@digital-realty/ix-date 1.2.13 → 1.3.1
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/IxDate.js +1 -1
- package/dist/IxDate.js.map +1 -1
- package/dist/ix-date.min.js +69 -1
- package/package.json +10 -16
package/dist/IxDate.js
CHANGED
package/dist/IxDate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxDate.js","sourceRoot":"","sources":["../src/IxDate.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAElD,MAAM,eAAe,GAAG,kBAAkB,CACxC,qBAAqB,CAAC,cAAc,CAAC,CACtC,CAAC;AAEF,MAAM,OAAO,MAAO,SAAQ,eAAe;IAA3C;;QAK8B,S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AAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;yCAAgB;AAExB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAkB;AAEjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAmB;AAG9D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC;kDACrC;AAqGI;IAA7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;yCAA2B;AAE/C;IAAR,KAAK,EAAE;uCAAyB","sourcesContent":["import { html, LitElement } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport '@digital-realty/ix-field/ix-field.js';\nimport { mixinDelegatesAria } from '@material/web/internal/aria/delegate.js';\nimport { mixinElementInternals } from '@material/web/labs/behaviors/element-internals.js';\nimport { format } from 'date-fns/format.js';\nimport { isValid } from 'date-fns/isValid.js';\nimport { parse } from 'date-fns/parse.js';\nimport { parseISO } from 'date-fns/parseISO.js';\nimport { MobxLitElement } from '@adobe/lit-mobx';\nimport {\n dateFormatState,\n defaultDateFormat,\n defaultTimeFormat,\n} from './state/date-format-state.js';\nimport { IxDateStyles } from './ix-date-styles.js';\n\nexport const NativeInputDateFormat = 'yyyy-MM-dd';\n\nconst ixDateBaseClass = mixinDelegatesAria(\n mixinElementInternals(MobxLitElement)\n);\n\nexport class IxDate extends ixDateBaseClass {\n static get styles() {\n return [IxDateStyles];\n }\n\n @property({ type: String }) type: 'default' | 'static' = 'default';\n\n @property({ type: String }) variant: 'date' | 'time' | 'date-time' = 'date';\n\n @property({ type: String }) format = defaultDateFormat;\n\n @property({ type: String }) timeFormat = defaultTimeFormat;\n\n @property({ type: String }) timezone = 'UTC';\n\n @property({ type: String }) label = '';\n\n @property({ type: String }) dateTimeText = '';\n\n /**\n * For `type='default'`, should be any value that is accepted by [new Date()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date).\n *\n * For `type='static'`, should be a date string that can be parsed by [parseISO](https://date-fns.org/v2.0.0/docs/parseISO), e.g.\n * - `2025-01-01`\n * - `2025-01-01 12:30Z`\n * - `2025-01-01T12:30:00.000+02:00`\n * */\n @property({ type: String }) value = '';\n\n @property({ type: Boolean }) showCalendarOnMouseDown = false;\n\n @property({ type: String }) min = '';\n\n @property({ type: String }) max = '9999-12-31';\n\n /**\n * Applies when type=static. Defaults to `false`.\n *\n * If `true`, the value is formatted but no time zone conversions are applied.\n *\n * If `false`, values that do not specify a time zone are interpreted as being in the\n * user's local time zone and all values are displayed in the user's local time zone.\n */\n @property({ type: Boolean, attribute: 'no-time-zone-conversion' })\n noTimeZoneConversion = false;\n\n // Form association\n\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** @nocollapse */\n static readonly formAssociated = true;\n\n private readonly internals = (this as HTMLElement) /* needed for closure */\n .attachInternals();\n\n @query('#date-input') dateInput!: HTMLInputElement;\n\n @query('vaadin-date-picker') datePicker!: any;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * Gets or sets whether or not the text field is in a visually invalid state.\n *\n * This error state overrides the error state controlled by\n * `reportValidity()`.\n */\n get error() {\n return !!this.errorText;\n }\n\n @property({ type: String, attribute: 'error-text' }) errorText = '';\n\n @property({ type: Boolean, reflect: true }) required = false;\n\n @property({ type: Boolean, reflect: true }) hideError = false;\n\n @property({ type: Boolean, attribute: 'clear-button-visible' })\n clearButtonVisible = true;\n\n /**\n * The associated form element with which this element's value will submit.\n */\n get form() {\n return this.internals.form;\n }\n\n /**\n * The labels this element is associated with.\n */\n get labels() {\n return this.internals.labels;\n }\n\n /**\n * The HTML name to use in form submission.\n */\n get name() {\n return this.getAttribute('name') ?? '';\n }\n\n set name(name: string) {\n this.setAttribute('name', name);\n }\n\n /**\n * Returns the text field's validation error message.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation\n */\n get validationMessage() {\n return this.internals.validationMessage;\n }\n\n /**\n * Returns a `ValidityState` object that represents the validity states of the\n * text field.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ValidityState\n */\n get validity() {\n return this.internals.validity;\n }\n\n /**\n * Returns whether an element will successfully validate based on forms\n * validation rules and constraints.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate\n */\n get willValidate() {\n return this.internals.willValidate;\n }\n\n checkValidity() {\n return this.internals.checkValidity();\n }\n\n reportValidity() {\n return this.internals.reportValidity();\n }\n\n /** @private */\n formResetCallback() {\n this.reset();\n }\n\n /**\n * Reset the text field to its default value.\n */\n reset() {\n this.clear();\n this.value = this.getAttribute('value') ?? '';\n }\n\n protected override updated(\n changedProperties: Map<string | number | symbol, unknown>\n ) {\n if (changedProperties.has('value')) {\n const inputVal = this.dateInput ? this.dateInput : this.datePicker;\n if (inputVal) {\n this.internals.setValidity(\n {\n badInput: this.error,\n },\n this.error ? this.errorText : '',\n inputVal\n );\n }\n }\n\n this.internals.setFormValue(this.value);\n }\n\n override focus() {\n this.dateInput.focus();\n }\n\n // eslint-disable-next-line class-methods-use-this\n @property({ type: Function }) onChanged: any = () => {};\n\n @state() private focused = false;\n\n connectedCallback(): void {\n super.connectedCallback();\n document.addEventListener(\n 'dateFormatChanged',\n this.handleDateFormatChanged\n );\n\n if (!this.hasAttribute('format')) {\n this.format = dateFormatState.preferredDateFormat;\n }\n if (!this.hasAttribute('timeFormat')) {\n this.timeFormat = dateFormatState.preferredTimeFormat;\n }\n if (!this.hasAttribute('timezone')) {\n this.timezone = dateFormatState.preferredTimezone;\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\n 'dateFormatChanged',\n this.handleDateFormatChanged\n );\n }\n\n handleDateFormatChanged = async () => {\n await dateFormatState.hydrateStore();\n\n this.format = dateFormatState.preferredDateFormat;\n this.timeFormat = dateFormatState.preferredTimeFormat;\n this.timezone = dateFormatState.preferredTimezone;\n };\n\n firstUpdated() {\n const minDate = new Date(this.min);\n const maxDate = new Date(this.max);\n\n if (minDate && !Number.isNaN(minDate.valueOf())) {\n const [min] = minDate.toISOString().split('T');\n this.min = min;\n }\n\n if (maxDate && !Number.isNaN(maxDate.valueOf())) {\n const [max] = maxDate.toISOString().split('T');\n this.max = max;\n }\n\n this.validateDate();\n\n if (this.datePicker) {\n const formatDateIso8601 = (dateParts: any): string => {\n const { year, month, day } = dateParts;\n const date = new Date(year, month, day);\n\n return format(date, this.format);\n };\n\n const parseDateIso8601 = (inputValue: string) => {\n const date = parse(inputValue, this.format, new Date());\n\n return {\n year: date.getFullYear(),\n month: date.getMonth(),\n day: date.getDate(),\n };\n };\n\n this.datePicker.i18n = {\n ...this.datePicker.i18n,\n formatDate: formatDateIso8601,\n parseDate: parseDateIso8601,\n };\n }\n }\n\n handleMouseDown = (e: Event) => {\n if (this.showCalendarOnMouseDown) {\n const inputElement = e.target as HTMLInputElement;\n\n if ('showPicker' in inputElement) {\n inputElement.showPicker();\n }\n }\n };\n\n focusin = () => {\n this.focused = true;\n };\n\n clear = () => {\n this.value = '';\n };\n\n handleChange = (e: InputEvent) => {\n const { value } = e.target as HTMLInputElement;\n this.value = value;\n this.validateDate();\n this.onChanged(value);\n };\n\n validateDate = () => {\n if (this.value) {\n const date = new Date(this.value);\n\n if (!date || Number.isNaN(date.valueOf())) {\n this.errorText = 'Invalid date format.';\n }\n }\n };\n\n focusOut = () => {\n this.focused = false;\n };\n\n parseValue = () => {\n if (typeof this.value !== 'string') {\n return this.value;\n }\n\n if (this.noTimeZoneConversion) {\n // Matches the time zone designator, e.g. `Z` or `-02:00`.\n // Note: does not match `-02` and `-0200`, which are valid ISO 8601 but rarely used.\n const timeZoneRegex = /Z|([+-]\\d\\d:\\d\\d)/;\n const valueWithoutTimeZone = this.value.split(timeZoneRegex)[0];\n return parseISO(valueWithoutTimeZone);\n }\n\n return parseISO(this.value);\n };\n\n getTimezoneDateTime = (date: Date) => {\n const parts = new Intl.DateTimeFormat('en-GB', {\n timeZone: this.timezone,\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: false,\n }).formatToParts(new Date(date));\n\n const get = (type: string) => parts.find(p => p.type === type)?.value;\n\n const year = get('year');\n const month = get('month');\n const day = get('day');\n const hour = get('hour');\n const minute = get('minute');\n const second = get('second');\n\n return new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}`);\n };\n\n formatValueAsDate = (date: Date) =>\n format(date, this.format || defaultDateFormat);\n\n formatValueAsTime = (date: Date) =>\n format(date, this.timeFormat || defaultTimeFormat);\n\n formatValueAsDateTime = (date: Date) =>\n `${this.formatValueAsDate(date)}${\n this.dateTimeText ? ` ${this.dateTimeText} ` : ' '\n }${this.formatValueAsTime(date)}`;\n\n formatValue = () => {\n const parsedDate = this.parseValue();\n\n if (!isValid(parsedDate)) return '';\n\n const adjustedDate = this.noTimeZoneConversion\n ? parsedDate\n : this.getTimezoneDateTime(parsedDate);\n\n switch (this.variant) {\n case 'date':\n return this.formatValueAsDate(adjustedDate);\n case 'time':\n return this.formatValueAsTime(adjustedDate);\n case 'date-time':\n return this.formatValueAsDateTime(adjustedDate);\n default:\n return '';\n }\n };\n\n get nativeInputValue() {\n try {\n return new Date(this.value).toISOString().split('T')[0];\n } catch (error) {\n return this.value;\n }\n }\n\n renderStaticDate() {\n return html`<span>${this.formatValue()}</span>`;\n }\n\n renderDateInput() {\n const classes = {\n disabled: this.disabled,\n error: !this.disabled && this.error,\n };\n\n return html` <ix-field\n class=\"${classMap(classes)}\"\n ?focused=${this.focused}\n ?populated=${this.value}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?error=${this.error && !this.hideError}\n error-text=${this.errorText}\n label=${this.label}\n @focusin=${this.focusin}\n @focusout=${this.focusOut}\n >\n ${html`<input\n id=\"date-input\"\n @change=${this.handleChange}\n @mousedown=${this.handleMouseDown}\n .value=${this.nativeInputValue}\n class=\"flex-fill\"\n type=\"date\"\n min=${this.min}\n max=${this.max}\n ?disabled=${this.disabled}\n />`}\n </ix-field>`;\n }\n\n render() {\n return this.type === 'static'\n ? this.renderStaticDate()\n : this.renderDateInput();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IxDate.js","sourceRoot":"","sources":["../src/IxDate.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAElD,MAAM,eAAe,GAAG,kBAAkB,CACxC,qBAAqB,CAAC,cAAc,CAAC,CACtC,CAAC;AAEF,MAAM,OAAO,MAAO,SAAQ,eAAe;IAA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QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;yCAAgB;AAExB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAkB;AAEjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAmB;AAG9D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC;kDACrC;AAqGI;IAA7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;yCAA2B;AAE/C;IAAR,KAAK,EAAE;uCAAyB","sourcesContent":["import { html, LitElement } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport '@digital-realty/ix-field/ix-field.js';\nimport { mixinDelegatesAria } from '@material/web/internal/aria/delegate.js';\nimport { mixinElementInternals } from '@material/web/labs/behaviors/element-internals.js';\nimport { format } from 'date-fns/format.js';\nimport { isValid } from 'date-fns/isValid.js';\nimport { parse } from 'date-fns/parse.js';\nimport { parseISO } from 'date-fns/parseISO.js';\nimport { MobxLitElement } from '@adobe/lit-mobx';\nimport {\n dateFormatState,\n defaultDateFormat,\n defaultTimeFormat,\n} from './state/date-format-state.js';\nimport { IxDateStyles } from './ix-date-styles.js';\n\nexport const NativeInputDateFormat = 'yyyy-MM-dd';\n\nconst ixDateBaseClass = mixinDelegatesAria(\n mixinElementInternals(MobxLitElement)\n);\n\nexport class IxDate extends ixDateBaseClass {\n static get styles() {\n return [IxDateStyles];\n }\n\n @property({ type: String }) type: 'default' | 'static' = 'default';\n\n @property({ type: String }) variant: 'date' | 'time' | 'date-time' = 'date';\n\n @property({ type: String }) format = defaultDateFormat;\n\n @property({ type: String }) timeFormat = defaultTimeFormat;\n\n @property({ type: String }) timezone = 'UTC';\n\n @property({ type: String }) label = '';\n\n @property({ type: String }) dateTimeText = '';\n\n /**\n * For `type='default'`, should be any value that is accepted by [new Date()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date).\n *\n * For `type='static'`, should be a date string that can be parsed by [parseISO](https://date-fns.org/v2.0.0/docs/parseISO), e.g.\n * - `2025-01-01`\n * - `2025-01-01 12:30Z`\n * - `2025-01-01T12:30:00.000+02:00`\n * */\n @property({ type: String }) value = '';\n\n @property({ type: Boolean }) showCalendarOnMouseDown = false;\n\n @property({ type: String }) min = '';\n\n @property({ type: String }) max = '9999-12-31';\n\n /**\n * Applies when type=static. Defaults to `false`.\n *\n * If `true`, the value is formatted but no time zone conversions are applied.\n *\n * If `false`, values that do not specify a time zone are interpreted as being in the\n * user's local time zone and all values are displayed in the user's local time zone.\n */\n @property({ type: Boolean, attribute: 'no-time-zone-conversion' })\n noTimeZoneConversion = false;\n\n // Form association\n\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** @nocollapse */\n static readonly formAssociated = true;\n\n private readonly internals = (this as HTMLElement) /* needed for closure */\n .attachInternals();\n\n @query('#date-input') dateInput!: HTMLInputElement;\n\n @query('vaadin-date-picker') datePicker!: any;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * Gets or sets whether or not the text field is in a visually invalid state.\n *\n * This error state overrides the error state controlled by\n * `reportValidity()`.\n */\n get error() {\n return !!this.errorText;\n }\n\n @property({ type: String, attribute: 'error-text' }) errorText = '';\n\n @property({ type: Boolean, reflect: true }) required = false;\n\n @property({ type: Boolean, reflect: true }) hideError = false;\n\n @property({ type: Boolean, attribute: 'clear-button-visible' })\n clearButtonVisible = true;\n\n /**\n * The associated form element with which this element's value will submit.\n */\n get form() {\n return this.internals.form;\n }\n\n /**\n * The labels this element is associated with.\n */\n get labels() {\n return this.internals.labels;\n }\n\n /**\n * The HTML name to use in form submission.\n */\n get name() {\n return this.getAttribute('name') ?? '';\n }\n\n set name(name: string) {\n this.setAttribute('name', name);\n }\n\n /**\n * Returns the text field's validation error message.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation\n */\n get validationMessage() {\n return this.internals.validationMessage;\n }\n\n /**\n * Returns a `ValidityState` object that represents the validity states of the\n * text field.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ValidityState\n */\n get validity() {\n return this.internals.validity;\n }\n\n /**\n * Returns whether an element will successfully validate based on forms\n * validation rules and constraints.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate\n */\n get willValidate() {\n return this.internals.willValidate;\n }\n\n checkValidity() {\n return this.internals.checkValidity();\n }\n\n reportValidity() {\n return this.internals.reportValidity();\n }\n\n /** @private */\n formResetCallback() {\n this.reset();\n }\n\n /**\n * Reset the text field to its default value.\n */\n reset() {\n this.clear();\n this.value = this.getAttribute('value') ?? '';\n }\n\n protected override updated(\n changedProperties: Map<string | number | symbol, unknown>\n ) {\n if (changedProperties.has('value')) {\n const inputVal = this.dateInput ? this.dateInput : this.datePicker;\n if (inputVal) {\n this.internals.setValidity(\n {\n badInput: this.error,\n },\n this.error ? this.errorText : '',\n inputVal\n );\n }\n }\n\n this.internals.setFormValue(this.value);\n }\n\n override focus() {\n this.dateInput.focus();\n }\n\n // eslint-disable-next-line class-methods-use-this\n @property({ type: Function }) onChanged: any = () => {};\n\n @state() private focused = false;\n\n connectedCallback(): void {\n super.connectedCallback();\n document.addEventListener(\n 'dateFormatChanged',\n this.handleDateFormatChanged\n );\n\n if (!this.hasAttribute('format')) {\n this.format = dateFormatState.preferredDateFormat;\n }\n if (!this.hasAttribute('timeFormat')) {\n this.timeFormat = dateFormatState.preferredTimeFormat;\n }\n if (!this.hasAttribute('timezone')) {\n this.timezone = dateFormatState.preferredTimezone;\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\n 'dateFormatChanged',\n this.handleDateFormatChanged\n );\n }\n\n handleDateFormatChanged = async () => {\n await dateFormatState.hydrateStore();\n\n this.format = dateFormatState.preferredDateFormat;\n this.timeFormat = dateFormatState.preferredTimeFormat;\n this.timezone = dateFormatState.preferredTimezone;\n };\n\n firstUpdated() {\n const minDate = new Date(this.min);\n const maxDate = new Date(this.max);\n\n if (minDate && !Number.isNaN(minDate.valueOf())) {\n const [min] = minDate.toISOString().split('T');\n this.min = min;\n }\n\n if (maxDate && !Number.isNaN(maxDate.valueOf())) {\n const [max] = maxDate.toISOString().split('T');\n this.max = max;\n }\n\n this.validateDate();\n\n if (this.datePicker) {\n const formatDateIso8601 = (dateParts: any): string => {\n const { year, month, day } = dateParts;\n const date = new Date(year, month, day);\n\n return format(date, this.format);\n };\n\n const parseDateIso8601 = (inputValue: string) => {\n const date = parse(inputValue, this.format, new Date());\n\n return {\n year: date.getFullYear(),\n month: date.getMonth(),\n day: date.getDate(),\n };\n };\n\n this.datePicker.i18n = {\n ...this.datePicker.i18n,\n formatDate: formatDateIso8601,\n parseDate: parseDateIso8601,\n };\n }\n }\n\n handleMouseDown = (e: Event) => {\n if (this.showCalendarOnMouseDown) {\n const inputElement = e.target as HTMLInputElement;\n\n if ('showPicker' in inputElement) {\n inputElement.showPicker();\n }\n }\n };\n\n focusin = () => {\n this.focused = true;\n };\n\n clear = () => {\n this.value = '';\n };\n\n handleChange = (e: InputEvent) => {\n const { value } = e.target as HTMLInputElement;\n this.value = value;\n this.validateDate();\n this.onChanged(value);\n };\n\n validateDate = () => {\n if (this.value) {\n const date = new Date(this.value);\n\n if (!date || Number.isNaN(date.valueOf())) {\n this.errorText = 'Invalid date format.';\n }\n }\n };\n\n focusOut = () => {\n this.focused = false;\n };\n\n parseValue = () => {\n if (typeof this.value !== 'string') {\n return this.value;\n }\n\n if (this.noTimeZoneConversion) {\n // Matches the time zone designator, e.g. `Z` or `-02:00`.\n // Note: does not match `-02` and `-0200`, which are valid ISO 8601 but rarely used.\n const timeZoneRegex = /Z|([+-]\\d\\d:\\d\\d)/;\n const valueWithoutTimeZone = this.value.split(timeZoneRegex)[0];\n return parseISO(valueWithoutTimeZone);\n }\n\n return parseISO(this.value);\n };\n\n getTimezoneDateTime = (date: Date) => {\n const parts = new Intl.DateTimeFormat('en-GB', {\n timeZone: this.timezone,\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: false,\n }).formatToParts(new Date(date));\n\n const get = (type: string) => parts.find(p => p.type === type)?.value;\n\n const year = get('year');\n const month = get('month');\n const day = get('day');\n const hour = get('hour');\n const minute = get('minute');\n const second = get('second');\n\n return new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}`);\n };\n\n formatValueAsDate = (date: Date) =>\n format(date, this.format || defaultDateFormat);\n\n formatValueAsTime = (date: Date) =>\n format(date, this.timeFormat || defaultTimeFormat);\n\n formatValueAsDateTime = (date: Date) =>\n `${this.formatValueAsDate(date)}${\n this.dateTimeText ? ` ${this.dateTimeText} ` : ' '\n }${this.formatValueAsTime(date)}`;\n\n formatValue = () => {\n const parsedDate = this.parseValue();\n\n if (!isValid(parsedDate)) return '';\n\n const adjustedDate = this.noTimeZoneConversion\n ? parsedDate\n : this.getTimezoneDateTime(parsedDate);\n\n switch (this.variant) {\n case 'date':\n return this.formatValueAsDate(adjustedDate);\n case 'time':\n return this.formatValueAsTime(adjustedDate);\n case 'date-time':\n return this.formatValueAsDateTime(adjustedDate);\n default:\n return '';\n }\n };\n\n get nativeInputValue() {\n try {\n return new Date(this.value).toISOString().split('T')[0];\n } catch {\n return this.value;\n }\n }\n\n renderStaticDate() {\n return html`<span>${this.formatValue()}</span>`;\n }\n\n renderDateInput() {\n const classes = {\n disabled: this.disabled,\n error: !this.disabled && this.error,\n };\n\n return html` <ix-field\n class=\"${classMap(classes)}\"\n ?focused=${this.focused}\n ?populated=${this.value}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?error=${this.error && !this.hideError}\n error-text=${this.errorText}\n label=${this.label}\n @focusin=${this.focusin}\n @focusout=${this.focusOut}\n >\n ${html`<input\n id=\"date-input\"\n @change=${this.handleChange}\n @mousedown=${this.handleMouseDown}\n .value=${this.nativeInputValue}\n class=\"flex-fill\"\n type=\"date\"\n min=${this.min}\n max=${this.max}\n ?disabled=${this.disabled}\n />`}\n </ix-field>`;\n }\n\n render() {\n return this.type === 'static'\n ? this.renderStaticDate()\n : this.renderDateInput();\n }\n}\n"]}
|
package/dist/ix-date.min.js
CHANGED
|
@@ -1 +1,69 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{css,LitElement,html}from"lit";import{property,query,state}from"lit/decorators.js";import{classMap}from"lit/directives/class-map.js";import"@digital-realty/ix-field/ix-field.js";import{mixinDelegatesAria}from"@material/web/internal/aria/delegate.js";import{mixinElementInternals}from"@material/web/labs/behaviors/element-internals.js";import{format}from"date-fns/format.js";import{isValid}from"date-fns/isValid.js";import{parse}from"date-fns/parse.js";import{parseISO}from"date-fns/parseISO.js";import{MobxLitElement}from"@adobe/lit-mobx";import{makeAutoObservable}from"mobx";import{makePersistable,isHydrated,hydrateStore,clearPersistedStore,getPersistedStore}from"mobx-persist-store";
|
|
1
|
+
import{__decorate as t}from"tslib";import{css as e,LitElement as i,html as r}from"lit";import{property as a,query as o,state as s}from"lit/decorators.js";import{classMap as n}from"lit/directives/class-map.js";import"@digital-realty/ix-field/ix-field.js";import{mixinDelegatesAria as d}from"@material/web/internal/aria/delegate.js";import{mixinElementInternals as h}from"@material/web/labs/behaviors/element-internals.js";import{format as l}from"date-fns/format.js";import{isValid as m}from"date-fns/isValid.js";import{parse as u}from"date-fns/parse.js";import{parseISO as p}from"date-fns/parseISO.js";import{MobxLitElement as c}from"@adobe/lit-mobx";import{makeAutoObservable as f}from"mobx";import{makePersistable as v,isHydrated as y,hydrateStore as g,clearPersistedStore as b,getPersistedStore as T}from"mobx-persist-store";const D="dd/MM/yyyy",w="HH:mm";const x=new class{constructor(){this.preferredDateFormat=D,this.preferredTimeFormat=w,this.preferredTimezone="UTC",f(this),v(this,{name:"date-format",properties:["preferredDateFormat","preferredTimeFormat","preferredTimezone"],storage:window.localStorage})}get isHydrated(){return y(this)}async hydrateStore(){await g(this)}async clearStoredDate(){await b(this)}async getStoredData(){return T(this)}},$=e`
|
|
2
|
+
:host {
|
|
3
|
+
display: block;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
::part(input-field) {
|
|
7
|
+
background: transparent;
|
|
8
|
+
padding: 0;
|
|
9
|
+
height: 26px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
#search-input-vaadin-date-picker-3 {
|
|
13
|
+
padding: 0 !important;
|
|
14
|
+
--_hover-highlight: transparent;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
ix-field {
|
|
18
|
+
display: block;
|
|
19
|
+
position: relative;
|
|
20
|
+
--vaadin-field-default-width: auto;
|
|
21
|
+
|
|
22
|
+
input {
|
|
23
|
+
-webkit-text-fill-color: var(--_content-color);
|
|
24
|
+
height: var(--ix-line-height);
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
input::-webkit-calendar-picker-indicator {
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
ix-field.error {
|
|
34
|
+
input {
|
|
35
|
+
-webkit-text-fill-color: var(--_error-content-color);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
.flex-fill {
|
|
39
|
+
flex: 1;
|
|
40
|
+
align-items: center;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
vaadin-date-picker::before {
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
`,S=d(h(c));class V extends S{constructor(){super(...arguments),this.type="default",this.variant="date",this.format=D,this.timeFormat=w,this.timezone="UTC",this.label="",this.dateTimeText="",this.value="",this.showCalendarOnMouseDown=!1,this.min="",this.max="9999-12-31",this.noTimeZoneConversion=!1,this.internals=this.attachInternals(),this.disabled=!1,this.errorText="",this.required=!1,this.hideError=!1,this.clearButtonVisible=!0,this.onChanged=()=>{},this.focused=!1,this.handleDateFormatChanged=async()=>{await x.hydrateStore(),this.format=x.preferredDateFormat,this.timeFormat=x.preferredTimeFormat,this.timezone=x.preferredTimezone},this.handleMouseDown=t=>{if(this.showCalendarOnMouseDown){const e=t.target;"showPicker"in e&&e.showPicker()}},this.focusin=()=>{this.focused=!0},this.clear=()=>{this.value=""},this.handleChange=t=>{const{value:e}=t.target;this.value=e,this.validateDate(),this.onChanged(e)},this.validateDate=()=>{if(this.value){const t=new Date(this.value);t&&!Number.isNaN(t.valueOf())||(this.errorText="Invalid date format.")}},this.focusOut=()=>{this.focused=!1},this.parseValue=()=>{if("string"!=typeof this.value)return this.value;if(this.noTimeZoneConversion){const t=/Z|([+-]\d\d:\d\d)/,e=this.value.split(t)[0];return p(e)}return p(this.value)},this.getTimezoneDateTime=t=>{const e=new Intl.DateTimeFormat("en-GB",{timeZone:this.timezone,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(new Date(t)),i=t=>{var i;return null===(i=e.find(e=>e.type===t))||void 0===i?void 0:i.value},r=i("year"),a=i("month"),o=i("day"),s=i("hour"),n=i("minute"),d=i("second");return new Date(`${r}-${a}-${o}T${s}:${n}:${d}`)},this.formatValueAsDate=t=>l(t,this.format||D),this.formatValueAsTime=t=>l(t,this.timeFormat||w),this.formatValueAsDateTime=t=>`${this.formatValueAsDate(t)}${this.dateTimeText?` ${this.dateTimeText} `:" "}${this.formatValueAsTime(t)}`,this.formatValue=()=>{const t=this.parseValue();if(!m(t))return"";const e=this.noTimeZoneConversion?t:this.getTimezoneDateTime(t);switch(this.variant){case"date":return this.formatValueAsDate(e);case"time":return this.formatValueAsTime(e);case"date-time":return this.formatValueAsDateTime(e);default:return""}}}static get styles(){return[$]}get error(){return!!this.errorText}get form(){return this.internals.form}get labels(){return this.internals.labels}get name(){var t;return null!==(t=this.getAttribute("name"))&&void 0!==t?t:""}set name(t){this.setAttribute("name",t)}get validationMessage(){return this.internals.validationMessage}get validity(){return this.internals.validity}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}formResetCallback(){this.reset()}reset(){var t;this.clear(),this.value=null!==(t=this.getAttribute("value"))&&void 0!==t?t:""}updated(t){if(t.has("value")){const t=this.dateInput?this.dateInput:this.datePicker;t&&this.internals.setValidity({badInput:this.error},this.error?this.errorText:"",t)}this.internals.setFormValue(this.value)}focus(){this.dateInput.focus()}connectedCallback(){super.connectedCallback(),document.addEventListener("dateFormatChanged",this.handleDateFormatChanged),this.hasAttribute("format")||(this.format=x.preferredDateFormat),this.hasAttribute("timeFormat")||(this.timeFormat=x.preferredTimeFormat),this.hasAttribute("timezone")||(this.timezone=x.preferredTimezone)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dateFormatChanged",this.handleDateFormatChanged)}firstUpdated(){const t=new Date(this.min),e=new Date(this.max);if(t&&!Number.isNaN(t.valueOf())){const[e]=t.toISOString().split("T");this.min=e}if(e&&!Number.isNaN(e.valueOf())){const[t]=e.toISOString().split("T");this.max=t}if(this.validateDate(),this.datePicker){const t=t=>{const{year:e,month:i,day:r}=t,a=new Date(e,i,r);return l(a,this.format)},e=t=>{const e=u(t,this.format,new Date);return{year:e.getFullYear(),month:e.getMonth(),day:e.getDate()}};this.datePicker.i18n={...this.datePicker.i18n,formatDate:t,parseDate:e}}}get nativeInputValue(){try{return new Date(this.value).toISOString().split("T")[0]}catch(t){return this.value}}renderStaticDate(){return r`<span>${this.formatValue()}</span>`}renderDateInput(){const t={disabled:this.disabled,error:!this.disabled&&this.error};return r` <ix-field
|
|
47
|
+
class="${n(t)}"
|
|
48
|
+
?focused=${this.focused}
|
|
49
|
+
?populated=${this.value}
|
|
50
|
+
?disabled=${this.disabled}
|
|
51
|
+
?required=${this.required}
|
|
52
|
+
?error=${this.error&&!this.hideError}
|
|
53
|
+
error-text=${this.errorText}
|
|
54
|
+
label=${this.label}
|
|
55
|
+
@focusin=${this.focusin}
|
|
56
|
+
@focusout=${this.focusOut}
|
|
57
|
+
>
|
|
58
|
+
${r`<input
|
|
59
|
+
id="date-input"
|
|
60
|
+
@change=${this.handleChange}
|
|
61
|
+
@mousedown=${this.handleMouseDown}
|
|
62
|
+
.value=${this.nativeInputValue}
|
|
63
|
+
class="flex-fill"
|
|
64
|
+
type="date"
|
|
65
|
+
min=${this.min}
|
|
66
|
+
max=${this.max}
|
|
67
|
+
?disabled=${this.disabled}
|
|
68
|
+
/>`}
|
|
69
|
+
</ix-field>`}render(){return"static"===this.type?this.renderStaticDate():this.renderDateInput()}}V.shadowRootOptions={...i.shadowRootOptions,delegatesFocus:!0},V.formAssociated=!0,t([a({type:String})],V.prototype,"type",void 0),t([a({type:String})],V.prototype,"variant",void 0),t([a({type:String})],V.prototype,"format",void 0),t([a({type:String})],V.prototype,"timeFormat",void 0),t([a({type:String})],V.prototype,"timezone",void 0),t([a({type:String})],V.prototype,"label",void 0),t([a({type:String})],V.prototype,"dateTimeText",void 0),t([a({type:String})],V.prototype,"value",void 0),t([a({type:Boolean})],V.prototype,"showCalendarOnMouseDown",void 0),t([a({type:String})],V.prototype,"min",void 0),t([a({type:String})],V.prototype,"max",void 0),t([a({type:Boolean,attribute:"no-time-zone-conversion"})],V.prototype,"noTimeZoneConversion",void 0),t([o("#date-input")],V.prototype,"dateInput",void 0),t([o("vaadin-date-picker")],V.prototype,"datePicker",void 0),t([a({type:Boolean,reflect:!0})],V.prototype,"disabled",void 0),t([a({type:String,attribute:"error-text"})],V.prototype,"errorText",void 0),t([a({type:Boolean,reflect:!0})],V.prototype,"required",void 0),t([a({type:Boolean,reflect:!0})],V.prototype,"hideError",void 0),t([a({type:Boolean,attribute:"clear-button-visible"})],V.prototype,"clearButtonVisible",void 0),t([a({type:Function})],V.prototype,"onChanged",void 0),t([s()],V.prototype,"focused",void 0),window.customElements.define("ix-date",V);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent ix-date following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Digital Realty",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.3.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
21
21
|
"build": "tsc && npm run analyze -- --exclude dist && rollup -c",
|
|
22
22
|
"prepublish": "tsc && npm run analyze -- --exclude dist",
|
|
23
|
-
"lint": "eslint --ext .ts,.html .
|
|
24
|
-
"format": "eslint --ext .ts,.html . --fix
|
|
23
|
+
"lint": "eslint --ext .ts,.html . && prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
24
|
+
"format": "eslint --ext .ts,.html . --fix && prettier \"**/*.ts\" --write --ignore-path .gitignore",
|
|
25
25
|
"test": "tsc && wtr --coverage",
|
|
26
26
|
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@adobe/lit-mobx": "^2.2.2",
|
|
30
|
-
"@digital-realty/ix-field": "^1.
|
|
30
|
+
"@digital-realty/ix-field": "^1.3.1",
|
|
31
31
|
"@material/web": "2.4.0",
|
|
32
32
|
"@vaadin/date-picker": "^24.6.0",
|
|
33
33
|
"@web/test-runner-commands": "^0.9.0",
|
|
@@ -38,29 +38,27 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@custom-elements-manifest/analyzer": "^0.4.17",
|
|
41
|
-
"@open-wc/eslint-config": "^9.2.1",
|
|
42
41
|
"@open-wc/testing": "^3.1.6",
|
|
43
42
|
"@rollup/plugin-commonjs": "^25.0.4",
|
|
43
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
44
44
|
"@types/glob": "^8.1.0",
|
|
45
45
|
"@types/timezoned-date": "^3.0.2",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
47
|
-
"@typescript-eslint/parser": "^
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^8.58.2",
|
|
47
|
+
"@typescript-eslint/parser": "^8.58.2",
|
|
48
48
|
"@web/dev-server": "^0.4.6",
|
|
49
49
|
"@web/dev-server-import-maps": "^0.2.1",
|
|
50
50
|
"@web/dev-server-rollup": "^0.6.4",
|
|
51
51
|
"@web/test-runner": "^0.20.2",
|
|
52
|
-
"concurrently": "^9.1
|
|
53
|
-
"eslint": "^
|
|
52
|
+
"concurrently": "^9.2.1",
|
|
53
|
+
"eslint": "^9.39.4",
|
|
54
54
|
"eslint-config-prettier": "^8.3.0",
|
|
55
55
|
"husky": "^4.3.8",
|
|
56
56
|
"lint-staged": "^10.5.4",
|
|
57
57
|
"mockdate": "^3.0.5",
|
|
58
58
|
"prettier": "^2.4.1",
|
|
59
59
|
"rollup": "^4.29.1",
|
|
60
|
-
"rollup-plugin-minify-html-literals": "^1.2.6",
|
|
61
60
|
"rollup-plugin-replace": "^2.2.0",
|
|
62
61
|
"rollup-plugin-summary": "^2.0.0",
|
|
63
|
-
"rollup-plugin-uglify": "^6.0.4",
|
|
64
62
|
"timezoned-date": "^3.0.2",
|
|
65
63
|
"tslib": "^2.3.1",
|
|
66
64
|
"typescript": "^4.5.2"
|
|
@@ -68,10 +66,6 @@
|
|
|
68
66
|
"customElements": "custom-elements.json",
|
|
69
67
|
"eslintConfig": {
|
|
70
68
|
"parser": "@typescript-eslint/parser",
|
|
71
|
-
"extends": [
|
|
72
|
-
"@open-wc",
|
|
73
|
-
"prettier"
|
|
74
|
-
],
|
|
75
69
|
"plugins": [
|
|
76
70
|
"@typescript-eslint"
|
|
77
71
|
],
|
|
@@ -112,5 +106,5 @@
|
|
|
112
106
|
"README.md",
|
|
113
107
|
"LICENSE"
|
|
114
108
|
],
|
|
115
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "da06737d6707fd3d4ef898ba0fa632e7b3ed8019"
|
|
116
110
|
}
|