@haiilo/catalyst 10.28.2 → 10.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalyst/catalyst.css +3 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.esm.js +1 -1
- package/dist/catalyst/p-41a50f19.entry.js +10 -0
- package/dist/catalyst/p-41a50f19.entry.js.map +1 -0
- package/dist/catalyst/{p-e5aee21d.js → p-9500d6fb.js} +1 -1
- package/dist/catalyst/{p-e5aee21d.js.map → p-9500d6fb.js.map} +1 -1
- package/dist/catalyst/scss/core/_notification.scss +4 -1
- package/dist/catalyst/scss/utils/_elevation.mixins.scss +8 -2
- package/dist/cjs/cat-alert_30.cjs.entry.js +274 -180
- package/dist/cjs/cat-alert_30.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{of-aaee31a6.js → of-958251e4.js} +1 -1
- package/dist/cjs/{of-aaee31a6.js.map → of-958251e4.js.map} +1 -1
- package/dist/collection/components/cat-button/cat-button.css +1 -1
- package/dist/collection/components/cat-date/cat-date.js +8 -7
- package/dist/collection/components/cat-date/cat-date.js.map +1 -1
- package/dist/collection/components/cat-date-inline/cat-date-inline.js +10 -8
- package/dist/collection/components/cat-date-inline/cat-date-inline.js.map +1 -1
- package/dist/collection/components/cat-date-inline/cat-date-locale.js +2 -4
- package/dist/collection/components/cat-date-inline/cat-date-locale.js.map +1 -1
- package/dist/collection/components/cat-datepicker/cat-datepicker.js +9 -8
- package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -1
- package/dist/collection/components/cat-dropdown/cat-dropdown.js +1 -1
- package/dist/collection/components/cat-input/cat-input.js +8 -4
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-select/cat-select.js +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.js +25 -3
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-time/cat-time.js +8 -7
- package/dist/collection/components/cat-time/cat-time.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.css +18 -9
- package/dist/collection/scss/core/_notification.scss +4 -1
- package/dist/collection/scss/utils/_elevation.mixins.scss +8 -2
- package/dist/components/cat-button2.js +1 -1
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-date-inline2.js +12 -12
- package/dist/components/cat-date-inline2.js.map +1 -1
- package/dist/components/cat-date.js +3 -3
- package/dist/components/cat-date.js.map +1 -1
- package/dist/components/cat-datepicker.js +4 -4
- package/dist/components/cat-datepicker.js.map +1 -1
- package/dist/components/cat-dropdown2.js +169 -118
- package/dist/components/cat-dropdown2.js.map +1 -1
- package/dist/components/cat-input2.js +7 -4
- package/dist/components/cat-input2.js.map +1 -1
- package/dist/components/cat-textarea.js +8 -3
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-time.js +3 -3
- package/dist/components/cat-time.js.map +1 -1
- package/dist/components/cat-tooltip.js +1 -1
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/floating-ui.dom.esm.js +67 -29
- package/dist/components/floating-ui.dom.esm.js.map +1 -1
- package/dist/components/loglevel.js.map +1 -1
- package/dist/esm/cat-alert_30.entry.js +274 -180
- package/dist/esm/cat-alert_30.entry.js.map +1 -1
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{of-acb1f3a9.js → of-e4ec2eb4.js} +1 -1
- package/dist/esm/{of-acb1f3a9.js.map → of-e4ec2eb4.js.map} +1 -1
- package/dist/types/components/cat-date/cat-date.d.ts +1 -1
- package/dist/types/components/cat-datepicker/cat-datepicker.d.ts +1 -1
- package/dist/types/components/cat-input/cat-input.d.ts +2 -0
- package/dist/types/components/cat-textarea/cat-textarea.d.ts +6 -0
- package/dist/types/components/cat-time/cat-time.d.ts +1 -1
- package/dist/types/components.d.ts +11 -3
- package/package.json +8 -8
- package/dist/catalyst/p-ee89e395.entry.js +0 -10
- package/dist/catalyst/p-ee89e395.entry.js.map +0 -1
|
@@ -12,7 +12,7 @@ export class CatDate {
|
|
|
12
12
|
this.inputFocused = false;
|
|
13
13
|
this.requiredMarker = 'optional';
|
|
14
14
|
this.horizontal = false;
|
|
15
|
-
this.autoComplete =
|
|
15
|
+
this.autoComplete = 'off';
|
|
16
16
|
this.clearable = false;
|
|
17
17
|
this.disabled = false;
|
|
18
18
|
this.hint = undefined;
|
|
@@ -90,14 +90,14 @@ export class CatDate {
|
|
|
90
90
|
}
|
|
91
91
|
render() {
|
|
92
92
|
this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;
|
|
93
|
-
return (h(Host, { key: '
|
|
93
|
+
return (h(Host, { key: '9635d72c77b9f68f5d650a5ef9e1883672e4865f' }, h("cat-input", { key: '469f2bab5fd76cb6f09ee7b484cb222a154e3718', class: "cat-date-input", ref: el => (this.input = el), requiredMarker: this.requiredMarker, horizontal: this.horizontal, autoComplete: this.autoComplete, clearable: this.clearable, disabled: this.disabled, hint: this.hint, icon: this.icon, iconRight: this.iconRight, identifier: this.identifier, labelHidden: this.labelHidden, name: this.name, placeholder: this.placeholder, textPrefix: this.textPrefix, textSuffix: this.textSuffix, readonly: this.readonly, required: this.required, errors: this.errors, errorUpdate: this.errorUpdate, nativeAttributes: this.nativeAttributes, value: this.inputValue, onCatFocus: e => {
|
|
94
94
|
this.inputFocused = e.target === this.input;
|
|
95
95
|
e.stopPropagation();
|
|
96
96
|
this.catFocus.emit(e.detail);
|
|
97
97
|
}, onCatBlur: e => {
|
|
98
98
|
e.stopPropagation();
|
|
99
99
|
this.onInputBlur(e.detail);
|
|
100
|
-
} }, h("span", { key: '
|
|
100
|
+
} }, h("span", { key: '65e0c84bf675f0c76896f06452068acfb0326e2e', slot: "label" }, this.label, h("span", { key: '67f3e80eb70dd817b481ca7945edfc83d2451c78', class: "label-aria" }, " (", this.locale.formatStr, ")")), h("cat-dropdown", { key: 'a05ef8d20ade5dda5801e44142efdb3b532b76f7', slot: "addon", placement: this.placement, arrowNavigation: "none", noResize: true, onCatOpen: () => this.dateInline?.resetView() }, h("cat-button", { key: 'a4d464eead26162405655074e352e2024c04a201', slot: "trigger", icon: "$cat:datepicker-calendar", iconOnly: true, class: "cat-date-toggle", disabled: this.disabled, a11yLabel: this.getTriggerA11yLabel() }), h("div", { key: 'e9b8ac737e80392f98b933d4870309cb8843d166', slot: "content" }, h("cat-date-inline", { key: '541651169cd502dd166aa9443c6392118f3bd26a', ref: el => (this.dateInline = el), min: this.min, max: this.max, value: this.value, hint: true, weeks: true, noClear: true, onCatChange: this.onDateChange.bind(this) }))))));
|
|
101
101
|
}
|
|
102
102
|
getTriggerA11yLabel() {
|
|
103
103
|
const date = this.locale.fromLocalISO(this.value);
|
|
@@ -220,17 +220,18 @@ export class CatDate {
|
|
|
220
220
|
"mutable": false,
|
|
221
221
|
"complexType": {
|
|
222
222
|
"original": "string",
|
|
223
|
-
"resolved": "string
|
|
223
|
+
"resolved": "string",
|
|
224
224
|
"references": {}
|
|
225
225
|
},
|
|
226
226
|
"required": false,
|
|
227
|
-
"optional":
|
|
227
|
+
"optional": false,
|
|
228
228
|
"docs": {
|
|
229
229
|
"tags": [],
|
|
230
230
|
"text": "Hint for form autofill feature."
|
|
231
231
|
},
|
|
232
232
|
"attribute": "auto-complete",
|
|
233
|
-
"reflect": false
|
|
233
|
+
"reflect": false,
|
|
234
|
+
"defaultValue": "'off'"
|
|
234
235
|
},
|
|
235
236
|
"clearable": {
|
|
236
237
|
"type": "boolean",
|
|
@@ -594,7 +595,7 @@ export class CatDate {
|
|
|
594
595
|
"Placement": {
|
|
595
596
|
"location": "import",
|
|
596
597
|
"path": "@floating-ui/dom",
|
|
597
|
-
"id": "../node_modules/.pnpm/@floating-ui+dom@1.6.
|
|
598
|
+
"id": "../node_modules/.pnpm/@floating-ui+dom@1.6.13/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.ts::Placement"
|
|
598
599
|
}
|
|
599
600
|
}
|
|
600
601
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-date.js","sourceRoot":"","sources":["../../../src/components/cat-date/cat-date.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAExE;;GAEG;AAQH,MAAM,OAAO,OAAO;;QACD,aAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,WAAM,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAG3C,iBAAY,GAAG,KAAK,CAAC;8BAOqE,UAAU;0BAKvF,KAAK;;yBAUN,KAAK;wBAKN,KAAK;;;yBAeJ,KAAK;;qBAUT,EAAE;2BAKI,KAAK;;;;;;;wBAmCR,KAAK;wBAKL,KAAK;;;2BAsBgB,CAAC;;yBAUV,YAAY;;IAG3C,YAAY,CAAC,GAAY,EAAE,MAAe;QACxC,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAGD,YAAY,CAAC,GAAY,EAAE,MAAe;QACxC,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC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port { getLocale } from '../cat-date-inline/cat-date-locale';\nimport { clampDate } from '../cat-date-inline/cat-date-math';\nimport { ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\n/**\n * A date input component to select a date from a calendar in a dropdown.\n */\n@Component({\n tag: 'cat-date',\n styleUrl: 'cat-date.scss',\n shadow: {\n delegatesFocus: true\n }\n})\nexport class CatDate {\n private readonly language = i18n.getLocale();\n private readonly locale = getLocale(this.language);\n private input?: HTMLCatInputElement;\n private dateInline?: HTMLCatDateInlineElement;\n private inputFocused = false;\n\n @Element() hostElement!: HTMLElement;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker?: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() min?: string;\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The value of the control, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors change with the given delay in milliseconds or immediately on blur.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * The placement of the dropdown.\n */\n @Prop() placement: Placement = 'bottom-end';\n\n @Watch('min')\n onMinChanged(min?: string, oldMin?: string) {\n if (min !== oldMin) {\n this.reclamp('min', min);\n }\n }\n\n @Watch('max')\n onMaxChanged(max?: string, oldMax?: string) {\n if (max !== oldMax) {\n this.reclamp('max', max);\n }\n }\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n private get inputValue() {\n const [match, year, month, day] = this.value?.match(/^(\\d{4})-(\\d{2})-(\\d{2})/) ?? [];\n if (match) {\n const date = new Date(Number(year), Number(month) - 1, Number(day));\n const format = new Intl.DateTimeFormat(this.language, { year: 'numeric', month: '2-digit', day: '2-digit' });\n return format.format(date);\n }\n return '';\n }\n\n componentDidLoad() {\n const format = this.locale.formatStr.replace('YYYY', 'Y').replace('YY', 'y').replace('MM', 'm').replace('DD', 'd');\n const [, p1, d1, p2, p3] = /(\\w+)([^\\w]+)(\\w+)[^\\w]+(\\w+)/.exec(format) || [];\n this.input?.mask({\n date: true,\n dateMin: this.min,\n dateMax: this.max,\n delimiter: d1,\n datePattern: [p1, p2, p3]\n });\n }\n\n /**\n * Programmatically move focus to the input. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input?.doFocus(options);\n }\n\n /**\n * Programmatically remove focus from the input. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input?.doBlur();\n }\n\n /**\n * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.input?.clear();\n }\n\n render() {\n this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;\n return (\n <Host>\n <cat-input\n class=\"cat-date-input\"\n ref={el => (this.input = el as HTMLCatInputElement)}\n requiredMarker={this.requiredMarker}\n horizontal={this.horizontal}\n autoComplete={this.autoComplete}\n clearable={this.clearable}\n disabled={this.disabled}\n hint={this.hint}\n icon={this.icon}\n iconRight={this.iconRight}\n identifier={this.identifier}\n labelHidden={this.labelHidden}\n name={this.name}\n placeholder={this.placeholder}\n textPrefix={this.textPrefix}\n textSuffix={this.textSuffix}\n readonly={this.readonly}\n required={this.required}\n errors={this.errors}\n errorUpdate={this.errorUpdate}\n nativeAttributes={this.nativeAttributes}\n value={this.inputValue}\n onCatFocus={e => {\n this.inputFocused = e.target === this.input;\n e.stopPropagation();\n this.catFocus.emit(e.detail);\n }}\n onCatBlur={e => {\n e.stopPropagation();\n this.onInputBlur(e.detail);\n }}\n >\n <span slot=\"label\">\n {this.label}\n <span class=\"label-aria\"> ({this.locale.formatStr})</span>\n </span>\n <cat-dropdown\n slot=\"addon\"\n placement={this.placement}\n arrowNavigation=\"none\"\n noResize\n onCatOpen={() => this.dateInline?.resetView()}\n >\n <cat-button\n slot=\"trigger\"\n icon=\"$cat:datepicker-calendar\"\n iconOnly\n class=\"cat-date-toggle\"\n disabled={this.disabled}\n a11yLabel={this.getTriggerA11yLabel()}\n ></cat-button>\n <div slot=\"content\">\n <cat-date-inline\n ref={el => (this.dateInline = el as HTMLCatDateInlineElement)}\n min={this.min}\n max={this.max}\n value={this.value}\n hint\n weeks\n noClear\n onCatChange={this.onDateChange.bind(this)}\n ></cat-date-inline>\n </div>\n </cat-dropdown>\n </cat-input>\n </Host>\n );\n }\n\n private getTriggerA11yLabel() {\n const date = this.locale.fromLocalISO(this.value);\n return date ? `${this.locale.change}, ${this.locale.toLocalStr(date)}` : this.locale.choose;\n }\n\n private onInputBlur(e: FocusEvent) {\n if (!this.input || !this.inputFocused) {\n return;\n }\n this.inputFocused = false;\n const oldValue = this.value;\n const dateParsed = this.parse(this.input.value ?? '');\n const dateMin = this.locale.fromLocalISO(this.min);\n const dateMax = this.locale.fromLocalISO(this.max);\n const date = dateParsed ? clampDate(dateMin, dateParsed, dateMax) : null;\n this.value = date ? this.locale.toLocalISO(date) : undefined;\n if (oldValue !== this.value) {\n if (date) {\n this.dateInline?.select(date);\n } else {\n this.dateInline?.clear();\n }\n this.catChange.emit(this.value);\n }\n this.input.value = this.inputValue;\n this.catBlur.emit(e);\n }\n\n private onDateChange(e: CustomEvent<string>) {\n e.stopPropagation();\n const oldValue = this.value;\n const date = e.detail ? this.locale.fromLocalISO(e.detail) : null;\n this.value = date ? this.locale.toLocalISO(date) : undefined;\n if (oldValue !== this.value) {\n this.catChange.emit(this.value);\n }\n }\n\n private parse(value: string) {\n const [, p1, d1, p2, p3] = /(\\w+)([^\\w]+)(\\w+)[^\\w]+(\\w+)/.exec(this.locale.formatStr) || [];\n const formatParts = [p1, p2, p3];\n const parts = value.split(d1).map(s => Number(s || 'x'));\n let year = parts[formatParts.indexOf('YYYY') || formatParts.indexOf('YY')] || this.locale.now().getFullYear();\n const month = parts[formatParts.indexOf('MM')];\n const day = parts[formatParts.indexOf('DD')];\n if (!Number.isInteger(month) || !Number.isInteger(day)) {\n return null;\n } else if (year < 100) {\n year += year < 50 ? 2000 : 1900;\n }\n return new Date(year, month - 1, day);\n }\n\n private reclamp(mode: 'min' | 'max', limit: string | undefined) {\n const oldValue = this.value;\n const oldDate = this.locale.fromLocalISO(oldValue);\n const limitDate = this.locale.fromLocalISO(limit);\n if (!oldDate || !limitDate) {\n return;\n }\n const newDate = clampDate(mode === 'min' ? limitDate : null, oldDate, mode === 'max' ? limitDate : null);\n const newValue = this.locale.toLocalISO(newDate);\n if (oldValue !== newValue) {\n this.value = newValue;\n this.catChange.emit(newValue);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cat-date.js","sourceRoot":"","sources":["../../../src/components/cat-date/cat-date.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAExE;;GAEG;AAQH,MAAM,OAAO,OAAO;;QACD,aAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,WAAM,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAG3C,iBAAY,GAAG,KAAK,CAAC;8BAOqE,UAAU;0BAKvF,KAAK;4BAKH,KAAK;yBAKR,KAAK;wBAKN,KAAK;;;yBAeJ,KAAK;;qBAUT,EAAE;2BAKI,KAAK;;;;;;;wBAmCR,KAAK;wBAKL,KAAK;;;2BAsBgB,CAAC;;yBAUV,YAAY;;IAG3C,YAAY,CAAC,GAAY,EAAE,MAAe;QACxC,IAAI,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Placement } from '@floating-ui/dom';\nimport { Component, Element, Event, EventEmitter, Host, Method, Prop, Watch, h } from '@stencil/core';\nimport { getLocale } from '../cat-date-inline/cat-date-locale';\nimport { clampDate } from '../cat-date-inline/cat-date-math';\nimport { ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\n/**\n * A date input component to select a date from a calendar in a dropdown.\n */\n@Component({\n tag: 'cat-date',\n styleUrl: 'cat-date.scss',\n shadow: {\n delegatesFocus: true\n }\n})\nexport class CatDate {\n private readonly language = i18n.getLocale();\n private readonly locale = getLocale(this.language);\n private input?: HTMLCatInputElement;\n private dateInline?: HTMLCatDateInlineElement;\n private inputFocused = false;\n\n @Element() hostElement!: HTMLElement;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker?: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete = 'off';\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() min?: string;\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The value of the control, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors change with the given delay in milliseconds or immediately on blur.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * The placement of the dropdown.\n */\n @Prop() placement: Placement = 'bottom-end';\n\n @Watch('min')\n onMinChanged(min?: string, oldMin?: string) {\n if (min !== oldMin) {\n this.reclamp('min', min);\n }\n }\n\n @Watch('max')\n onMaxChanged(max?: string, oldMax?: string) {\n if (max !== oldMax) {\n this.reclamp('max', max);\n }\n }\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n private get inputValue() {\n const [match, year, month, day] = this.value?.match(/^(\\d{4})-(\\d{2})-(\\d{2})/) ?? [];\n if (match) {\n const date = new Date(Number(year), Number(month) - 1, Number(day));\n const format = new Intl.DateTimeFormat(this.language, { year: 'numeric', month: '2-digit', day: '2-digit' });\n return format.format(date);\n }\n return '';\n }\n\n componentDidLoad() {\n const format = this.locale.formatStr.replace('YYYY', 'Y').replace('YY', 'y').replace('MM', 'm').replace('DD', 'd');\n const [, p1, d1, p2, p3] = /(\\w+)([^\\w]+)(\\w+)[^\\w]+(\\w+)/.exec(format) || [];\n this.input?.mask({\n date: true,\n dateMin: this.min,\n dateMax: this.max,\n delimiter: d1,\n datePattern: [p1, p2, p3]\n });\n }\n\n /**\n * Programmatically move focus to the input. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input?.doFocus(options);\n }\n\n /**\n * Programmatically remove focus from the input. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input?.doBlur();\n }\n\n /**\n * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.input?.clear();\n }\n\n render() {\n this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;\n return (\n <Host>\n <cat-input\n class=\"cat-date-input\"\n ref={el => (this.input = el as HTMLCatInputElement)}\n requiredMarker={this.requiredMarker}\n horizontal={this.horizontal}\n autoComplete={this.autoComplete}\n clearable={this.clearable}\n disabled={this.disabled}\n hint={this.hint}\n icon={this.icon}\n iconRight={this.iconRight}\n identifier={this.identifier}\n labelHidden={this.labelHidden}\n name={this.name}\n placeholder={this.placeholder}\n textPrefix={this.textPrefix}\n textSuffix={this.textSuffix}\n readonly={this.readonly}\n required={this.required}\n errors={this.errors}\n errorUpdate={this.errorUpdate}\n nativeAttributes={this.nativeAttributes}\n value={this.inputValue}\n onCatFocus={e => {\n this.inputFocused = e.target === this.input;\n e.stopPropagation();\n this.catFocus.emit(e.detail);\n }}\n onCatBlur={e => {\n e.stopPropagation();\n this.onInputBlur(e.detail);\n }}\n >\n <span slot=\"label\">\n {this.label}\n <span class=\"label-aria\"> ({this.locale.formatStr})</span>\n </span>\n <cat-dropdown\n slot=\"addon\"\n placement={this.placement}\n arrowNavigation=\"none\"\n noResize\n onCatOpen={() => this.dateInline?.resetView()}\n >\n <cat-button\n slot=\"trigger\"\n icon=\"$cat:datepicker-calendar\"\n iconOnly\n class=\"cat-date-toggle\"\n disabled={this.disabled}\n a11yLabel={this.getTriggerA11yLabel()}\n ></cat-button>\n <div slot=\"content\">\n <cat-date-inline\n ref={el => (this.dateInline = el as HTMLCatDateInlineElement)}\n min={this.min}\n max={this.max}\n value={this.value}\n hint\n weeks\n noClear\n onCatChange={this.onDateChange.bind(this)}\n ></cat-date-inline>\n </div>\n </cat-dropdown>\n </cat-input>\n </Host>\n );\n }\n\n private getTriggerA11yLabel() {\n const date = this.locale.fromLocalISO(this.value);\n return date ? `${this.locale.change}, ${this.locale.toLocalStr(date)}` : this.locale.choose;\n }\n\n private onInputBlur(e: FocusEvent) {\n if (!this.input || !this.inputFocused) {\n return;\n }\n this.inputFocused = false;\n const oldValue = this.value;\n const dateParsed = this.parse(this.input.value ?? '');\n const dateMin = this.locale.fromLocalISO(this.min);\n const dateMax = this.locale.fromLocalISO(this.max);\n const date = dateParsed ? clampDate(dateMin, dateParsed, dateMax) : null;\n this.value = date ? this.locale.toLocalISO(date) : undefined;\n if (oldValue !== this.value) {\n if (date) {\n this.dateInline?.select(date);\n } else {\n this.dateInline?.clear();\n }\n this.catChange.emit(this.value);\n }\n this.input.value = this.inputValue;\n this.catBlur.emit(e);\n }\n\n private onDateChange(e: CustomEvent<string>) {\n e.stopPropagation();\n const oldValue = this.value;\n const date = e.detail ? this.locale.fromLocalISO(e.detail) : null;\n this.value = date ? this.locale.toLocalISO(date) : undefined;\n if (oldValue !== this.value) {\n this.catChange.emit(this.value);\n }\n }\n\n private parse(value: string) {\n const [, p1, d1, p2, p3] = /(\\w+)([^\\w]+)(\\w+)[^\\w]+(\\w+)/.exec(this.locale.formatStr) || [];\n const formatParts = [p1, p2, p3];\n const parts = value.split(d1).map(s => Number(s || 'x'));\n let year = parts[formatParts.indexOf('YYYY') || formatParts.indexOf('YY')] || this.locale.now().getFullYear();\n const month = parts[formatParts.indexOf('MM')];\n const day = parts[formatParts.indexOf('DD')];\n if (!Number.isInteger(month) || !Number.isInteger(day)) {\n return null;\n } else if (year < 100) {\n year += year < 50 ? 2000 : 1900;\n }\n return new Date(year, month - 1, day);\n }\n\n private reclamp(mode: 'min' | 'max', limit: string | undefined) {\n const oldValue = this.value;\n const oldDate = this.locale.fromLocalISO(oldValue);\n const limitDate = this.locale.fromLocalISO(limit);\n if (!oldDate || !limitDate) {\n return;\n }\n const newDate = clampDate(mode === 'min' ? limitDate : null, oldDate, mode === 'max' ? limitDate : null);\n const newValue = this.locale.toLocalISO(newDate);\n if (oldValue !== newValue) {\n this.value = newValue;\n this.catChange.emit(newValue);\n }\n }\n}\n"]}
|
|
@@ -191,14 +191,16 @@ export class CatDateInline {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
navigate(direction, period) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
194
|
+
const offset = direction === 'prev' ? -1 : 1;
|
|
195
|
+
const targetYear = this.viewDate.getFullYear() + (period === 'year' ? offset : 0);
|
|
196
|
+
const targetMonth = this.viewDate.getMonth() + (period === 'month' ? offset : 0);
|
|
197
|
+
const date = new Date(this.viewDate);
|
|
198
|
+
date.setFullYear(targetYear);
|
|
199
|
+
date.setMonth(targetMonth);
|
|
200
|
+
const minDate = new Date(targetYear, targetMonth, 1);
|
|
201
|
+
const maxDay = new Date(targetYear, targetMonth + 1, 0).getDate();
|
|
202
|
+
const maxDate = new Date(targetYear, targetMonth, maxDay);
|
|
203
|
+
this.viewDate = clampDate(minDate, date, maxDate);
|
|
202
204
|
this.setAriaLive(this.getHeadline());
|
|
203
205
|
}
|
|
204
206
|
setAriaLive(text) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-date-inline.js","sourceRoot":"","sources":["../../../src/components/cat-date-inline/cat-date-inline.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,aAAa,MAAM,4BAA4B,CAAC;AAEvD,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;GAIG;AAQH,MAAM,OAAO,aAAa;;QACP,QAAG,GAAG,mBAAmB,YAAY,EAAE,EAAE,CAAC;QAK1C,aAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,WAAM,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnD,qFAAqF;QAC7E,cAAS,GAAgB,IAAI,CAAC;+BAIX,KAAK;8BACN,KAAK;wBAEL,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;uBAKzB,KAAK;;oBAUR,KAAK;uBAKF,KAAK;qBAKP,KAAK;qBAKL,EAAE;2BAKI,KAAK;;;qBAeX,KAAK;wBAKF,KAAK;;8BAW0E,UAAU;;;IAhF5G,IAAY,EAAE;QACZ,OAAO,IAAI,CAAC,UAAU,IAAI,IAA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AAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, Host, Listen, Method, Prop, State, h } from '@stencil/core';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { getLocale } from './cat-date-locale';\nimport { addDays, addMonth, clampDate, isSameDay, isSameMonth, isSameYear } from './cat-date-math';\nimport firstTabbable from '../../utils/first-tabbable';\n\nlet nextUniqueId = 0;\n\n/**\n * An inline date picker component to select a date.\n *\n * @part label - The native label element.\n */\n@Component({\n tag: 'cat-date-inline',\n styleUrl: 'cat-date-inline.scss',\n shadow: {\n delegatesFocus: true\n }\n})\nexport class CatDateInline {\n private readonly _id = `cat-date-inline-${nextUniqueId++}`;\n private get id() {\n return this.identifier || this._id;\n }\n\n private readonly language = i18n.getLocale();\n private readonly locale = getLocale(this.language);\n // additonally store the focus date to ensure correct focus after potential re-render\n private focusDate: Date | null = null;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n @State() hasSlottedHint = false;\n\n @State() viewDate: Date = this.locale.now();\n\n /**\n * Hides the clear button.\n */\n @Prop() noClear = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * Shows an arrow keys navigation hint.\n */\n @Prop() hint = false;\n\n /**\n * Hides the today button.\n */\n @Prop() noToday = false;\n\n /**\n * Show week numbers.\n */\n @Prop() weeks = false;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A minimum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() min?: string;\n\n /**\n * A maximum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() max?: string;\n\n /**\n * Allow the selection of a range of dates, i.e. start and end date.\n */\n @Prop() range = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * Adds accessible label for the datepicker. The label will be read by\n * assistive technology upon focusing the datepicker.\n */\n @Prop({ attribute: 'a11y-label' }) a11yLabel?: string;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker?: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * The value of the control, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n private get focusedDate() {\n const [all, year, month, day] =\n this.hostElement.shadowRoot\n ?.querySelector<HTMLCatButtonElement>(`[data-date]:focus`)\n ?.dataset.date?.match(/^(\\d{4})-(\\d{2})-(\\d{2})/) ?? [];\n return all ? new Date(Number(year), Number(month) - 1, Number(day)) : null;\n }\n\n componentWillLoad() {\n const [startDate, endDate] = this.getValue();\n if (endDate) {\n this.focus(endDate, false);\n } else if (startDate) {\n this.focus(startDate, false);\n }\n this.hostElement.addEventListener('focusin', () => this.setAriaLive(this.a11yLabel));\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n }\n\n componentDidRender() {\n if (this.focusDate) {\n // re-focus the previously focused date after re-render\n this.hostElement.shadowRoot\n ?.querySelector<HTMLCatButtonElement>(`[data-date=\"${this.locale.toLocalISO(this.focusDate)}\"]`)\n ?.doFocus();\n this.focusDate = null;\n }\n }\n\n @Listen('keydown')\n onKeyDown(e: KeyboardEvent) {\n if (!['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(e.key)) {\n return;\n }\n const focusedDate = this.focusedDate;\n if (!focusedDate) {\n e.preventDefault();\n const [startDate] = this.getValue();\n this.focus(startDate || this.locale.now());\n } else if (e.key === 'ArrowLeft') {\n e.preventDefault();\n this.focus(e.shiftKey ? addMonth(focusedDate, -1) : addDays(focusedDate, -1));\n } else if (e.key === 'ArrowRight') {\n e.preventDefault();\n this.focus(e.shiftKey ? addMonth(focusedDate, 1) : addDays(focusedDate, 1));\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n this.focus(addDays(focusedDate, -7));\n } else if (e.key === 'ArrowDown') {\n e.preventDefault();\n this.focus(addDays(focusedDate, 7));\n }\n }\n\n /**\n * Select a date in the picker.\n *\n * @param date The date to select.\n */\n @Method()\n async select(date: Date | null): Promise<void> {\n if (!date) {\n return this.clear();\n }\n const oldValue = this.value;\n const [minDate, maxDate] = this.getMinMaxDate();\n const newDate = clampDate(minDate, new Date(date.getFullYear(), date.getMonth(), date.getDate()), maxDate);\n this.focus(newDate);\n\n if (this.range) {\n const [startDate, endDate] = this.getValue();\n if (!startDate || endDate || newDate < startDate) {\n this.value = this.toRangeValue(newDate, null);\n } else {\n this.value = this.toRangeValue(startDate, newDate);\n }\n } else {\n this.value = this.locale.toLocalISO(newDate);\n }\n\n if (oldValue !== this.value) {\n this.catChange.emit(this.value);\n }\n }\n\n /**\n * Clear the picker.\n */\n @Method()\n async clear(): Promise<void> {\n const oldValue = this.value;\n this.value = undefined;\n if (oldValue !== this.value) {\n this.catChange.emit(this.value);\n }\n }\n\n /**\n * Resets the view of the picker.\n */\n @Method()\n async resetView(): Promise<void> {\n const [minDate, maxDate] = this.getMinMaxDate();\n const [dateStart] = this.getValue();\n this.viewDate = dateStart ?? clampDate(minDate, this.locale.now(), maxDate);\n }\n\n /**\n * Programmatically move focus to the inline datepicker, i,e, the first\n * focusable date.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n firstTabbable(this.hostElement.shadowRoot?.querySelector('.picker-grid-days'))?.focus(options);\n }\n\n render() {\n this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;\n const [minDate, maxDate] = this.getMinMaxDate();\n const dateGrid = this.dateGrid(this.viewDate.getFullYear(), this.viewDate.getMonth());\n const [dateStart, dateEnd] = this.getValue();\n return (\n <Host aria-label={this.label || undefined}>\n <div class={{ 'label-container': true, 'label-hidden': this.labelHidden }}>\n {(this.hasSlottedLabel || this.label) && (\n <label id={`${this.id}-label`} htmlFor={this.id} part=\"label\" onClick={() => this.doFocus()}>\n <span class=\"label-wrapper\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n <div class=\"label-metadata\">\n {!this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.optional')})\n </span>\n )}\n {this.required && this.requiredMarker?.startsWith('required') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.required')})\n </span>\n )}\n </div>\n </span>\n </label>\n )}\n </div>\n <div class={{ picker: true, 'picker-weeks': this.weeks }} id={this.id} aria-describedby={`${this.id}-label`}>\n <div class=\"picker-head\">\n <cat-button\n icon=\"$cat:datepicker-year-prev\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.prevYear}\n disabled={isSameYear(this.viewDate, minDate)}\n onClick={() => this.navigate('prev', 'year')}\n data-dropdown-no-close\n ></cat-button>\n <cat-button\n icon=\"$cat:datepicker-month-prev\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.prevMonth}\n disabled={isSameMonth(this.viewDate, minDate)}\n onClick={() => this.navigate('prev', 'month')}\n data-dropdown-no-close\n ></cat-button>\n <h3>{this.getHeadline()}</h3>\n <cat-button\n icon=\"$cat:datepicker-month-next\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.nextMonth}\n disabled={isSameMonth(this.viewDate, maxDate)}\n onClick={() => this.navigate('next', 'month')}\n data-dropdown-no-close\n ></cat-button>\n <cat-button\n icon=\"$cat:datepicker-year-next\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.nextYear}\n disabled={isSameYear(this.viewDate, maxDate)}\n onClick={() => this.navigate('next', 'year')}\n data-dropdown-no-close\n ></cat-button>\n </div>\n <div class=\"picker-grid\" onFocusin={() => this.setAriaLive(this.locale.arrowKeys)}>\n <div class=\"picker-grid-head\">\n {Array.from(Array(7), (_, i) => {\n const day = (i + this.locale.weekInfo.firstDay) % 7;\n return <abbr title={this.locale.days.long[day]}>{this.locale.days.short[day]}</abbr>;\n })}\n </div>\n {this.weeks && (\n <div class=\"picker-grid-weeks\">\n {dateGrid\n .filter((_, i) => i % 7 === 0)\n .map(day => (\n <div>{this.getWeekNumber(day)}</div>\n ))}\n </div>\n )}\n <div class=\"picker-grid-days\">\n {dateGrid.map(day => {\n const isStartDate = isSameDay(dateStart, day);\n const isEndDate = isSameDay(dateEnd, day);\n const isRange = !!dateStart && !!dateEnd && day > dateStart && day < dateEnd;\n const isToday = isSameDay(this.locale.now(), day);\n const isWeekend = this.locale.weekInfo.weekend.includes(day.getDay() || 7);\n return (\n <cat-button\n class={{\n 'cat-date-item': true,\n 'date-other': !isSameMonth(this.viewDate, day),\n 'date-today': isToday,\n 'date-weekend': isWeekend,\n 'date-start': this.range && isStartDate,\n 'date-range': this.range && isRange,\n 'date-end': this.range && isEndDate,\n 'date-focusable': this.canFocus(day),\n 'date-disabled': !this.canClick(day)\n }}\n nativeAttributes={!this.canFocus(day) ? { tabindex: '-1' } : {}}\n variant={isStartDate || isEndDate ? 'filled' : isToday ? 'outlined' : 'text'}\n a11yLabel={this.locale.toLocalStr(day)}\n active={isStartDate || isEndDate || isRange}\n color={isStartDate || isEndDate || isToday ? 'primary' : 'secondary'}\n disabled={!this.canClick(day)}\n onClick={() => this.select(day)}\n data-date={this.locale.toLocalISO(day)}\n >\n {day.getDate()}\n </cat-button>\n );\n })}\n </div>\n </div>\n <div class=\"picker-foot\">\n {!this.noToday && this.canClick(this.locale.now()) && (\n <cat-button size=\"s\" data-dropdown-no-close onClick={() => this.select(this.locale.now())}>\n {this.locale.today}\n </cat-button>\n )}\n {this.hint && <p class=\"cursor-help\">{this.locale.arrowKeys}</p>}\n {!this.noClear && (\n <cat-button size=\"s\" disabled={!this.value} data-dropdown-no-close onClick={() => this.clear()}>\n {this.locale.clear}\n </cat-button>\n )}\n </div>\n </div>\n <p class=\"cursor-aria\" aria-live=\"polite\"></p>\n </Host>\n );\n }\n\n private focus(date: Date, focus = true) {\n const [minDate, maxDate] = this.getMinMaxDate();\n const focusDate = clampDate(minDate, date, maxDate);\n this.viewDate = new Date(focusDate.getFullYear(), focusDate.getMonth());\n if (focus) {\n this.focusDate = focusDate;\n this.hostElement.shadowRoot\n ?.querySelector<HTMLCatButtonElement>(`[data-date=\"${this.locale.toLocalISO(focusDate)}\"]`)\n ?.doFocus();\n }\n }\n\n private navigate(direction: 'prev' | 'next', period: 'year' | 'month') {\n this.viewDate = new Date(\n direction === 'prev'\n ? period === 'year'\n ? this.viewDate.setFullYear(this.viewDate.getFullYear() - 1)\n : this.viewDate.setMonth(this.viewDate.getMonth() - 1)\n : period === 'year'\n ? this.viewDate.setFullYear(this.viewDate.getFullYear() + 1)\n : this.viewDate.setMonth(this.viewDate.getMonth() + 1)\n );\n // announce the new month and year\n this.setAriaLive(this.getHeadline());\n }\n\n private setAriaLive(text?: string) {\n const node = this.hostElement.shadowRoot?.querySelector('.cursor-aria');\n if (node && text) {\n node.innerHTML = text;\n }\n }\n\n private dateGrid(year: number, month: number) {\n const daysOffset = (new Date(year, month, 1).getDay() - this.locale.weekInfo.firstDay + 7) % 7;\n const daysInMonth = new Date(year, month + 1, 0).getDate();\n const days = [...Array(daysInMonth).keys()];\n const daysBefore = this.getLastDaysOfMonth(year, month, daysOffset);\n const daysAfter = [...Array(42 - days.length - daysBefore.length).keys()];\n return [\n ...daysBefore.map(day => new Date(year, month - 1, day + 1)),\n ...days.map(day => new Date(year, month, day + 1)),\n ...daysAfter.map(day => new Date(year, month + 1, day + 1))\n ];\n }\n\n private getLastDaysOfMonth(year: number, month: number, x: number): number[] {\n const lastDayOfMonth = new Date(year, month, 0).getDate();\n const daysOfMonth = Array.from({ length: lastDayOfMonth }, (_, index) => index);\n return x ? daysOfMonth.slice(-x) : [];\n }\n\n private getHeadline() {\n return `${this.locale.months.long[this.viewDate.getMonth()]} ${this.viewDate.getFullYear()}`;\n }\n\n private getWeekNumber(date: Date, iso8601 = true) {\n const currentDate = new Date(date.getTime());\n const dayNum = iso8601 ? currentDate.getDay() || 7 : currentDate.getDay();\n currentDate.setDate(currentDate.getDate() + 4 - dayNum);\n const yearStart = new Date(currentDate.getFullYear(), 0, 1);\n return Math.ceil(((+currentDate - +yearStart) / 86400000 + 1) / 7);\n }\n\n private canFocus(date: Date): boolean {\n const now = this.locale.now();\n const [minDate] = this.getMinMaxDate();\n const focusedDate = this.focusedDate;\n const [startDate] = this.getValue();\n if (focusedDate && isSameMonth(focusedDate, this.viewDate)) {\n return isSameMonth(focusedDate, date) && isSameDay(focusedDate, date);\n } else if (startDate && isSameMonth(startDate, this.viewDate)) {\n return isSameMonth(startDate, date) && isSameDay(startDate, date);\n } else if (isSameMonth(this.viewDate, now) && (!minDate || minDate <= now)) {\n return isSameMonth(this.viewDate, date) && isSameDay(now, date);\n }\n const minDay = isSameMonth(date, minDate) ? (minDate?.getDate() ?? 1) : 1;\n return isSameMonth(this.viewDate, date) && date.getDate() === minDay;\n }\n\n private canClick(date: Date) {\n const [minDate, maxDate] = this.getMinMaxDate();\n return (!minDate || minDate <= date) && (!maxDate || maxDate >= date);\n }\n\n private getMinMaxDate() {\n const minDate = this.locale.fromLocalISO(this.min);\n const maxDate = this.locale.fromLocalISO(this.max);\n return [minDate, maxDate];\n }\n\n private getValue(): [Date | null, Date | null] {\n if (this.range) {\n const [startDate, endDate] = JSON.parse(this.value || '[]') as [string | null, string | null];\n return [this.locale.fromLocalISO(startDate), this.locale.fromLocalISO(endDate)];\n } else {\n return [this.locale.fromLocalISO(this.value), null];\n }\n }\n\n private toRangeValue(startDate: Date | null, endDate: Date | null): string {\n return JSON.stringify([startDate, endDate].map(date => (date ? this.locale.toLocalISO(date) : null)));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cat-date-inline.js","sourceRoot":"","sources":["../../../src/components/cat-date-inline/cat-date-inline.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,aAAa,MAAM,4BAA4B,CAAC;AAEvD,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;GAIG;AAQH,MAAM,OAAO,aAAa;;QACP,QAAG,GAAG,mBAAmB,YAAY,EAAE,EAAE,CAAC;QAK1C,aAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,CA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, Host, Listen, Method, Prop, State, h } from '@stencil/core';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { getLocale } from './cat-date-locale';\nimport { addDays, addMonth, clampDate, isSameDay, isSameMonth, isSameYear } from './cat-date-math';\nimport firstTabbable from '../../utils/first-tabbable';\n\nlet nextUniqueId = 0;\n\n/**\n * An inline date picker component to select a date.\n *\n * @part label - The native label element.\n */\n@Component({\n tag: 'cat-date-inline',\n styleUrl: 'cat-date-inline.scss',\n shadow: {\n delegatesFocus: true\n }\n})\nexport class CatDateInline {\n private readonly _id = `cat-date-inline-${nextUniqueId++}`;\n private get id() {\n return this.identifier || this._id;\n }\n\n private readonly language = i18n.getLocale();\n private readonly locale = getLocale(this.language);\n // additonally store the focus date to ensure correct focus after potential re-render\n private focusDate: Date | null = null;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n @State() hasSlottedHint = false;\n\n @State() viewDate: Date = this.locale.now();\n\n /**\n * Hides the clear button.\n */\n @Prop() noClear = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * Shows an arrow keys navigation hint.\n */\n @Prop() hint = false;\n\n /**\n * Hides the today button.\n */\n @Prop() noToday = false;\n\n /**\n * Show week numbers.\n */\n @Prop() weeks = false;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A minimum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() min?: string;\n\n /**\n * A maximum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() max?: string;\n\n /**\n * Allow the selection of a range of dates, i.e. start and end date.\n */\n @Prop() range = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * Adds accessible label for the datepicker. The label will be read by\n * assistive technology upon focusing the datepicker.\n */\n @Prop({ attribute: 'a11y-label' }) a11yLabel?: string;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker?: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * The value of the control, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n private get focusedDate() {\n const [all, year, month, day] =\n this.hostElement.shadowRoot\n ?.querySelector<HTMLCatButtonElement>(`[data-date]:focus`)\n ?.dataset.date?.match(/^(\\d{4})-(\\d{2})-(\\d{2})/) ?? [];\n return all ? new Date(Number(year), Number(month) - 1, Number(day)) : null;\n }\n\n componentWillLoad() {\n const [startDate, endDate] = this.getValue();\n if (endDate) {\n this.focus(endDate, false);\n } else if (startDate) {\n this.focus(startDate, false);\n }\n this.hostElement.addEventListener('focusin', () => this.setAriaLive(this.a11yLabel));\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n }\n\n componentDidRender() {\n if (this.focusDate) {\n // re-focus the previously focused date after re-render\n this.hostElement.shadowRoot\n ?.querySelector<HTMLCatButtonElement>(`[data-date=\"${this.locale.toLocalISO(this.focusDate)}\"]`)\n ?.doFocus();\n this.focusDate = null;\n }\n }\n\n @Listen('keydown')\n onKeyDown(e: KeyboardEvent) {\n if (!['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(e.key)) {\n return;\n }\n const focusedDate = this.focusedDate;\n if (!focusedDate) {\n e.preventDefault();\n const [startDate] = this.getValue();\n this.focus(startDate || this.locale.now());\n } else if (e.key === 'ArrowLeft') {\n e.preventDefault();\n this.focus(e.shiftKey ? addMonth(focusedDate, -1) : addDays(focusedDate, -1));\n } else if (e.key === 'ArrowRight') {\n e.preventDefault();\n this.focus(e.shiftKey ? addMonth(focusedDate, 1) : addDays(focusedDate, 1));\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n this.focus(addDays(focusedDate, -7));\n } else if (e.key === 'ArrowDown') {\n e.preventDefault();\n this.focus(addDays(focusedDate, 7));\n }\n }\n\n /**\n * Select a date in the picker.\n *\n * @param date The date to select.\n */\n @Method()\n async select(date: Date | null): Promise<void> {\n if (!date) {\n return this.clear();\n }\n const oldValue = this.value;\n const [minDate, maxDate] = this.getMinMaxDate();\n const newDate = clampDate(minDate, new Date(date.getFullYear(), date.getMonth(), date.getDate()), maxDate);\n this.focus(newDate);\n\n if (this.range) {\n const [startDate, endDate] = this.getValue();\n if (!startDate || endDate || newDate < startDate) {\n this.value = this.toRangeValue(newDate, null);\n } else {\n this.value = this.toRangeValue(startDate, newDate);\n }\n } else {\n this.value = this.locale.toLocalISO(newDate);\n }\n\n if (oldValue !== this.value) {\n this.catChange.emit(this.value);\n }\n }\n\n /**\n * Clear the picker.\n */\n @Method()\n async clear(): Promise<void> {\n const oldValue = this.value;\n this.value = undefined;\n if (oldValue !== this.value) {\n this.catChange.emit(this.value);\n }\n }\n\n /**\n * Resets the view of the picker.\n */\n @Method()\n async resetView(): Promise<void> {\n const [minDate, maxDate] = this.getMinMaxDate();\n const [dateStart] = this.getValue();\n this.viewDate = dateStart ?? clampDate(minDate, this.locale.now(), maxDate);\n }\n\n /**\n * Programmatically move focus to the inline datepicker, i,e, the first\n * focusable date.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n firstTabbable(this.hostElement.shadowRoot?.querySelector('.picker-grid-days'))?.focus(options);\n }\n\n render() {\n this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;\n const [minDate, maxDate] = this.getMinMaxDate();\n const dateGrid = this.dateGrid(this.viewDate.getFullYear(), this.viewDate.getMonth());\n const [dateStart, dateEnd] = this.getValue();\n return (\n <Host aria-label={this.label || undefined}>\n <div class={{ 'label-container': true, 'label-hidden': this.labelHidden }}>\n {(this.hasSlottedLabel || this.label) && (\n <label id={`${this.id}-label`} htmlFor={this.id} part=\"label\" onClick={() => this.doFocus()}>\n <span class=\"label-wrapper\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n <div class=\"label-metadata\">\n {!this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.optional')})\n </span>\n )}\n {this.required && this.requiredMarker?.startsWith('required') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.required')})\n </span>\n )}\n </div>\n </span>\n </label>\n )}\n </div>\n <div class={{ picker: true, 'picker-weeks': this.weeks }} id={this.id} aria-describedby={`${this.id}-label`}>\n <div class=\"picker-head\">\n <cat-button\n icon=\"$cat:datepicker-year-prev\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.prevYear}\n disabled={isSameYear(this.viewDate, minDate)}\n onClick={() => this.navigate('prev', 'year')}\n data-dropdown-no-close\n ></cat-button>\n <cat-button\n icon=\"$cat:datepicker-month-prev\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.prevMonth}\n disabled={isSameMonth(this.viewDate, minDate)}\n onClick={() => this.navigate('prev', 'month')}\n data-dropdown-no-close\n ></cat-button>\n <h3>{this.getHeadline()}</h3>\n <cat-button\n icon=\"$cat:datepicker-month-next\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.nextMonth}\n disabled={isSameMonth(this.viewDate, maxDate)}\n onClick={() => this.navigate('next', 'month')}\n data-dropdown-no-close\n ></cat-button>\n <cat-button\n icon=\"$cat:datepicker-year-next\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.nextYear}\n disabled={isSameYear(this.viewDate, maxDate)}\n onClick={() => this.navigate('next', 'year')}\n data-dropdown-no-close\n ></cat-button>\n </div>\n <div class=\"picker-grid\" onFocusin={() => this.setAriaLive(this.locale.arrowKeys)}>\n <div class=\"picker-grid-head\">\n {Array.from(Array(7), (_, i) => {\n const day = (i + this.locale.weekInfo.firstDay) % 7;\n return <abbr title={this.locale.days.long[day]}>{this.locale.days.short[day]}</abbr>;\n })}\n </div>\n {this.weeks && (\n <div class=\"picker-grid-weeks\">\n {dateGrid\n .filter((_, i) => i % 7 === 0)\n .map(day => (\n <div>{this.getWeekNumber(day)}</div>\n ))}\n </div>\n )}\n <div class=\"picker-grid-days\">\n {dateGrid.map(day => {\n const isStartDate = isSameDay(dateStart, day);\n const isEndDate = isSameDay(dateEnd, day);\n const isRange = !!dateStart && !!dateEnd && day > dateStart && day < dateEnd;\n const isToday = isSameDay(this.locale.now(), day);\n const isWeekend = this.locale.weekInfo.weekend.includes(day.getDay() || 7);\n return (\n <cat-button\n class={{\n 'cat-date-item': true,\n 'date-other': !isSameMonth(this.viewDate, day),\n 'date-today': isToday,\n 'date-weekend': isWeekend,\n 'date-start': this.range && isStartDate,\n 'date-range': this.range && isRange,\n 'date-end': this.range && isEndDate,\n 'date-focusable': this.canFocus(day),\n 'date-disabled': !this.canClick(day)\n }}\n nativeAttributes={!this.canFocus(day) ? { tabindex: '-1' } : {}}\n variant={isStartDate || isEndDate ? 'filled' : isToday ? 'outlined' : 'text'}\n a11yLabel={this.locale.toLocalStr(day)}\n active={isStartDate || isEndDate || isRange}\n color={isStartDate || isEndDate || isToday ? 'primary' : 'secondary'}\n disabled={!this.canClick(day)}\n onClick={() => this.select(day)}\n data-date={this.locale.toLocalISO(day)}\n >\n {day.getDate()}\n </cat-button>\n );\n })}\n </div>\n </div>\n <div class=\"picker-foot\">\n {!this.noToday && this.canClick(this.locale.now()) && (\n <cat-button size=\"s\" data-dropdown-no-close onClick={() => this.select(this.locale.now())}>\n {this.locale.today}\n </cat-button>\n )}\n {this.hint && <p class=\"cursor-help\">{this.locale.arrowKeys}</p>}\n {!this.noClear && (\n <cat-button size=\"s\" disabled={!this.value} data-dropdown-no-close onClick={() => this.clear()}>\n {this.locale.clear}\n </cat-button>\n )}\n </div>\n </div>\n <p class=\"cursor-aria\" aria-live=\"polite\"></p>\n </Host>\n );\n }\n\n private focus(date: Date, focus = true) {\n const [minDate, maxDate] = this.getMinMaxDate();\n const focusDate = clampDate(minDate, date, maxDate);\n this.viewDate = new Date(focusDate.getFullYear(), focusDate.getMonth());\n if (focus) {\n this.focusDate = focusDate;\n this.hostElement.shadowRoot\n ?.querySelector<HTMLCatButtonElement>(`[data-date=\"${this.locale.toLocalISO(focusDate)}\"]`)\n ?.doFocus();\n }\n }\n\n private navigate(direction: 'prev' | 'next', period: 'year' | 'month') {\n const offset = direction === 'prev' ? -1 : 1;\n const targetYear = this.viewDate.getFullYear() + (period === 'year' ? offset : 0);\n const targetMonth = this.viewDate.getMonth() + (period === 'month' ? offset : 0);\n\n const date = new Date(this.viewDate);\n date.setFullYear(targetYear);\n date.setMonth(targetMonth);\n\n const minDate = new Date(targetYear, targetMonth, 1);\n const maxDay = new Date(targetYear, targetMonth + 1, 0).getDate();\n const maxDate = new Date(targetYear, targetMonth, maxDay);\n this.viewDate = clampDate(minDate, date, maxDate);\n this.setAriaLive(this.getHeadline());\n }\n\n private setAriaLive(text?: string) {\n const node = this.hostElement.shadowRoot?.querySelector('.cursor-aria');\n if (node && text) {\n node.innerHTML = text;\n }\n }\n\n private dateGrid(year: number, month: number) {\n const daysOffset = (new Date(year, month, 1).getDay() - this.locale.weekInfo.firstDay + 7) % 7;\n const daysInMonth = new Date(year, month + 1, 0).getDate();\n const days = [...Array(daysInMonth).keys()];\n const daysBefore = this.getLastDaysOfMonth(year, month, daysOffset);\n const daysAfter = [...Array(42 - days.length - daysBefore.length).keys()];\n return [\n ...daysBefore.map(day => new Date(year, month - 1, day + 1)),\n ...days.map(day => new Date(year, month, day + 1)),\n ...daysAfter.map(day => new Date(year, month + 1, day + 1))\n ];\n }\n\n private getLastDaysOfMonth(year: number, month: number, x: number): number[] {\n const lastDayOfMonth = new Date(year, month, 0).getDate();\n const daysOfMonth = Array.from({ length: lastDayOfMonth }, (_, index) => index);\n return x ? daysOfMonth.slice(-x) : [];\n }\n\n private getHeadline() {\n return `${this.locale.months.long[this.viewDate.getMonth()]} ${this.viewDate.getFullYear()}`;\n }\n\n private getWeekNumber(date: Date, iso8601 = true) {\n const currentDate = new Date(date.getTime());\n const dayNum = iso8601 ? currentDate.getDay() || 7 : currentDate.getDay();\n currentDate.setDate(currentDate.getDate() + 4 - dayNum);\n const yearStart = new Date(currentDate.getFullYear(), 0, 1);\n return Math.ceil(((+currentDate - +yearStart) / 86400000 + 1) / 7);\n }\n\n private canFocus(date: Date): boolean {\n const now = this.locale.now();\n const [minDate] = this.getMinMaxDate();\n const focusedDate = this.focusedDate;\n const [startDate] = this.getValue();\n if (focusedDate && isSameMonth(focusedDate, this.viewDate)) {\n return isSameMonth(focusedDate, date) && isSameDay(focusedDate, date);\n } else if (startDate && isSameMonth(startDate, this.viewDate)) {\n return isSameMonth(startDate, date) && isSameDay(startDate, date);\n } else if (isSameMonth(this.viewDate, now) && (!minDate || minDate <= now)) {\n return isSameMonth(this.viewDate, date) && isSameDay(now, date);\n }\n const minDay = isSameMonth(date, minDate) ? (minDate?.getDate() ?? 1) : 1;\n return isSameMonth(this.viewDate, date) && date.getDate() === minDay;\n }\n\n private canClick(date: Date) {\n const [minDate, maxDate] = this.getMinMaxDate();\n return (!minDate || minDate <= date) && (!maxDate || maxDate >= date);\n }\n\n private getMinMaxDate() {\n const minDate = this.locale.fromLocalISO(this.min);\n const maxDate = this.locale.fromLocalISO(this.max);\n return [minDate, maxDate];\n }\n\n private getValue(): [Date | null, Date | null] {\n if (this.range) {\n const [startDate, endDate] = JSON.parse(this.value || '[]') as [string | null, string | null];\n return [this.locale.fromLocalISO(startDate), this.locale.fromLocalISO(endDate)];\n } else {\n return [this.locale.fromLocalISO(this.value), null];\n }\n }\n\n private toRangeValue(startDate: Date | null, endDate: Date | null): string {\n return JSON.stringify([startDate, endDate].map(date => (date ? this.locale.toLocalISO(date) : null)));\n }\n}\n"]}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { catI18nRegistry as i18n } from "../cat-i18n/cat-i18n-registry";
|
|
2
2
|
function getDays(language, weekday = 'long') {
|
|
3
|
-
const date = new Date();
|
|
4
|
-
const firstDayOfWeek = (date.getUTCDate() - date.getUTCDay() + 7) % 7;
|
|
5
3
|
const format = new Intl.DateTimeFormat(language, { weekday }).format;
|
|
6
|
-
return [...Array(7).keys()].map(day => format(new Date(
|
|
4
|
+
return [...Array(7).keys()].map(day => format(new Date(2000, 4, 14 + day)));
|
|
7
5
|
}
|
|
8
6
|
function getMonths(language, month = 'long') {
|
|
9
7
|
const format = new Intl.DateTimeFormat(language, { month }).format;
|
|
10
|
-
return [...Array(12).keys()].map(month => format(new Date(2000, month,
|
|
8
|
+
return [...Array(12).keys()].map(month => format(new Date(2000, month, 15)));
|
|
11
9
|
}
|
|
12
10
|
function getWeekInfo(language) {
|
|
13
11
|
const locale = new Intl.Locale(language);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-date-locale.js","sourceRoot":"","sources":["../../../src/components/cat-date-inline/cat-date-locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAExE,SAAS,OAAO,CAAC,QAAgB,EAAE,UAAuC,MAAM;IAC9E,MAAM,
|
|
1
|
+
{"version":3,"file":"cat-date-locale.js","sourceRoot":"","sources":["../../../src/components/cat-date-inline/cat-date-locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAExE,SAAS,OAAO,CAAC,QAAgB,EAAE,UAAuC,MAAM;IAC9E,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,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O,EAAE,MAAM;SAChB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;KAClB,CAAC;AACJ,CAAC","sourcesContent":["import { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\nfunction getDays(language: string, weekday: 'long' | 'short' | 'narrow' = 'long') {\n const format = new Intl.DateTimeFormat(language, { weekday }).format;\n return [...Array(7).keys()].map(day => format(new Date(2000, 4, 14 + day)));\n}\n\nfunction getMonths(language: string, month: 'long' | 'short' = 'long') {\n const format = new Intl.DateTimeFormat(language, { month }).format;\n return [...Array(12).keys()].map(month => format(new Date(2000, month, 15)));\n}\n\nfunction getWeekInfo(language: string) {\n const locale = new Intl.Locale(language);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const weekInfo = (locale as any).getWeekInfo?.() ?? (locale as any).weekInfo;\n return {\n firstDay: weekInfo?.firstDay ?? 1,\n minDays: weekInfo?.minDays ?? 4,\n weekend: weekInfo?.weekend ?? [6, 7]\n };\n}\n\nfunction getFormat(language: string) {\n const format = new Intl.DateTimeFormat(language, { year: 'numeric', month: '2-digit', day: '2-digit' })\n .format(new Date(3456, 10, 22))\n .replace('3456', 'YYYY')\n .replace('56', 'YY')\n .replace('11', 'MM')\n .replace('22', 'DD');\n return /^(YYYY|YY|MM|DD)\\W(YYYY|YY|MM|DD)\\W(YYYY|YY|MM|DD)$/.test(format) ? format : 'DD-MM-YYYY';\n}\n\nexport function getLocale(language: string) {\n return {\n prevYear: i18n.t('datepicker.prevYear'),\n nextYear: i18n.t('datepicker.nextYear'),\n prevMonth: i18n.t('datepicker.prevMonth'),\n nextMonth: i18n.t('datepicker.nextMonth'),\n arrowKeys: i18n.t('datepicker.arrowKeys'),\n today: i18n.t('datepicker.today'),\n change: i18n.t('datepicker.change'),\n choose: i18n.t('datepicker.choose'),\n clear: i18n.t('datepicker.clear'),\n formatStr: getFormat(language),\n weekInfo: getWeekInfo(language),\n days: {\n short: getDays(language, 'short'),\n long: getDays(language, 'long')\n },\n months: {\n short: getMonths(language, 'short'),\n long: getMonths(language, 'long')\n },\n now: () => {\n const date = new Date();\n return new Date(date.getFullYear(), date.getMonth(), date.getDate());\n },\n fromLocalISO: (date?: string | null) => {\n const [match, year, month, day] = date?.match(/^(\\d{4})-(\\d{2})-(\\d{2})/) ?? [];\n return match ? new Date(Number(year), Number(month) - 1, Number(day)) : null;\n },\n toLocalISO: (date: Date) => {\n const year = date.getFullYear();\n const month = (date.getMonth() + 1).toString().padStart(2, '0');\n const day = date.getDate().toString().padStart(2, '0');\n return `${year}-${month}-${day}`;\n },\n toLocalStr: (date: Date) =>\n new Intl.DateTimeFormat(language, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'long'\n }).format(date)\n };\n}\n"]}
|
|
@@ -12,7 +12,7 @@ export class CatDatepickerFlat {
|
|
|
12
12
|
this.hasSlottedHint = false;
|
|
13
13
|
this.requiredMarker = 'optional';
|
|
14
14
|
this.horizontal = false;
|
|
15
|
-
this.autoComplete =
|
|
15
|
+
this.autoComplete = 'off';
|
|
16
16
|
this.clearable = false;
|
|
17
17
|
this.disabled = false;
|
|
18
18
|
this.hint = undefined;
|
|
@@ -100,7 +100,7 @@ export class CatDatepickerFlat {
|
|
|
100
100
|
}
|
|
101
101
|
render() {
|
|
102
102
|
return [
|
|
103
|
-
h("cat-input", { key: '
|
|
103
|
+
h("cat-input", { key: '472e33835c2ac42e3e648d7b4b80551bfad276bb', ref: el => (this._input = el), requiredMarker: this.requiredMarker, horizontal: this.horizontal, autoComplete: this.autoComplete, clearable: this.clearable, disabled: this.disabled, hint: this.hint, icon: this.icon, iconRight: this.iconRight, identifier: this.identifier, label: this.label, labelHidden: this.labelHidden, name: this.name, placeholder: this.placeholder, textPrefix: this.textPrefix, textSuffix: this.textSuffix, readonly: this.readonly, required: this.required, value: this.value, errors: this.errors, errorUpdate: this.errorUpdate, nativeAttributes: this.nativeAttributes, onCatChange: e => {
|
|
104
104
|
e.stopPropagation();
|
|
105
105
|
this.value = e.detail || undefined;
|
|
106
106
|
}, onCatFocus: e => {
|
|
@@ -109,8 +109,8 @@ export class CatDatepickerFlat {
|
|
|
109
109
|
}, onCatBlur: e => {
|
|
110
110
|
e.stopPropagation();
|
|
111
111
|
this.catBlur.emit(e.detail);
|
|
112
|
-
} }, this.hasSlottedLabel && (h("span", { key: '
|
|
113
|
-
h("div", { key: '
|
|
112
|
+
} }, this.hasSlottedLabel && (h("span", { key: '9e883cc02c66b78e8be8221a5632f37b016df965', slot: "label" }, h("slot", { key: '892603e7cb7e645e92503a30f2eb89dc5b2be9bc', name: "label" }))), this.hasSlottedHint && (h("span", { key: 'b5f4e4fad0aca02ab0d9c1a94d4f5e7582634490', slot: "hint" }, h("slot", { key: '4d9184fd37321b6b7709a25a3cee17057b5cfcb7', name: "hint" })))),
|
|
113
|
+
h("div", { key: '8eccd0924e6dfcd2fdf2d71feba880ca84d44e87', ref: el => (this._calendarWrapper = el), class: "datepicker-wrapper" })
|
|
114
114
|
];
|
|
115
115
|
}
|
|
116
116
|
initDatepicker(input) {
|
|
@@ -218,17 +218,18 @@ export class CatDatepickerFlat {
|
|
|
218
218
|
"mutable": false,
|
|
219
219
|
"complexType": {
|
|
220
220
|
"original": "string",
|
|
221
|
-
"resolved": "string
|
|
221
|
+
"resolved": "string",
|
|
222
222
|
"references": {}
|
|
223
223
|
},
|
|
224
224
|
"required": false,
|
|
225
|
-
"optional":
|
|
225
|
+
"optional": false,
|
|
226
226
|
"docs": {
|
|
227
227
|
"tags": [],
|
|
228
228
|
"text": "Hint for form autofill feature."
|
|
229
229
|
},
|
|
230
230
|
"attribute": "auto-complete",
|
|
231
|
-
"reflect": false
|
|
231
|
+
"reflect": false,
|
|
232
|
+
"defaultValue": "'off'"
|
|
232
233
|
},
|
|
233
234
|
"clearable": {
|
|
234
235
|
"type": "boolean",
|
|
@@ -584,7 +585,7 @@ export class CatDatepickerFlat {
|
|
|
584
585
|
"Placement": {
|
|
585
586
|
"location": "import",
|
|
586
587
|
"path": "@floating-ui/dom",
|
|
587
|
-
"id": "../node_modules/.pnpm/@floating-ui+dom@1.6.
|
|
588
|
+
"id": "../node_modules/.pnpm/@floating-ui+dom@1.6.13/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.ts::Placement"
|
|
588
589
|
}
|
|
589
590
|
}
|
|
590
591
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-datepicker.js","sourceRoot":"","sources":["../../../src/components/cat-datepicker/cat-datepicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAA+B,MAAM,kBAAkB,CAAC;AAQlG,MAAM,OAAO,iBAAiB;;+BAUD,KAAK;8BAEN,KAAK;8BAKmE,UAAU;0BAKvF,KAAK;;yBAUN,KAAK;wBAKN,KAAK;;;yBAeJ,KAAK;;qBAUT,EAAE;2BAKI,KAAK;;;oBAeO,MAAM;;;;;wBAyBrB,KAAK;wBAKL,KAAK;oBAKT,CAAC;+BAKU,KAAK;;;;2BA8BS,CAAC;;;;IApJzC,IAAY,KAAK;QACf,OAAO,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC;IACtE,CAAC;IA8KD,cAAc,CAAC,KAAa;QAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, Method, Prop, State, Watch, h } from '@stencil/core';\nimport flatpickr from 'flatpickr';\nimport { findClosest } from '../../utils/find-closest';\nimport { ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { getConfig } from './cat-datepicker.config';\nimport { getFormat } from './cat-datepicker.format';\nimport { getLocale } from './cat-datepicker.locale';\nimport { CatDatepickerMode } from './cat-datepicker.mode';\nimport { autoUpdate, computePosition, flip, Placement, ReferenceElement } from '@floating-ui/dom';\nimport { BaseOptions } from 'flatpickr/dist/types/options';\n\n@Component({\n tag: 'cat-datepicker',\n styleUrl: 'cat-datepicker.scss',\n shadow: true\n})\nexport class CatDatepickerFlat {\n private pickr?: flatpickr.Instance;\n private _input?: HTMLCatInputElement;\n private _calendarWrapper?: HTMLDivElement;\n private get input(): HTMLInputElement | undefined {\n return this._input?.shadowRoot?.querySelector('input') ?? undefined;\n }\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker?: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() min?: string;\n\n /**\n * The mode of the datepicker, to select a date, time, both, a date range or a week number.\n */\n @Prop() mode: CatDatepickerMode = 'date';\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The step size to use when changing the time.\n */\n @Prop() step = 5;\n\n /**\n * Instead of body, appends the calendar to the cat-datepicker element instead\n */\n @Prop() attachToElement = false;\n\n /**\n * Where the calendar is rendered relative to the input vertically and horizontally.\n * In the format of \"[vertical] [horizontal]\". Vertical can be auto, above or below (required).\n * Horizontal can be left, center or right.\n * If @attachToElement is passed the value should be in Placement format\n */\n @Prop() position?: BaseOptions['position'] | Placement;\n\n /**\n * The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors change with the given delay in milliseconds or immediately on blur.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Attributes that will be added to the rendered HTML datepicker element.\n */\n @Prop() nativePickerAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n @Watch('value')\n onValueChanged(value: string) {\n if (value) {\n this.pickr?.setDate(value, false);\n if (this.mode !== 'daterange' || value.includes(' - ')) {\n this.catChange.emit(value);\n }\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n @Watch('readonly')\n @Watch('mode')\n onDisabledChanged() {\n // Dynamically changing config value is not working due to a bug in the\n // library. We thus need to fully recreate the date picker after the value\n // has been updated.\n this.pickr?.destroy();\n this.pickr = undefined;\n setTimeout(() => {\n this.input ? (this.input.disabled = this.disabled) : null;\n this.pickr = this.initDatepicker(this.input);\n });\n }\n\n componentDidLoad() {\n this.pickr = this.initDatepicker(this.input);\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n }\n\n @Watch('min')\n @Watch('max')\n onMinChanged() {\n this.pickr?.set('minDate', this.min);\n this.pickr?.set('maxDate', this.max);\n if (this.value && !this.pickr?.selectedDates?.length) {\n // Dynamically changing 'minDate' or 'maxDate' does not emit a change if\n // the value is cleared due to an invalid date.\n this.pickr?.clear();\n }\n }\n\n /**\n * Programmatically move focus to the datepicker. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this._input?.doFocus(options);\n }\n\n /**\n * Programmatically remove focus from the datepicker. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this._input?.doBlur();\n }\n\n render() {\n return [\n <cat-input\n ref={el => (this._input = el)}\n requiredMarker={this.requiredMarker}\n horizontal={this.horizontal}\n autoComplete={this.autoComplete}\n clearable={this.clearable}\n disabled={this.disabled}\n hint={this.hint}\n icon={this.icon}\n iconRight={this.iconRight}\n identifier={this.identifier}\n label={this.label}\n labelHidden={this.labelHidden}\n name={this.name}\n placeholder={this.placeholder}\n textPrefix={this.textPrefix}\n textSuffix={this.textSuffix}\n readonly={this.readonly}\n required={this.required}\n value={this.value}\n errors={this.errors}\n errorUpdate={this.errorUpdate}\n nativeAttributes={this.nativeAttributes}\n onCatChange={e => {\n e.stopPropagation();\n this.value = e.detail || undefined;\n }}\n onCatFocus={e => {\n e.stopPropagation();\n this.catFocus.emit(e.detail);\n }}\n onCatBlur={e => {\n e.stopPropagation();\n this.catBlur.emit(e.detail);\n }}\n >\n {this.hasSlottedLabel && (\n <span slot=\"label\">\n <slot name=\"label\"></slot>\n </span>\n )}\n {this.hasSlottedHint && (\n <span slot=\"hint\">\n <slot name=\"hint\"></slot>\n </span>\n )}\n </cat-input>,\n <div ref={el => (this._calendarWrapper = el)} class=\"datepicker-wrapper\"></div>\n ];\n }\n\n private initDatepicker(input?: HTMLInputElement): flatpickr.Instance | undefined {\n if (!input) {\n return;\n }\n\n // avoid dropdown closing if datepicker is part of a dropdown\n const withinDropdown = !!findClosest('cat-dropdown', input);\n const nativePickerAttributes: { [key: string]: string } = withinDropdown ? { 'data-dropdown-no-close': '' } : {};\n\n return flatpickr(\n input,\n getConfig({\n locale: getLocale(i18n.getLocale()),\n format: getFormat(i18n.getLocale(), this.mode),\n mode: this.mode,\n min: this.min,\n max: this.max,\n step: this.step,\n disabled: this.disabled,\n readonly: this.readonly,\n appendTo: this.attachToElement ? this._calendarWrapper : undefined,\n nativePickerAttributes: { ...nativePickerAttributes, ...this.nativePickerAttributes },\n // flatpickr has open bug about incorrect positioning when appendTo is used,\n // we have to use custom logic to calculate position\n // https://github.com/flatpickr/flatpickr/issues/1619\n position: this.attachToElement\n ? (flatpickr, positionElement) => {\n this.updatePosition(flatpickr, positionElement);\n }\n : (this.position as BaseOptions['position']) || undefined,\n onReady: (_dates, _dateStr, flatpickr) => {\n autoUpdate(input, flatpickr.calendarContainer, () => this.updatePosition(flatpickr, flatpickr._input));\n },\n applyChange: value => (this.value = value)\n })\n );\n }\n\n private updatePosition(flatpickr: flatpickr.Instance, positionElement: HTMLElement | undefined): void {\n if (positionElement) {\n computePosition(positionElement as ReferenceElement, flatpickr.calendarContainer, {\n strategy: 'fixed',\n placement: (this.position as Placement) || 'bottom-start',\n middleware: [flip()]\n }).then(({ x, y, placement }) => {\n if (flatpickr.calendarContainer) {\n flatpickr.calendarContainer.dataset.placement = placement;\n Object.assign(flatpickr.calendarContainer.style, {\n left: `${x}px`,\n top: `${y}px`,\n position: 'fixed'\n });\n }\n });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cat-datepicker.js","sourceRoot":"","sources":["../../../src/components/cat-datepicker/cat-datepicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CA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AAC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;oBAC1D,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE;wBAC/C,IAAI,EAAE,GAAG,CAAC,IAAI;wBACd,GAAG,EAAE,GAAG,CAAC,IAAI;wBACb,QAAQ,EAAE,OAAO;qBAClB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, Method, Prop, State, Watch, h } from '@stencil/core';\nimport flatpickr from 'flatpickr';\nimport { findClosest } from '../../utils/find-closest';\nimport { ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { getConfig } from './cat-datepicker.config';\nimport { getFormat } from './cat-datepicker.format';\nimport { getLocale } from './cat-datepicker.locale';\nimport { CatDatepickerMode } from './cat-datepicker.mode';\nimport { autoUpdate, computePosition, flip, Placement, ReferenceElement } from '@floating-ui/dom';\nimport { BaseOptions } from 'flatpickr/dist/types/options';\n\n@Component({\n tag: 'cat-datepicker',\n styleUrl: 'cat-datepicker.scss',\n shadow: true\n})\nexport class CatDatepickerFlat {\n private pickr?: flatpickr.Instance;\n private _input?: HTMLCatInputElement;\n private _calendarWrapper?: HTMLDivElement;\n private get input(): HTMLInputElement | undefined {\n return this._input?.shadowRoot?.querySelector('input') ?? undefined;\n }\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker?: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete = 'off';\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z.\n */\n @Prop() min?: string;\n\n /**\n * The mode of the datepicker, to select a date, time, both, a date range or a week number.\n */\n @Prop() mode: CatDatepickerMode = 'date';\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The step size to use when changing the time.\n */\n @Prop() step = 5;\n\n /**\n * Instead of body, appends the calendar to the cat-datepicker element instead\n */\n @Prop() attachToElement = false;\n\n /**\n * Where the calendar is rendered relative to the input vertically and horizontally.\n * In the format of \"[vertical] [horizontal]\". Vertical can be auto, above or below (required).\n * Horizontal can be left, center or right.\n * If @attachToElement is passed the value should be in Placement format\n */\n @Prop() position?: BaseOptions['position'] | Placement;\n\n /**\n * The value as ISO Date string, e.g. 2017-03-04T01:23:43.000Z or as a week number string.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors change with the given delay in milliseconds or immediately on blur.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Attributes that will be added to the rendered HTML datepicker element.\n */\n @Prop() nativePickerAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n @Watch('value')\n onValueChanged(value: string) {\n if (value) {\n this.pickr?.setDate(value, false);\n if (this.mode !== 'daterange' || value.includes(' - ')) {\n this.catChange.emit(value);\n }\n } else {\n this.pickr?.clear(false);\n this.catChange.emit(undefined);\n }\n }\n\n @Watch('disabled')\n @Watch('readonly')\n @Watch('mode')\n onDisabledChanged() {\n // Dynamically changing config value is not working due to a bug in the\n // library. We thus need to fully recreate the date picker after the value\n // has been updated.\n this.pickr?.destroy();\n this.pickr = undefined;\n setTimeout(() => {\n this.input ? (this.input.disabled = this.disabled) : null;\n this.pickr = this.initDatepicker(this.input);\n });\n }\n\n componentDidLoad() {\n this.pickr = this.initDatepicker(this.input);\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n }\n\n @Watch('min')\n @Watch('max')\n onMinChanged() {\n this.pickr?.set('minDate', this.min);\n this.pickr?.set('maxDate', this.max);\n if (this.value && !this.pickr?.selectedDates?.length) {\n // Dynamically changing 'minDate' or 'maxDate' does not emit a change if\n // the value is cleared due to an invalid date.\n this.pickr?.clear();\n }\n }\n\n /**\n * Programmatically move focus to the datepicker. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this._input?.doFocus(options);\n }\n\n /**\n * Programmatically remove focus from the datepicker. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this._input?.doBlur();\n }\n\n render() {\n return [\n <cat-input\n ref={el => (this._input = el)}\n requiredMarker={this.requiredMarker}\n horizontal={this.horizontal}\n autoComplete={this.autoComplete}\n clearable={this.clearable}\n disabled={this.disabled}\n hint={this.hint}\n icon={this.icon}\n iconRight={this.iconRight}\n identifier={this.identifier}\n label={this.label}\n labelHidden={this.labelHidden}\n name={this.name}\n placeholder={this.placeholder}\n textPrefix={this.textPrefix}\n textSuffix={this.textSuffix}\n readonly={this.readonly}\n required={this.required}\n value={this.value}\n errors={this.errors}\n errorUpdate={this.errorUpdate}\n nativeAttributes={this.nativeAttributes}\n onCatChange={e => {\n e.stopPropagation();\n this.value = e.detail || undefined;\n }}\n onCatFocus={e => {\n e.stopPropagation();\n this.catFocus.emit(e.detail);\n }}\n onCatBlur={e => {\n e.stopPropagation();\n this.catBlur.emit(e.detail);\n }}\n >\n {this.hasSlottedLabel && (\n <span slot=\"label\">\n <slot name=\"label\"></slot>\n </span>\n )}\n {this.hasSlottedHint && (\n <span slot=\"hint\">\n <slot name=\"hint\"></slot>\n </span>\n )}\n </cat-input>,\n <div ref={el => (this._calendarWrapper = el)} class=\"datepicker-wrapper\"></div>\n ];\n }\n\n private initDatepicker(input?: HTMLInputElement): flatpickr.Instance | undefined {\n if (!input) {\n return;\n }\n\n // avoid dropdown closing if datepicker is part of a dropdown\n const withinDropdown = !!findClosest('cat-dropdown', input);\n const nativePickerAttributes: { [key: string]: string } = withinDropdown ? { 'data-dropdown-no-close': '' } : {};\n\n return flatpickr(\n input,\n getConfig({\n locale: getLocale(i18n.getLocale()),\n format: getFormat(i18n.getLocale(), this.mode),\n mode: this.mode,\n min: this.min,\n max: this.max,\n step: this.step,\n disabled: this.disabled,\n readonly: this.readonly,\n appendTo: this.attachToElement ? this._calendarWrapper : undefined,\n nativePickerAttributes: { ...nativePickerAttributes, ...this.nativePickerAttributes },\n // flatpickr has open bug about incorrect positioning when appendTo is used,\n // we have to use custom logic to calculate position\n // https://github.com/flatpickr/flatpickr/issues/1619\n position: this.attachToElement\n ? (flatpickr, positionElement) => {\n this.updatePosition(flatpickr, positionElement);\n }\n : (this.position as BaseOptions['position']) || undefined,\n onReady: (_dates, _dateStr, flatpickr) => {\n autoUpdate(input, flatpickr.calendarContainer, () => this.updatePosition(flatpickr, flatpickr._input));\n },\n applyChange: value => (this.value = value)\n })\n );\n }\n\n private updatePosition(flatpickr: flatpickr.Instance, positionElement: HTMLElement | undefined): void {\n if (positionElement) {\n computePosition(positionElement as ReferenceElement, flatpickr.calendarContainer, {\n strategy: 'fixed',\n placement: (this.position as Placement) || 'bottom-start',\n middleware: [flip()]\n }).then(({ x, y, placement }) => {\n if (flatpickr.calendarContainer) {\n flatpickr.calendarContainer.dataset.placement = placement;\n Object.assign(flatpickr.calendarContainer.style, {\n left: `${x}px`,\n top: `${y}px`,\n position: 'fixed'\n });\n }\n });\n }\n }\n}\n"]}
|
|
@@ -219,7 +219,7 @@ export class CatDropdown {
|
|
|
219
219
|
"Placement": {
|
|
220
220
|
"location": "import",
|
|
221
221
|
"path": "@floating-ui/dom",
|
|
222
|
-
"id": "../node_modules/.pnpm/@floating-ui+dom@1.6.
|
|
222
|
+
"id": "../node_modules/.pnpm/@floating-ui+dom@1.6.13/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.ts::Placement"
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
},
|