-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
180 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
{ | ||
"plugins": [ | ||
["@babel/plugin-transform-typescript", { "allExtensions": true, "onlyRemoveTypeImports": true, "allowDeclareFields": true }], | ||
"@embroider/addon-dev/template-colocation-plugin", | ||
["@babel/plugin-proposal-decorators", { "version": "legacy" }], | ||
"@babel/plugin-proposal-class-properties", | ||
"./node_modules/ember-concurrency/async-arrow-task-transform" | ||
["babel-plugin-ember-template-compilation", { | ||
"targetFormat": "hbs", | ||
"transforms": [] | ||
}], | ||
["module:decorator-transforms", { "runtime": { "import": "decorator-transforms/runtime" } }] | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
import type { DropdownActions } from 'ember-basic-dropdown/components/basic-dropdown'; | ||
import type { CalculatePosition, VerticalPosition, HorizontalPosition } from 'ember-basic-dropdown/utils/calculate-position'; | ||
import type { NormalizeCalendarValue } from 'ember-power-calendar/utils'; | ||
import type { CalendarDay, SelectedDays, PowerCalendarActions } from 'ember-power-calendar/components/power-calendar'; | ||
import type { ComponentLike } from '@glint/template'; | ||
|
||
interface PowerDatepickerSignature { | ||
Element: HTMLElement; | ||
Args: PowerDatepickerArgs; | ||
Blocks: { | ||
default: [ | ||
PowerDatepickerDefaultBlock, | ||
]; | ||
}; | ||
} | ||
|
||
interface PowerDatepickerArgs { | ||
initiallyOpened?: boolean; | ||
renderInPlace?: boolean; | ||
verticalPosition?: VerticalPosition; | ||
horizontalPosition?: HorizontalPosition; | ||
destination?: string; | ||
disabled?: boolean; | ||
matchTriggerWidth?: boolean; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
onOpen?: Function; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
onClose?: Function; | ||
calculatePosition?: CalculatePosition; | ||
|
||
locale?: string; | ||
selected?: SelectedDays; | ||
closeOnSelect?: boolean; | ||
onCenterChange?: ( | ||
newCenter: NormalizeCalendarValue | ||
) => void; | ||
onSelect?: ( | ||
day: CalendarDay, | ||
calendar: PowerDatepickerCalendar, | ||
event: MouseEvent, | ||
) => void | boolean; | ||
} | ||
|
||
interface PowerDatepickerActions extends DropdownActions, PowerCalendarActions {} | ||
|
||
export interface PowerDatepickerCalendar { | ||
uniqueId: string; | ||
disabled: boolean; | ||
isOpen: boolean; | ||
calendarUniqueId: string; | ||
selected?: SelectedDays; | ||
loading: boolean; | ||
center: Date; | ||
locale: string; | ||
actions: PowerDatepickerActions; | ||
} | ||
|
||
export interface PowerDatepickerDefaultBlock extends PowerDatepickerCalendar { | ||
Trigger: ComponentLike<any>; | ||
Content: ComponentLike<any>; | ||
Nav: ComponentLike<any>; | ||
Days: ComponentLike<any>; | ||
} | ||
|
||
export default class PowerDatepickerComponent extends Component<PowerDatepickerSignature> { | ||
@tracked center: Date | undefined; | ||
|
||
get closeOnSelect() { | ||
return this.args.closeOnSelect !== undefined | ||
? this.args.closeOnSelect | ||
: true; | ||
} | ||
|
||
@action | ||
onCenterChange(day: NormalizeCalendarValue) { | ||
if (this.args.onCenterChange) { | ||
this.args.onCenterChange(day); | ||
} | ||
|
||
this.center = day.date; | ||
} | ||
|
||
@action | ||
handleSelect(day: CalendarDay, datepicker: PowerDatepickerCalendar, e: MouseEvent) { | ||
let value = this.args.onSelect && this.args.onSelect(day, datepicker, e); | ||
if (value === false || !this.closeOnSelect) { | ||
return; | ||
} | ||
|
||
datepicker.actions.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type PowerDatepickerComponent from './components/power-datepicker.ts'; | ||
|
||
export default interface EmberPowerDatepickerRegistry { | ||
PowerDatepicker: typeof PowerDatepickerComponent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import '@glint/environment-ember-loose'; | ||
|
||
import type { EmbroiderUtilRegistry } from '@embroider/util'; | ||
|
||
export interface AssignRegistry { | ||
[key: string]: any; | ||
} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry | ||
extends EmbroiderUtilRegistry /* other registries here */ { | ||
// ... | ||
} | ||
|
||
export default interface Registry | ||
extends AssignRegistry /* other registries here */ { | ||
// ... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"extends": "@tsconfig/ember/tsconfig.json", | ||
"include": [ | ||
"src/**/*", | ||
"unpublished-development-types/**/*" | ||
], | ||
"glint": { | ||
"environment": ["ember-loose", "ember-template-imports"] | ||
}, | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"moduleResolution": "node", | ||
"allowSyntheticDefaultImports": true, | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"alwaysStrict": true, | ||
"exactOptionalPropertyTypes": true, | ||
"strictNullChecks": true, | ||
"strictPropertyInitialization": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitOverride": true, | ||
"noImplicitReturns": true, | ||
"noEmitOnError": false, | ||
"noEmit": true, | ||
"allowImportingTsExtensions": true, | ||
"experimentalDecorators": true, | ||
"declarationDir": "declarations" | ||
} | ||
} |
Oops, something went wrong.