igniteui-webcomponents 6.3.4 → 6.4.0-alpha.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/CHANGELOG.md +5 -0
- package/README.md +3 -0
- package/components/badge/themes/dark/badge.bootstrap.css.js +1 -1
- package/components/badge/themes/dark/badge.bootstrap.css.js.map +1 -1
- package/components/badge/themes/dark/badge.fluent.css.js +1 -1
- package/components/badge/themes/dark/badge.fluent.css.js.map +1 -1
- package/components/badge/themes/dark/badge.indigo.css.js +1 -1
- package/components/badge/themes/dark/badge.indigo.css.js.map +1 -1
- package/components/badge/themes/dark/badge.material.css.js +1 -1
- package/components/badge/themes/dark/badge.material.css.js.map +1 -1
- package/components/badge/themes/light/badge.bootstrap.css.js +1 -1
- package/components/badge/themes/light/badge.bootstrap.css.js.map +1 -1
- package/components/badge/themes/light/badge.fluent.css.js +1 -1
- package/components/badge/themes/light/badge.fluent.css.js.map +1 -1
- package/components/badge/themes/light/badge.indigo.css.js +1 -1
- package/components/badge/themes/light/badge.indigo.css.js.map +1 -1
- package/components/badge/themes/light/badge.material.css.js +1 -1
- package/components/badge/themes/light/badge.material.css.js.map +1 -1
- package/components/badge/themes/light/badge.shared.css.js +1 -1
- package/components/badge/themes/light/badge.shared.css.js.map +1 -1
- package/components/calendar/base.d.ts +9 -1
- package/components/calendar/base.js +21 -2
- package/components/calendar/base.js.map +1 -1
- package/components/calendar/calendar.d.ts +0 -4
- package/components/calendar/calendar.js +0 -5
- package/components/calendar/calendar.js.map +1 -1
- package/components/calendar/days-view/days-view.d.ts +0 -2
- package/components/calendar/days-view/days-view.js +0 -5
- package/components/calendar/days-view/days-view.js.map +1 -1
- package/components/carousel/carousel.d.ts +19 -2
- package/components/carousel/carousel.js +41 -6
- package/components/carousel/carousel.js.map +1 -1
- package/components/carousel/themes/dark/carousel.indigo.css.js +1 -1
- package/components/carousel/themes/dark/carousel.indigo.css.js.map +1 -1
- package/components/carousel/themes/light/carousel.indigo.css.js +1 -1
- package/components/carousel/themes/light/carousel.indigo.css.js.map +1 -1
- package/components/carousel/themes/shared/carousel.common.css.js +1 -1
- package/components/carousel/themes/shared/carousel.common.css.js.map +1 -1
- package/components/carousel/themes/shared/carousel.indigo.css.js +1 -1
- package/components/carousel/themes/shared/carousel.indigo.css.js.map +1 -1
- package/components/carousel/themes/shared/indicator-container/indicator-container.common.css.js +1 -1
- package/components/carousel/themes/shared/indicator-container/indicator-container.common.css.js.map +1 -1
- package/components/chat/chat-input.d.ts +4 -0
- package/components/chat/chat-input.js +29 -5
- package/components/chat/chat-input.js.map +1 -1
- package/components/chat/chat-state.d.ts +3 -4
- package/components/chat/chat-state.js +4 -23
- package/components/chat/chat-state.js.map +1 -1
- package/components/chat/chat.d.ts +1 -1
- package/components/chat/chat.js +22 -20
- package/components/chat/chat.js.map +1 -1
- package/components/chat/themes/chat.base.css.js +1 -1
- package/components/chat/themes/chat.base.css.js.map +1 -1
- package/components/chat/utils.js +3 -0
- package/components/chat/utils.js.map +1 -1
- package/components/checkbox/themes/dark/checkbox/checkbox.fluent.css.js +1 -1
- package/components/checkbox/themes/dark/checkbox/checkbox.fluent.css.js.map +1 -1
- package/components/checkbox/themes/light/checkbox/checkbox.fluent.css.js +1 -1
- package/components/checkbox/themes/light/checkbox/checkbox.fluent.css.js.map +1 -1
- package/components/checkbox/themes/light/checkbox/checkbox.shared.css.js +1 -1
- package/components/checkbox/themes/light/checkbox/checkbox.shared.css.js.map +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.bootstrap.css.js +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.bootstrap.css.js.map +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.common.css.js +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.common.css.js.map +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.fluent.css.js +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.fluent.css.js.map +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.indigo.css.js +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.indigo.css.js.map +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.material.css.js +1 -1
- package/components/checkbox/themes/shared/checkbox/checkbox.material.css.js.map +1 -1
- package/components/chip/chip.d.ts +13 -0
- package/components/chip/chip.js +29 -2
- package/components/chip/chip.js.map +1 -1
- package/components/chip/themes/chip.base.css.js +1 -1
- package/components/chip/themes/chip.base.css.js.map +1 -1
- package/components/chip/themes/shared/chip.bootstrap.css.js +1 -1
- package/components/chip/themes/shared/chip.bootstrap.css.js.map +1 -1
- package/components/chip/themes/shared/chip.common.css.js +1 -1
- package/components/chip/themes/shared/chip.common.css.js.map +1 -1
- package/components/chip/themes/shared/chip.fluent.css.js +1 -1
- package/components/chip/themes/shared/chip.fluent.css.js.map +1 -1
- package/components/chip/themes/shared/chip.indigo.css.js +1 -1
- package/components/chip/themes/shared/chip.indigo.css.js.map +1 -1
- package/components/combo/combo.d.ts +22 -1
- package/components/combo/combo.js +38 -4
- package/components/combo/combo.js.map +1 -1
- package/components/combo/operations/group.d.ts +0 -1
- package/components/combo/operations/group.js +19 -23
- package/components/combo/operations/group.js.map +1 -1
- package/components/combo/themes/combo-header.base.css.js +1 -1
- package/components/combo/themes/combo-header.base.css.js.map +1 -1
- package/components/combo/themes/combo-item.base.css.js +1 -1
- package/components/combo/themes/combo-item.base.css.js.map +1 -1
- package/components/combo/themes/combo.base.css.js +1 -1
- package/components/combo/themes/combo.base.css.js.map +1 -1
- package/components/combo/themes/shared/combo.bootstrap.css.js +1 -1
- package/components/combo/themes/shared/combo.bootstrap.css.js.map +1 -1
- package/components/combo/themes/shared/combo.fluent.css.js +1 -1
- package/components/combo/themes/shared/combo.fluent.css.js.map +1 -1
- package/components/combo/themes/shared/combo.indigo.css.js +1 -1
- package/components/combo/themes/shared/combo.indigo.css.js.map +1 -1
- package/components/combo/themes/shared/combo.material.css.js +1 -1
- package/components/combo/themes/shared/combo.material.css.js.map +1 -1
- package/components/combo/validators.js +2 -2
- package/components/combo/validators.js.map +1 -1
- package/components/common/i18n/EN/calendar.resources.js +4 -0
- package/components/common/i18n/EN/calendar.resources.js.map +1 -0
- package/components/common/i18n/EN/chat.resources.js.map +1 -0
- package/components/common/i18n/EN/date-range-picker.resources.js +8 -0
- package/components/common/i18n/EN/date-range-picker.resources.js.map +1 -0
- package/components/common/i18n/i18n-controller.d.ts +74 -0
- package/components/common/i18n/i18n-controller.js +89 -0
- package/components/common/i18n/i18n-controller.js.map +1 -0
- package/components/common/i18n/utils.d.ts +19 -0
- package/components/common/i18n/utils.js +100 -0
- package/components/common/i18n/utils.js.map +1 -0
- package/components/common/mixins/forms/associated.js +23 -3
- package/components/common/mixins/forms/associated.js.map +1 -1
- package/components/common/util.d.ts +0 -1
- package/components/common/util.js +0 -15
- package/components/common/util.js.map +1 -1
- package/components/common/validators.d.ts +4 -2
- package/components/common/validators.js +19 -13
- package/components/common/validators.js.map +1 -1
- package/components/date-picker/date-picker.d.ts +13 -8
- package/components/date-picker/date-picker.js +20 -6
- package/components/date-picker/date-picker.js.map +1 -1
- package/components/date-picker/themes/dark/date-picker.bootstrap.css.js +1 -1
- package/components/date-picker/themes/dark/date-picker.bootstrap.css.js.map +1 -1
- package/components/date-picker/themes/date-picker.base.css.js +1 -1
- package/components/date-picker/themes/date-picker.base.css.js.map +1 -1
- package/components/date-picker/themes/light/date-picker.bootstrap.css.js +1 -1
- package/components/date-picker/themes/light/date-picker.bootstrap.css.js.map +1 -1
- package/components/date-picker/themes/shared/date-picker.bootstrap.css.js +1 -1
- package/components/date-picker/themes/shared/date-picker.bootstrap.css.js.map +1 -1
- package/components/date-picker/themes/shared/date-picker.common.css.js +1 -1
- package/components/date-picker/themes/shared/date-picker.common.css.js.map +1 -1
- package/components/date-picker/themes/shared/date-picker.fluent.css.js +1 -1
- package/components/date-picker/themes/shared/date-picker.fluent.css.js.map +1 -1
- package/components/date-picker/themes/shared/date-picker.indigo.css.js +1 -1
- package/components/date-picker/themes/shared/date-picker.indigo.css.js.map +1 -1
- package/components/date-picker/themes/shared/date-picker.material.css.js +1 -1
- package/components/date-picker/themes/shared/date-picker.material.css.js.map +1 -1
- package/components/date-picker/validators.js +3 -2
- package/components/date-picker/validators.js.map +1 -1
- package/components/date-range-picker/date-range-picker.base.css.js +1 -1
- package/components/date-range-picker/date-range-picker.base.css.js.map +1 -1
- package/components/date-range-picker/date-range-picker.d.ts +6 -2
- package/components/date-range-picker/date-range-picker.js +19 -5
- package/components/date-range-picker/date-range-picker.js.map +1 -1
- package/components/date-range-picker/predefined-ranges-area.d.ts +4 -2
- package/components/date-range-picker/predefined-ranges-area.js +12 -3
- package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
- package/components/date-range-picker/themes/dark/date-range-picker.bootstrap.css.js +1 -1
- package/components/date-range-picker/themes/dark/date-range-picker.bootstrap.css.js.map +1 -1
- package/components/date-range-picker/themes/dark/date-range-picker.fluent.css.js +1 -1
- package/components/date-range-picker/themes/dark/date-range-picker.fluent.css.js.map +1 -1
- package/components/date-range-picker/themes/dark/date-range-picker.indigo.css.js +1 -1
- package/components/date-range-picker/themes/dark/date-range-picker.indigo.css.js.map +1 -1
- package/components/date-range-picker/themes/dark/date-range-picker.material.css.js +1 -1
- package/components/date-range-picker/themes/dark/date-range-picker.material.css.js.map +1 -1
- package/components/date-range-picker/themes/light/date-range-picker.bootstrap.css.js +1 -1
- package/components/date-range-picker/themes/light/date-range-picker.bootstrap.css.js.map +1 -1
- package/components/date-range-picker/themes/light/date-range-picker.fluent.css.js +1 -1
- package/components/date-range-picker/themes/light/date-range-picker.fluent.css.js.map +1 -1
- package/components/date-range-picker/themes/light/date-range-picker.indigo.css.js +1 -1
- package/components/date-range-picker/themes/light/date-range-picker.indigo.css.js.map +1 -1
- package/components/date-range-picker/themes/light/date-range-picker.material.css.js +1 -1
- package/components/date-range-picker/themes/light/date-range-picker.material.css.js.map +1 -1
- package/components/date-range-picker/themes/light/date-range-picker.shared.css.js +1 -1
- package/components/date-range-picker/themes/light/date-range-picker.shared.css.js.map +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.bootstrap.css.js +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.bootstrap.css.js.map +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.common.css.js +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.common.css.js.map +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.fluent.css.js +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.fluent.css.js.map +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.indigo.css.js +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.indigo.css.js.map +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.material.css.js +1 -1
- package/components/date-range-picker/themes/shared/date-range-picker.material.css.js.map +1 -1
- package/components/date-range-picker/validators.js +8 -5
- package/components/date-range-picker/validators.js.map +1 -1
- package/components/date-time-input/date-time-input.d.ts +5 -3
- package/components/date-time-input/date-time-input.js +11 -2
- package/components/date-time-input/date-time-input.js.map +1 -1
- package/components/input/themes/dark/input.bootstrap.css.js +1 -1
- package/components/input/themes/dark/input.bootstrap.css.js.map +1 -1
- package/components/input/themes/input.base.css.js +1 -1
- package/components/input/themes/input.base.css.js.map +1 -1
- package/components/input/themes/light/input.bootstrap.css.js +1 -1
- package/components/input/themes/light/input.bootstrap.css.js.map +1 -1
- package/components/input/themes/shared/input.bootstrap.css.js +1 -1
- package/components/input/themes/shared/input.bootstrap.css.js.map +1 -1
- package/components/input/themes/shared/input.common.css.js +1 -1
- package/components/input/themes/shared/input.common.css.js.map +1 -1
- package/components/input/themes/shared/input.fluent.css.js +1 -1
- package/components/input/themes/shared/input.fluent.css.js.map +1 -1
- package/components/input/themes/shared/input.indigo.css.js +1 -1
- package/components/input/themes/shared/input.indigo.css.js.map +1 -1
- package/components/input/themes/shared/input.material.css.js +1 -1
- package/components/input/themes/shared/input.material.css.js.map +1 -1
- package/components/input/validators.js +3 -3
- package/components/input/validators.js.map +1 -1
- package/components/mask-input/validators.js +2 -2
- package/components/mask-input/validators.js.map +1 -1
- package/components/radio/validators.js +2 -2
- package/components/radio/validators.js.map +1 -1
- package/components/select/themes/select.base.css.js +1 -1
- package/components/select/themes/select.base.css.js.map +1 -1
- package/components/select/themes/shared/select.fluent.css.js +1 -1
- package/components/select/themes/shared/select.fluent.css.js.map +1 -1
- package/components/select/themes/shared/select.indigo.css.js +1 -1
- package/components/select/themes/shared/select.indigo.css.js.map +1 -1
- package/components/select/themes/shared/select.material.css.js +1 -1
- package/components/select/themes/shared/select.material.css.js.map +1 -1
- package/components/textarea/textarea.d.ts +1 -1
- package/components/textarea/textarea.js +1 -1
- package/components/textarea/textarea.js.map +1 -1
- package/components/textarea/themes/dark/textarea.bootstrap.css.js +1 -1
- package/components/textarea/themes/dark/textarea.bootstrap.css.js.map +1 -1
- package/components/textarea/themes/light/textarea.bootstrap.css.js +1 -1
- package/components/textarea/themes/light/textarea.bootstrap.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.bootstrap.css.js +1 -1
- package/components/textarea/themes/shared/textarea.bootstrap.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.common.css.js +1 -1
- package/components/textarea/themes/shared/textarea.common.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.fluent.css.js +1 -1
- package/components/textarea/themes/shared/textarea.fluent.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.indigo.css.js +1 -1
- package/components/textarea/themes/shared/textarea.indigo.css.js.map +1 -1
- package/components/textarea/themes/shared/textarea.material.css.js +1 -1
- package/components/textarea/themes/shared/textarea.material.css.js.map +1 -1
- package/components/textarea/themes/textarea.base.css.js +1 -1
- package/components/textarea/themes/textarea.base.css.js.map +1 -1
- package/components/tile-manager/tile.js.map +1 -1
- package/components/tooltip/controller.d.ts +1 -0
- package/components/tooltip/controller.js +9 -0
- package/components/tooltip/controller.js.map +1 -1
- package/components/tooltip/tooltip.js +1 -0
- package/components/tooltip/tooltip.js.map +1 -1
- package/custom-elements.json +1191 -234
- package/igniteui-webcomponents.html-data.json +1 -1
- package/index.d.ts +3 -2
- package/index.js +3 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/web-types.json +1 -1
- package/components/common/i18n/calendar.resources.js +0 -17
- package/components/common/i18n/calendar.resources.js.map +0 -1
- package/components/common/i18n/chat.resources.js.map +0 -1
- package/components/common/i18n/date-range-picker.resources.js +0 -12
- package/components/common/i18n/date-range-picker.resources.js.map +0 -1
- package/components/common/localization/validation-en.d.ts +0 -13
- package/components/common/localization/validation-en.js +0 -13
- package/components/common/localization/validation-en.js.map +0 -1
- /package/components/common/i18n/{calendar.resources.d.ts → EN/calendar.resources.d.ts} +0 -0
- /package/components/common/i18n/{chat.resources.d.ts → EN/chat.resources.d.ts} +0 -0
- /package/components/common/i18n/{chat.resources.js → EN/chat.resources.js} +0 -0
- /package/components/common/i18n/{date-range-picker.resources.d.ts → EN/date-range-picker.resources.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo.indigo.css.js","sourceRoot":"","sources":["../../../../../src/components/combo/themes/shared/combo.indigo.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,
|
|
1
|
+
{"version":3,"file":"combo.indigo.css.js","sourceRoot":"","sources":["../../../../../src/components/combo/themes/shared/combo.indigo.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,g8IAAg8I,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`:host{--component-size: var(--ig-size, var(--default-size));--input-icon: max(var(--is-large, 1) * max(1.125rem, -1 * 1.125rem), var(--is-medium, 1) * max(1rem, -1 * 1rem), var(--is-small, 1) * max(0.875rem, -1 * 0.875rem));--combo-size: var(--component-size)}:host igc-input::part(container){padding-inline:0}:host ::part(helper-text){margin-block-start:max(var(--is-large, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-large, var(--ig-spacing-block, var(--ig-spacing))),var(--is-medium, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-medium, var(--ig-spacing-block, var(--ig-spacing))),var(--is-small, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-small, var(--ig-spacing-block, var(--ig-spacing))));grid-auto-rows:minmax(0.9375rem, auto)}:host igc-icon,:host ::slotted(igc-icon){--size: var(--input-icon) !important}[part=case-icon]{color:var(--ig-gray-600)}[part=\"case-icon active\"]{color:var(--ig-gray-900)}:host(:not([single-select]))>igc-input::part(input)::-moz-selection{background:rgba(0,0,0,0)}:host(:not([single-select]))>igc-input::part(input)::selection{background:rgba(0,0,0,0)}[part=list-wrapper]{background:var(--background-color);border-radius:var(--border-radius);outline:var(--border-width) solid var(--border-color);padding:max(var(--is-large, 1)*max(0.1875rem, -1 * 0.1875rem)*var(--ig-spacing-large, var(--ig-spacing, var(--ig-spacing))),var(--is-medium, 1)*max(0.1875rem, -1 * 0.1875rem)*var(--ig-spacing-medium, var(--ig-spacing, var(--ig-spacing))),var(--is-small, 1)*max(0.1875rem, -1 * 0.1875rem)*var(--ig-spacing-small, var(--ig-spacing, var(--ig-spacing))))}[part=list-wrapper] igc-input{--ig-theme: indigo;--ig-size: var(--ig-size-medium)}[part=list-wrapper] igc-input::part(input)::-moz-selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(input)::selection{background:var(--ig-primary-100)}[part=list-wrapper] [part=\"case-icon active\"]{color:var(--ig-primary-500)}[part=list]{min-height:calc(var(--size)*var(--item-count) + 1rem) !important}[part=filter-input]{padding-inline:max(var(--is-large, 1)*max(0.75rem, -1 * 0.75rem)*var(--ig-spacing-inline-large, var(--ig-spacing-inline, var(--ig-spacing))),var(--is-medium, 1)*max(0.75rem, -1 * 0.75rem)*var(--ig-spacing-inline-medium, var(--ig-spacing-inline, var(--ig-spacing))),var(--is-small, 1)*max(0.5rem, -1 * 0.5rem)*var(--ig-spacing-inline-small, var(--ig-spacing-inline, var(--ig-spacing))));padding-block:max(var(--is-large, 1)*max(0.75rem, -1 * 0.75rem)*var(--ig-spacing-block-large, var(--ig-spacing-block, var(--ig-spacing))),var(--is-medium, 1)*max(0.75rem, -1 * 0.75rem)*var(--ig-spacing-block-medium, var(--ig-spacing-block, var(--ig-spacing))),var(--is-small, 1)*max(0.75rem, -1 * 0.75rem)*var(--ig-spacing-block-small, var(--ig-spacing-block, var(--ig-spacing))))}:host(:focus-within) igc-input::part(label){color:var(--focused-secondary-color)}:host(:hover) [part~=toggle-icon],:host(:focus-within) [part~=toggle-icon]{background:var(--toggle-button-background-focus--border);color:var(--toggle-button-foreground-focus)}:host(:hover) [part~=toggle-icon] igc-icon,:host(:focus-within) [part~=toggle-icon] igc-icon{color:inherit}:host(:hover) [part~=clear-icon],:host(:focus-within) [part~=clear-icon]{background:var(--clear-button-background-focus);color:var(--clear-button-foreground-focus)}:host(:hover) [part~=clear-icon] igc-icon,:host(:focus-within) [part~=clear-icon] igc-icon{color:inherit}:host(:not([disabled]):state(ig-invalid)) ::part(helper-text),:host(:not(:disabled):state(ig-invalid)) ::part(helper-text){color:var(--helper-text-color)}:host(:disabled) igc-input::part(input)::-moz-selection, :host([disabled]) igc-input::part(input)::-moz-selection{background:rgba(0,0,0,0)}:host(:disabled) ::slotted([slot=prefix]),:host(:disabled) ::slotted([slot=suffix]),:host(:disabled) igc-input::part(input)::selection,:host([disabled]) ::slotted([slot=prefix]),:host([disabled]) ::slotted([slot=suffix]),:host([disabled]) igc-input::part(input)::selection{background:rgba(0,0,0,0)}:host(:disabled) [part~=clear-icon],:host([disabled]) [part~=clear-icon]{background:inherit;color:var(--disabled-text-color)}:host(:disabled) [part~=clear-icon] igc-icon,:host([disabled]) [part~=clear-icon] igc-icon{color:inherit}:host(:disabled) [part~=toggle-icon],:host([disabled]) [part~=toggle-icon]{background:var(--toggle-button-background-disabled);color:var(--toggle-button-foreground-disabled)}:host(:disabled) [part~=toggle-icon] igc-icon,:host([disabled]) [part~=toggle-icon] igc-icon{color:inherit}`;\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const styles = css `:host{--component-size: var(--ig-size, var(--default-size));--combo-size: var(--component-size)}:host ::part(helper-text){
|
|
2
|
+
export const styles = css `:host{--component-size: var(--ig-size, var(--default-size));--combo-size: var(--component-size)}:host ::part(helper-text){margin-block-start:max(var(--is-large, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-large, var(--ig-spacing-block, var(--ig-spacing))),var(--is-medium, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-medium, var(--ig-spacing-block, var(--ig-spacing))),var(--is-small, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-small, var(--ig-spacing-block, var(--ig-spacing))));grid-auto-rows:minmax(1.125rem, auto);padding-inline:max(var(--is-large, 1)*max(1rem, -1 * 1rem)*var(--ig-spacing-inline-large, var(--ig-spacing-inline, var(--ig-spacing))),var(--is-medium, 1)*max(0.875rem, -1 * 0.875rem)*var(--ig-spacing-inline-medium, var(--ig-spacing-inline, var(--ig-spacing))),var(--is-small, 1)*max(0.75rem, -1 * 0.75rem)*var(--ig-spacing-inline-small, var(--ig-spacing-inline, var(--ig-spacing))))}:host ::slotted([slot=prefix]),:host ::slotted([slot=suffix]){color:inherit}:host(:not([single-select]))>igc-input::part(input)::-moz-selection{background:rgba(0,0,0,0)}:host(:not([single-select]))>igc-input::part(input)::selection{background:rgba(0,0,0,0)}[part=list-wrapper]{background:var(--background-color);border-radius:var(--border-radius)}[part=list-wrapper] igc-input,[part=list-wrapper] igc-input::part(container),[part=list-wrapper] igc-input::part(input){height:2.375rem}[part=list-wrapper] igc-input::part(container){background:rgba(0,0,0,0);border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;border-radius:0}[part=list-wrapper] igc-input::part(start){display:none}[part=list-wrapper] igc-input::part(input){border-radius:0;padding:0;border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;box-shadow:none}[part=list-wrapper] igc-input::part(input)::-moz-selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(input)::selection{background:var(--ig-primary-100)}[part=list-wrapper] [part=case-icon]{color:var(--ig-gray-600)}[part=list-wrapper] [part="case-icon active"]{color:var(--ig-primary-500)}[part="toggle-icon filled"]{color:var(--toggle-button-foreground-filled)}:host(:not([outlined]):focus-within) igc-input::part(container){--_toggle-focus-background: var(--toggle-button-background);--_toggle-focus-foreground: var(--toggle-button-foreground)}:host(:not([outlined]):focus-within) igc-input::part(container):focus-within{--_toggle-focus-background: var(--toggle-button-background-focus);--_toggle-focus-foreground: var(--toggle-button-foreground-filled)}:host(:not([outlined]):focus-within) [part~=toggle-icon]{color:var(--_toggle-focus-foreground);background:var(--_toggle-focus-background)}:host(:not([outlined]):focus-within) [part="toggle-icon filled"]{color:var(--toggle-button-foreground-filled)}:host([outlined]:focus-within) [part~=toggle-icon]{background:var(--toggle-button-background-focus--border)}:host(:disabled) igc-input::part(input)::-moz-placeholder, :host([disabled]) igc-input::part(input)::-moz-placeholder{color:var(--disabled-text-color)}:host(:disabled) ::slotted([slot=prefix]),:host(:disabled) ::slotted([slot=suffix]),:host(:disabled) igc-input::part(label),:host(:disabled) igc-input::part(input)::placeholder,:host([disabled]) ::slotted([slot=prefix]),:host([disabled]) ::slotted([slot=suffix]),:host([disabled]) igc-input::part(label),:host([disabled]) igc-input::part(input)::placeholder{color:var(--disabled-text-color)}:host(:disabled) [part~=clear-icon],:host([disabled]) [part~=clear-icon]{background:inherit;color:var(--disabled-text-color)}:host(:disabled) [part~=clear-icon] igc-icon,:host([disabled]) [part~=clear-icon] igc-icon{color:inherit}:host(:disabled) [part~=toggle-icon],:host([disabled]) [part~=toggle-icon]{background:var(--toggle-button-background-disabled);color:var(--toggle-button-foreground-disabled)}:host(:disabled) [part~=toggle-icon] igc-icon,:host([disabled]) [part~=toggle-icon] igc-icon{color:inherit}:host(:disabled[outlined]) igc-input::part(filled)+igc-input::part(notch),:host([outlined][disabled]) igc-input::part(filled)+igc-input::part(notch){border-top-color:rgba(0,0,0,0)}`;
|
|
3
3
|
//# sourceMappingURL=combo.material.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo.material.css.js","sourceRoot":"","sources":["../../../../../src/components/combo/themes/shared/combo.material.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,
|
|
1
|
+
{"version":3,"file":"combo.material.css.js","sourceRoot":"","sources":["../../../../../src/components/combo/themes/shared/combo.material.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,ilIAAilI,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`:host{--component-size: var(--ig-size, var(--default-size));--combo-size: var(--component-size)}:host ::part(helper-text){margin-block-start:max(var(--is-large, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-large, var(--ig-spacing-block, var(--ig-spacing))),var(--is-medium, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-medium, var(--ig-spacing-block, var(--ig-spacing))),var(--is-small, 1)*max(0.25rem, -1 * 0.25rem)*var(--ig-spacing-block-small, var(--ig-spacing-block, var(--ig-spacing))));grid-auto-rows:minmax(1.125rem, auto);padding-inline:max(var(--is-large, 1)*max(1rem, -1 * 1rem)*var(--ig-spacing-inline-large, var(--ig-spacing-inline, var(--ig-spacing))),var(--is-medium, 1)*max(0.875rem, -1 * 0.875rem)*var(--ig-spacing-inline-medium, var(--ig-spacing-inline, var(--ig-spacing))),var(--is-small, 1)*max(0.75rem, -1 * 0.75rem)*var(--ig-spacing-inline-small, var(--ig-spacing-inline, var(--ig-spacing))))}:host ::slotted([slot=prefix]),:host ::slotted([slot=suffix]){color:inherit}:host(:not([single-select]))>igc-input::part(input)::-moz-selection{background:rgba(0,0,0,0)}:host(:not([single-select]))>igc-input::part(input)::selection{background:rgba(0,0,0,0)}[part=list-wrapper]{background:var(--background-color);border-radius:var(--border-radius)}[part=list-wrapper] igc-input,[part=list-wrapper] igc-input::part(container),[part=list-wrapper] igc-input::part(input){height:2.375rem}[part=list-wrapper] igc-input::part(container){background:rgba(0,0,0,0);border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;border-radius:0}[part=list-wrapper] igc-input::part(start){display:none}[part=list-wrapper] igc-input::part(input){border-radius:0;padding:0;border-inline-start:0;border-inline-end-color:rgba(0,0,0,0);border-block-start:0;box-shadow:none}[part=list-wrapper] igc-input::part(input)::-moz-selection{background:var(--ig-primary-100)}[part=list-wrapper] igc-input::part(input)::selection{background:var(--ig-primary-100)}[part=list-wrapper] [part=case-icon]{color:var(--ig-gray-600)}[part=list-wrapper] [part=\"case-icon active\"]{color:var(--ig-primary-500)}[part=\"toggle-icon filled\"]{color:var(--toggle-button-foreground-filled)}:host(:not([outlined]):focus-within) igc-input::part(container){--_toggle-focus-background: var(--toggle-button-background);--_toggle-focus-foreground: var(--toggle-button-foreground)}:host(:not([outlined]):focus-within) igc-input::part(container):focus-within{--_toggle-focus-background: var(--toggle-button-background-focus);--_toggle-focus-foreground: var(--toggle-button-foreground-filled)}:host(:not([outlined]):focus-within) [part~=toggle-icon]{color:var(--_toggle-focus-foreground);background:var(--_toggle-focus-background)}:host(:not([outlined]):focus-within) [part=\"toggle-icon filled\"]{color:var(--toggle-button-foreground-filled)}:host([outlined]:focus-within) [part~=toggle-icon]{background:var(--toggle-button-background-focus--border)}:host(:disabled) igc-input::part(input)::-moz-placeholder, :host([disabled]) igc-input::part(input)::-moz-placeholder{color:var(--disabled-text-color)}:host(:disabled) ::slotted([slot=prefix]),:host(:disabled) ::slotted([slot=suffix]),:host(:disabled) igc-input::part(label),:host(:disabled) igc-input::part(input)::placeholder,:host([disabled]) ::slotted([slot=prefix]),:host([disabled]) ::slotted([slot=suffix]),:host([disabled]) igc-input::part(label),:host([disabled]) igc-input::part(input)::placeholder{color:var(--disabled-text-color)}:host(:disabled) [part~=clear-icon],:host([disabled]) [part~=clear-icon]{background:inherit;color:var(--disabled-text-color)}:host(:disabled) [part~=clear-icon] igc-icon,:host([disabled]) [part~=clear-icon] igc-icon{color:inherit}:host(:disabled) [part~=toggle-icon],:host([disabled]) [part~=toggle-icon]{background:var(--toggle-button-background-disabled);color:var(--toggle-button-foreground-disabled)}:host(:disabled) [part~=toggle-icon] igc-icon,:host([disabled]) [part~=toggle-icon] igc-icon{color:inherit}:host(:disabled[outlined]) igc-input::part(filled)+igc-input::part(notch),:host([outlined][disabled]) igc-input::part(filled)+igc-input::part(notch){border-top-color:rgba(0,0,0,0)}`;\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { validationResourcesKeys } from '../common/i18n/utils.js';
|
|
2
2
|
export const comboValidators = [
|
|
3
3
|
{
|
|
4
4
|
key: 'valueMissing',
|
|
5
|
-
|
|
5
|
+
messageResourceKey: validationResourcesKeys.required,
|
|
6
6
|
isValid: ({ required, value }) => required ? Array.isArray(value) && value.length > 0 : true,
|
|
7
7
|
},
|
|
8
8
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/components/combo/validators.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/components/combo/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAIlE,MAAM,CAAC,MAAM,eAAe,GAAmC;IAC7D;QACE,GAAG,EAAE,cAAc;QACnB,kBAAkB,EAAE,uBAAuB,CAAC,QAAQ;QACpD,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAC/B,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI;KAC7D;CACF,CAAC","sourcesContent":["import { validationResourcesKeys } from '../common/i18n/utils.js';\nimport type { Validator } from '../common/validators.js';\nimport type IgcComboComponent from './combo.js';\n\nexport const comboValidators: Validator<IgcComboComponent>[] = [\n {\n key: 'valueMissing',\n messageResourceKey: validationResourcesKeys.required,\n isValid: ({ required, value }) =>\n required ? Array.isArray(value) && value.length > 0 : true,\n },\n];\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.resources.js","sourceRoot":"","sources":["../../../../../src/components/common/i18n/EN/calendar.resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAoBnD,MAAM,CAAC,MAAM,2BAA2B,GACtC,oBAAoB,CAAC,yBAAyB,CAAC,CAAC","sourcesContent":["import { CalendarResourceStringsEN } from 'igniteui-i18n-core';\nimport { convertToIgcResource } from '../utils.js';\n\n/* blazorSuppress */\nexport interface IgcCalendarResourceStrings {\n selectMonth: string;\n selectYear: string;\n selectDate: string;\n selectRange: string;\n selectedDate: string;\n startDate: string;\n endDate: string;\n previousMonth: string;\n nextMonth: string;\n previousYear: string;\n nextYear: string;\n previousYears: string;\n nextYears: string;\n weekLabel: string;\n}\n\nexport const IgcCalendarResourceStringEN: IgcCalendarResourceStrings =\n convertToIgcResource(CalendarResourceStringsEN);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.resources.js","sourceRoot":"","sources":["../../../../../src/components/common/i18n/EN/chat.resources.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC7D,iBAAiB,EAAE,aAAa;IAChC,YAAY,EAAE,MAAM;IACpB,YAAY,EAAE,MAAM;IACpB,eAAe,EAAE,SAAS;IAC1B,kBAAkB,EAAE,YAAY;IAChC,eAAe,EAAE,YAAY;IAC7B,oBAAoB,EAAE,aAAa;IACnC,aAAa,EAAE,6BAA6B;CAC7C,CAAC","sourcesContent":["/* blazorSuppress */\nexport interface IgcChatResourceStrings {\n suggestionsHeader: string;\n reactionCopy: string;\n reactionLike: string;\n reactionDislike: string;\n reactionRegenerate: string;\n attachmentLabel: string;\n attachmentsListLabel: string;\n messageCopied: string;\n}\n\nexport const IgcChatResourceStringEN: IgcChatResourceStrings = {\n suggestionsHeader: 'Suggestions',\n reactionCopy: 'Copy',\n reactionLike: 'Like',\n reactionDislike: 'Dislike',\n reactionRegenerate: 'Regenerate',\n attachmentLabel: 'Attachment',\n attachmentsListLabel: 'Attachments',\n messageCopied: 'Message copied to clipboard',\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DateRangePickerResourceStringsEN } from 'igniteui-i18n-core';
|
|
2
|
+
import { convertToIgcResource } from '../utils.js';
|
|
3
|
+
import { IgcCalendarResourceStringEN, } from './calendar.resources.js';
|
|
4
|
+
export const IgcDateRangePickerResourceStringsEN = {
|
|
5
|
+
...convertToIgcResource(DateRangePickerResourceStringsEN),
|
|
6
|
+
...IgcCalendarResourceStringEN,
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=date-range-picker.resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-range-picker.resources.js","sourceRoot":"","sources":["../../../../../src/components/common/i18n/EN/date-range-picker.resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,2BAA2B,GAE5B,MAAM,yBAAyB,CAAC;AAcjC,MAAM,CAAC,MAAM,mCAAmC,GAC9C;IACE,GAAG,oBAAoB,CAAC,gCAAgC,CAAC;IACzD,GAAG,2BAA2B;CAC/B,CAAC","sourcesContent":["import { DateRangePickerResourceStringsEN } from 'igniteui-i18n-core';\nimport { convertToIgcResource } from '../utils.js';\nimport {\n IgcCalendarResourceStringEN,\n type IgcCalendarResourceStrings,\n} from './calendar.resources.js';\n\n/* blazorSuppress */\nexport interface IgcDateRangePickerResourceStrings\n extends IgcCalendarResourceStrings {\n separator: string;\n done: string;\n cancel: string;\n last7Days: string;\n last30Days: string;\n currentMonth: string;\n yearToDate: string;\n}\n\nexport const IgcDateRangePickerResourceStringsEN: IgcDateRangePickerResourceStrings =\n {\n ...convertToIgcResource(DateRangePickerResourceStringsEN),\n ...IgcCalendarResourceStringEN,\n };\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type IResourceChangeEventArgs } from 'igniteui-i18n-core';
|
|
2
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
3
|
+
/**
|
|
4
|
+
* Defines the structure for the host element that will use this controller.
|
|
5
|
+
* The host must be a Lit element (ReactiveControllerHost) and an HTMLElement.
|
|
6
|
+
*/
|
|
7
|
+
interface I18nControllerHost extends ReactiveControllerHost, HTMLElement {
|
|
8
|
+
resourceStrings?: unknown;
|
|
9
|
+
locale?: string;
|
|
10
|
+
}
|
|
11
|
+
type ResourceChangeCallback = (event: CustomEvent<IResourceChangeEventArgs>) => unknown;
|
|
12
|
+
/** Configuration object for the I18nController. */
|
|
13
|
+
type I18nControllerConfig<T extends object> = {
|
|
14
|
+
/** The full default English resource strings object for the component. */
|
|
15
|
+
defaultEN: T;
|
|
16
|
+
/** An optional callback to execute when the global locale changes. */
|
|
17
|
+
onResourceChange?: ResourceChangeCallback;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Manages localization (i18n) for a Lit web component.
|
|
21
|
+
* It handles the current locale, component-specific resource overrides,
|
|
22
|
+
* and updates when the global localization state changes.
|
|
23
|
+
*/
|
|
24
|
+
declare class I18nController<T extends object> implements ReactiveController {
|
|
25
|
+
private readonly _host;
|
|
26
|
+
private readonly _defaultEN;
|
|
27
|
+
private _resourceChangeCallback?;
|
|
28
|
+
private _defaultResourceStrings;
|
|
29
|
+
private _locale?;
|
|
30
|
+
private _resourceStrings?;
|
|
31
|
+
/**
|
|
32
|
+
* Sets a custom locale that overrides the global one for this host component instance.
|
|
33
|
+
* Setting a new locale triggers an update of the resource strings.
|
|
34
|
+
*/
|
|
35
|
+
set locale(value: string | undefined);
|
|
36
|
+
/**
|
|
37
|
+
* Gets the resolved locale for the host component.
|
|
38
|
+
* This is the component's custom locale if set, otherwise it falls back to the
|
|
39
|
+
* global locale.
|
|
40
|
+
*/
|
|
41
|
+
get locale(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Sets custom resource string for component with this controller.
|
|
44
|
+
* Gets the resolved resource string for component.
|
|
45
|
+
*/
|
|
46
|
+
set resourceStrings(value: T | undefined);
|
|
47
|
+
/** Get resolved resource strings for component */
|
|
48
|
+
get resourceStrings(): T;
|
|
49
|
+
constructor(host: I18nControllerHost, config: I18nControllerConfig<T>);
|
|
50
|
+
/** @internal */
|
|
51
|
+
hostConnected(): void;
|
|
52
|
+
/** @internal */
|
|
53
|
+
hostDisconnected(): void;
|
|
54
|
+
/** @internal */
|
|
55
|
+
handleEvent(event: CustomEvent<IResourceChangeEventArgs>): void;
|
|
56
|
+
/** Registers the default English resources with the global i18n manager. */
|
|
57
|
+
private _registerResources;
|
|
58
|
+
/**
|
|
59
|
+
* Helper to find the correct resource map based on the component's default resources (`#defaultEN`).
|
|
60
|
+
* This relies on structural checking (the component's key names).
|
|
61
|
+
*/
|
|
62
|
+
private _getResourceMapForComponent;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the current, locale-specific resource strings for the component.
|
|
65
|
+
* The logic maps component keys (from defaultEN) to core library keys
|
|
66
|
+
* and retrieves the localized string from the i18n manager.
|
|
67
|
+
*
|
|
68
|
+
* Result is truncated, containing only relevant locale strings.
|
|
69
|
+
*/
|
|
70
|
+
private _getCurrentResourceStrings;
|
|
71
|
+
}
|
|
72
|
+
/** Factory function to create and attach the I18nController to a host. */
|
|
73
|
+
export declare function addI18nController<T extends object>(host: I18nControllerHost, config: I18nControllerConfig<T>): I18nController<T>;
|
|
74
|
+
export type { I18nController };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { getCurrentI18n, getDisplayNamesFormatter, getI18nManager, } from 'igniteui-i18n-core';
|
|
2
|
+
import { calendarResourcesMap, convertToCoreResource, dateRangePickerResourcesMap, } from './utils.js';
|
|
3
|
+
class I18nController {
|
|
4
|
+
set locale(value) {
|
|
5
|
+
if (this._locale !== value) {
|
|
6
|
+
this._locale = value;
|
|
7
|
+
this._defaultResourceStrings = this._getCurrentResourceStrings();
|
|
8
|
+
this._host.requestUpdate();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
get locale() {
|
|
12
|
+
return this._locale ?? getCurrentI18n();
|
|
13
|
+
}
|
|
14
|
+
set resourceStrings(value) {
|
|
15
|
+
if (this._resourceStrings !== value) {
|
|
16
|
+
this._resourceStrings = value;
|
|
17
|
+
this._host.requestUpdate();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
get resourceStrings() {
|
|
21
|
+
return this._resourceStrings ?? this._defaultResourceStrings;
|
|
22
|
+
}
|
|
23
|
+
constructor(host, config) {
|
|
24
|
+
this._host = host;
|
|
25
|
+
this._defaultEN = config.defaultEN;
|
|
26
|
+
this._resourceChangeCallback = config.onResourceChange;
|
|
27
|
+
this._defaultResourceStrings = this._getCurrentResourceStrings();
|
|
28
|
+
this._registerResources(this._defaultEN);
|
|
29
|
+
this._host.addController(this);
|
|
30
|
+
}
|
|
31
|
+
hostConnected() {
|
|
32
|
+
getI18nManager().addEventListener('onResourceChange', this);
|
|
33
|
+
}
|
|
34
|
+
hostDisconnected() {
|
|
35
|
+
getI18nManager().removeEventListener('onResourceChange', this);
|
|
36
|
+
}
|
|
37
|
+
handleEvent(event) {
|
|
38
|
+
this._defaultResourceStrings = this._getCurrentResourceStrings();
|
|
39
|
+
this._resourceChangeCallback?.(event);
|
|
40
|
+
this._host.requestUpdate();
|
|
41
|
+
}
|
|
42
|
+
_registerResources(resource) {
|
|
43
|
+
const convertedResource = convertToCoreResource(resource);
|
|
44
|
+
const manager = getI18nManager();
|
|
45
|
+
manager.registerI18n(convertedResource, manager.defaultLocale);
|
|
46
|
+
}
|
|
47
|
+
_getResourceMapForComponent() {
|
|
48
|
+
const keys = Object.keys(this._defaultEN);
|
|
49
|
+
if (keys.includes('last7Days')) {
|
|
50
|
+
return dateRangePickerResourcesMap;
|
|
51
|
+
}
|
|
52
|
+
if (keys.includes('selectMonth')) {
|
|
53
|
+
return calendarResourcesMap;
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
_getCurrentResourceStrings() {
|
|
58
|
+
const coreResourceStrings = getI18nManager().getCurrentResourceStrings(this.locale);
|
|
59
|
+
const resourceMap = this._getResourceMapForComponent();
|
|
60
|
+
if (!resourceMap) {
|
|
61
|
+
return coreResourceStrings;
|
|
62
|
+
}
|
|
63
|
+
const normalizedResourceStrings = {};
|
|
64
|
+
const defaultComponentKeys = Object.keys(this._defaultEN);
|
|
65
|
+
for (const igcKey of defaultComponentKeys) {
|
|
66
|
+
const coreKey = resourceMap.get(igcKey);
|
|
67
|
+
let resolvedValue = this._defaultEN[igcKey];
|
|
68
|
+
if (coreKey) {
|
|
69
|
+
if (coreKey.includes('getWeekLabel')) {
|
|
70
|
+
resolvedValue = getDisplayNamesFormatter().getWeekLabel(this.locale, {
|
|
71
|
+
style: 'short',
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
resolvedValue =
|
|
76
|
+
coreKey in coreResourceStrings
|
|
77
|
+
? coreResourceStrings[coreKey]
|
|
78
|
+
: this._defaultEN[igcKey];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
normalizedResourceStrings[igcKey] = resolvedValue;
|
|
82
|
+
}
|
|
83
|
+
return normalizedResourceStrings;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function addI18nController(host, config) {
|
|
87
|
+
return new I18nController(host, config);
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=i18n-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n-controller.js","sourceRoot":"","sources":["../../../../src/components/common/i18n/i18n-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,cAAc,GAGf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,YAAY,CAAC;AA6BpB,MAAM,cAAc;IAmBlB,IAAW,MAAM,CAAC,KAAyB;QACzC,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAC;YACjE,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC7B,CAAC;IACH,CAAC;IAOD,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,IAAI,cAAc,EAAE,CAAC;IAC1C,CAAC;IAMD,IAAW,eAAe,CAAC,KAAoB;QAC7C,IAAI,IAAI,CAAC,gBAAgB,KAAK,KAAK,EAAE,CAAC;YACpC,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;YAC9B,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC7B,CAAC;IACH,CAAC;IAGD,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,gBAAgB,IAAI,IA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/B,IAAwB,EACxB,MAA+B;IAE/B,OAAO,IAAI,cAAc,CAAI,IAAI,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import {\n getCurrentI18n,\n getDisplayNamesFormatter,\n getI18nManager,\n type IResourceChangeEventArgs,\n type IResourceStrings,\n} from 'igniteui-i18n-core';\nimport type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport {\n calendarResourcesMap,\n convertToCoreResource,\n dateRangePickerResourcesMap,\n} from './utils.js';\n\n/**\n * Defines the structure for the host element that will use this controller.\n * The host must be a Lit element (ReactiveControllerHost) and an HTMLElement.\n */\ninterface I18nControllerHost extends ReactiveControllerHost, HTMLElement {\n // Properties the host is expected to have/use, though they are managed by the controller.\n resourceStrings?: unknown;\n locale?: string;\n}\n\ntype ResourceChangeCallback = (\n event: CustomEvent<IResourceChangeEventArgs>\n) => unknown;\n\n/** Configuration object for the I18nController. */\ntype I18nControllerConfig<T extends object> = {\n /** The full default English resource strings object for the component. */\n defaultEN: T;\n /** An optional callback to execute when the global locale changes. */\n onResourceChange?: ResourceChangeCallback;\n};\n\n/**\n * Manages localization (i18n) for a Lit web component.\n * It handles the current locale, component-specific resource overrides,\n * and updates when the global localization state changes.\n */\nclass I18nController<T extends object> implements ReactiveController {\n //#region Internal properties and state\n\n private readonly _host: I18nControllerHost;\n private readonly _defaultEN: T;\n\n private _resourceChangeCallback?: ResourceChangeCallback;\n private _defaultResourceStrings: T;\n private _locale?: string;\n private _resourceStrings?: T;\n\n //#endregion\n\n //#region Public properties\n\n /**\n * Sets a custom locale that overrides the global one for this host component instance.\n * Setting a new locale triggers an update of the resource strings.\n */\n public set locale(value: string | undefined) {\n if (this._locale !== value) {\n this._locale = value;\n this._defaultResourceStrings = this._getCurrentResourceStrings();\n this._host.requestUpdate();\n }\n }\n\n /**\n * Gets the resolved locale for the host component.\n * This is the component's custom locale if set, otherwise it falls back to the\n * global locale.\n */\n public get locale(): string {\n return this._locale ?? getCurrentI18n();\n }\n\n /**\n * Sets custom resource string for component with this controller.\n * Gets the resolved resource string for component.\n */\n public set resourceStrings(value: T | undefined) {\n if (this._resourceStrings !== value) {\n this._resourceStrings = value;\n this._host.requestUpdate();\n }\n }\n\n /** Get resolved resource strings for component */\n public get resourceStrings(): T {\n return this._resourceStrings ?? this._defaultResourceStrings;\n }\n\n //#endregion\n\n //#region Life-cycle hooks and event listener\n\n constructor(host: I18nControllerHost, config: I18nControllerConfig<T>) {\n this._host = host;\n this._defaultEN = config.defaultEN;\n this._resourceChangeCallback = config.onResourceChange;\n\n this._defaultResourceStrings = this._getCurrentResourceStrings();\n this._registerResources(this._defaultEN);\n\n this._host.addController(this);\n }\n\n /** @internal */\n public hostConnected(): void {\n getI18nManager().addEventListener('onResourceChange', this);\n }\n\n /** @internal */\n public hostDisconnected(): void {\n getI18nManager().removeEventListener('onResourceChange', this);\n }\n\n /** @internal */\n public handleEvent(event: CustomEvent<IResourceChangeEventArgs>): void {\n this._defaultResourceStrings = this._getCurrentResourceStrings();\n this._resourceChangeCallback?.(event);\n this._host.requestUpdate();\n }\n\n //#endregion\n\n //#region Internal API\n\n /** Registers the default English resources with the global i18n manager. */\n private _registerResources(resource: T): void {\n const convertedResource = convertToCoreResource(resource);\n const manager = getI18nManager();\n\n manager.registerI18n(convertedResource, manager.defaultLocale);\n }\n\n /**\n * Helper to find the correct resource map based on the component's default resources (`#defaultEN`).\n * This relies on structural checking (the component's key names).\n */\n private _getResourceMapForComponent():\n | Map<string, string | undefined>\n | undefined {\n const keys = Object.keys(this._defaultEN);\n\n if (keys.includes('last7Days')) {\n return dateRangePickerResourcesMap;\n }\n\n if (keys.includes('selectMonth')) {\n return calendarResourcesMap;\n }\n\n return undefined;\n }\n\n /**\n * Gets the current, locale-specific resource strings for the component.\n * The logic maps component keys (from defaultEN) to core library keys\n * and retrieves the localized string from the i18n manager.\n *\n * Result is truncated, containing only relevant locale strings.\n */\n private _getCurrentResourceStrings(): T {\n const coreResourceStrings = getI18nManager().getCurrentResourceStrings(\n this.locale\n );\n const resourceMap = this._getResourceMapForComponent();\n\n if (!resourceMap) {\n return coreResourceStrings as T;\n }\n\n const normalizedResourceStrings: T = {} as T;\n const defaultComponentKeys = Object.keys(this._defaultEN) as (keyof T)[];\n\n for (const igcKey of defaultComponentKeys) {\n const coreKey = resourceMap.get(igcKey as string);\n let resolvedValue: T[keyof T] = this._defaultEN[igcKey];\n\n if (coreKey) {\n if (coreKey.includes('getWeekLabel')) {\n resolvedValue = getDisplayNamesFormatter().getWeekLabel(this.locale, {\n style: 'short',\n }) as T[keyof T];\n } else {\n resolvedValue =\n coreKey in coreResourceStrings\n ? (coreResourceStrings[\n coreKey as keyof IResourceStrings\n ] as T[keyof T])\n : this._defaultEN[igcKey];\n }\n }\n\n normalizedResourceStrings[igcKey] = resolvedValue;\n }\n\n return normalizedResourceStrings;\n }\n\n //#endregion\n}\n\n/** Factory function to create and attach the I18nController to a host. */\nexport function addI18nController<T extends object>(\n host: I18nControllerHost,\n config: I18nControllerConfig<T>\n): I18nController<T> {\n return new I18nController<T>(host, config);\n}\n\nexport type { I18nController };\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IResourceStrings } from 'igniteui-i18n-core';
|
|
2
|
+
import type { IgcCalendarResourceStrings } from './EN/calendar.resources.js';
|
|
3
|
+
import type { IgcDateRangePickerResourceStrings } from './EN/date-range-picker.resources.js';
|
|
4
|
+
export declare const validationResourcesKeys: {
|
|
5
|
+
readonly minLength: "min_length_validation_error";
|
|
6
|
+
readonly maxLength: "max_length_validation_error";
|
|
7
|
+
readonly required: "required_validation_error";
|
|
8
|
+
readonly pattern: "pattern_validation_error";
|
|
9
|
+
readonly mask: "mask_validation_error";
|
|
10
|
+
readonly min: "min_validation_error";
|
|
11
|
+
readonly max: "max_validation_error";
|
|
12
|
+
readonly email: "email_validation_error";
|
|
13
|
+
readonly url: "url_validation_error";
|
|
14
|
+
readonly disabledDate: "disabled_date_validation_error";
|
|
15
|
+
};
|
|
16
|
+
export declare const calendarResourcesMap: Map<keyof IgcCalendarResourceStrings, string | undefined>;
|
|
17
|
+
export declare const dateRangePickerResourcesMap: Map<keyof IgcDateRangePickerResourceStrings, string | undefined>;
|
|
18
|
+
export declare function convertToIgcResource<T extends object>(resource: IResourceStrings): T;
|
|
19
|
+
export declare function convertToCoreResource<T>(resource: T): IResourceStrings;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { isObject, isString } from '../util.js';
|
|
2
|
+
export const validationResourcesKeys = {
|
|
3
|
+
minLength: 'min_length_validation_error',
|
|
4
|
+
maxLength: 'max_length_validation_error',
|
|
5
|
+
required: 'required_validation_error',
|
|
6
|
+
pattern: 'pattern_validation_error',
|
|
7
|
+
mask: 'mask_validation_error',
|
|
8
|
+
min: 'min_validation_error',
|
|
9
|
+
max: 'max_validation_error',
|
|
10
|
+
email: 'email_validation_error',
|
|
11
|
+
url: 'url_validation_error',
|
|
12
|
+
disabledDate: 'disabled_date_validation_error',
|
|
13
|
+
};
|
|
14
|
+
export const calendarResourcesMap = new Map([
|
|
15
|
+
['selectMonth', 'calendar_select_month'],
|
|
16
|
+
['selectYear', 'calendar_select_year'],
|
|
17
|
+
['selectDate', 'calendar_select_date'],
|
|
18
|
+
['selectRange', 'calendar_range_placeholder'],
|
|
19
|
+
['selectedDate', undefined],
|
|
20
|
+
['startDate', 'calendar_range_label_start'],
|
|
21
|
+
['endDate', 'calendar_range_label_end'],
|
|
22
|
+
['previousMonth', 'calendar_previous_month'],
|
|
23
|
+
['nextMonth', 'calendar_next_month'],
|
|
24
|
+
['previousYear', 'calendar_previous_year'],
|
|
25
|
+
['nextYear', 'calendar_next_year'],
|
|
26
|
+
['previousYears', 'calendar_previous_years'],
|
|
27
|
+
['nextYears', 'calendar_next_years'],
|
|
28
|
+
['weekLabel', 'i18n/getWeekLabel'],
|
|
29
|
+
]);
|
|
30
|
+
export const dateRangePickerResourcesMap = new Map([
|
|
31
|
+
['separator', 'date_range_picker_date_separator'],
|
|
32
|
+
['done', 'date_range_picker_done_button'],
|
|
33
|
+
['cancel', 'date_range_picker_cancel_button'],
|
|
34
|
+
['last7Days', 'date_range_picker_last7Days'],
|
|
35
|
+
['last30Days', 'date_range_picker_last30Days'],
|
|
36
|
+
['currentMonth', 'date_range_picker_currentMonth'],
|
|
37
|
+
['yearToDate', 'date_range_picker_yearToDate'],
|
|
38
|
+
...calendarResourcesMap.entries(),
|
|
39
|
+
]);
|
|
40
|
+
function isCalendarResource(resource) {
|
|
41
|
+
return (isObject(resource) &&
|
|
42
|
+
'selectMonth' in resource &&
|
|
43
|
+
!isDateRangePickerResource(resource));
|
|
44
|
+
}
|
|
45
|
+
function isDateRangePickerResource(resource) {
|
|
46
|
+
return isObject(resource) && 'last7Days' in resource;
|
|
47
|
+
}
|
|
48
|
+
function getResourceMap(resource) {
|
|
49
|
+
if (isCalendarResource(resource)) {
|
|
50
|
+
return calendarResourcesMap;
|
|
51
|
+
}
|
|
52
|
+
if (isDateRangePickerResource(resource)) {
|
|
53
|
+
return dateRangePickerResourcesMap;
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
function getResourceMapForCore(resource) {
|
|
58
|
+
if ('date_range_picker_last7Days' in resource) {
|
|
59
|
+
return dateRangePickerResourcesMap;
|
|
60
|
+
}
|
|
61
|
+
if ('calendar_select_month' in resource) {
|
|
62
|
+
return calendarResourcesMap;
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
export function convertToIgcResource(resource) {
|
|
67
|
+
const result = {};
|
|
68
|
+
const resourceMap = getResourceMapForCore(resource);
|
|
69
|
+
if (!resourceMap) {
|
|
70
|
+
return resource;
|
|
71
|
+
}
|
|
72
|
+
for (const [componentKey, coreKey] of resourceMap) {
|
|
73
|
+
if (coreKey && coreKey in resource) {
|
|
74
|
+
const coreValue = resource[coreKey];
|
|
75
|
+
if (isString(coreValue)) {
|
|
76
|
+
result[componentKey] = coreValue;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
export function convertToCoreResource(resource) {
|
|
83
|
+
const result = {};
|
|
84
|
+
const resourceMap = getResourceMap(resource);
|
|
85
|
+
if (resourceMap) {
|
|
86
|
+
for (const [key, coreKey] of resourceMap) {
|
|
87
|
+
if (coreKey) {
|
|
88
|
+
const value = resource[key];
|
|
89
|
+
if (isString(value)) {
|
|
90
|
+
result[coreKey] = value;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return resource;
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/components/common/i18n/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAIhD,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,SAAS,EAAE,6BAA6B;IACxC,SAAS,EAAE,6BAA6B;IACxC,QAAQ,EAAE,2BAA2B;IACrC,OAAO,EAAE,0BAA0B;IACnC,IAAI,EAAE,uBAAuB;IAC7B,GAAG,EAAE,sBAAsB;IAC3B,GAAG,EAAE,sBAAsB;IAC3B,KAAK,EAAE,wBAAwB;IAC/B,GAAG,EAAE,sBAAsB;IAC3B,YAAY,EAAE,gCAAgC;CACtC,CAAC;AAEX,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAGzC;IACA,CAAC,aAAa,EAAE,uBAAuB,CAAC;IACxC,CAAC,YAAY,EAAE,sBAAsB,CAAC;IACtC,CAAC,YAAY,EAAE,sBAAsB,CAAC;IACtC,CAAC,aAAa,EAAE,4BAA4B,CAAC;IAC7C,CAAC,cAAc,EAAE,SAAS,CAAC;IAC3B,CAAC,W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CAAC,GAAG,KAAK,CAAC;gBACpD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,QAA4B,CAAC;IACtC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { IResourceStrings } from 'igniteui-i18n-core';\nimport { isObject, isString } from '../util.js';\nimport type { IgcCalendarResourceStrings } from './EN/calendar.resources.js';\nimport type { IgcDateRangePickerResourceStrings } from './EN/date-range-picker.resources.js';\n\nexport const validationResourcesKeys = {\n minLength: 'min_length_validation_error',\n maxLength: 'max_length_validation_error',\n required: 'required_validation_error',\n pattern: 'pattern_validation_error',\n mask: 'mask_validation_error',\n min: 'min_validation_error',\n max: 'max_validation_error',\n email: 'email_validation_error',\n url: 'url_validation_error',\n disabledDate: 'disabled_date_validation_error',\n} as const;\n\nexport const calendarResourcesMap = new Map<\n keyof IgcCalendarResourceStrings,\n string | undefined\n>([\n ['selectMonth', 'calendar_select_month'],\n ['selectYear', 'calendar_select_year'],\n ['selectDate', 'calendar_select_date'],\n ['selectRange', 'calendar_range_placeholder'],\n ['selectedDate', undefined], // This one seems not to be in use anyway\n ['startDate', 'calendar_range_label_start'],\n ['endDate', 'calendar_range_label_end'],\n ['previousMonth', 'calendar_previous_month'],\n ['nextMonth', 'calendar_next_month'],\n ['previousYear', 'calendar_previous_year'],\n ['nextYear', 'calendar_next_year'],\n ['previousYears', 'calendar_previous_years'],\n ['nextYears', 'calendar_next_years'],\n ['weekLabel', 'i18n/getWeekLabel'],\n]);\n\nexport const dateRangePickerResourcesMap = new Map<\n keyof IgcDateRangePickerResourceStrings,\n string | undefined\n>([\n ['separator', 'date_range_picker_date_separator'],\n ['done', 'date_range_picker_done_button'],\n ['cancel', 'date_range_picker_cancel_button'],\n ['last7Days', 'date_range_picker_last7Days'],\n ['last30Days', 'date_range_picker_last30Days'],\n ['currentMonth', 'date_range_picker_currentMonth'],\n ['yearToDate', 'date_range_picker_yearToDate'],\n ...(\n calendarResourcesMap as Map<\n keyof IgcDateRangePickerResourceStrings,\n string | undefined\n >\n ).entries(),\n]);\n\nfunction isCalendarResource(\n resource: unknown\n): resource is IgcCalendarResourceStrings {\n return (\n isObject(resource) &&\n 'selectMonth' in resource &&\n !isDateRangePickerResource(resource)\n );\n}\n\nfunction isDateRangePickerResource(\n resource: unknown\n): resource is IgcDateRangePickerResourceStrings {\n return isObject(resource) && 'last7Days' in resource;\n}\n\nfunction getResourceMap<T>(\n resource: T\n): Map<string, string | undefined> | undefined {\n if (isCalendarResource(resource)) {\n return calendarResourcesMap;\n }\n\n if (isDateRangePickerResource(resource)) {\n return dateRangePickerResourcesMap;\n }\n\n return undefined;\n}\n\nfunction getResourceMapForCore<T extends IResourceStrings>(\n resource: T\n): Map<string, string | undefined> | undefined {\n if ('date_range_picker_last7Days' in resource) {\n return dateRangePickerResourcesMap;\n }\n\n if ('calendar_select_month' in resource) {\n return calendarResourcesMap;\n }\n\n return undefined;\n}\n\nexport function convertToIgcResource<T extends object>(\n resource: IResourceStrings\n): T {\n const result = {} as T;\n const resourceMap = getResourceMapForCore(resource);\n\n if (!resourceMap) {\n return resource as T;\n }\n\n for (const [componentKey, coreKey] of resourceMap) {\n if (coreKey && coreKey in resource) {\n const coreValue = resource[coreKey as keyof IResourceStrings];\n\n if (isString(coreValue)) {\n result[componentKey as keyof T] = coreValue as T[keyof T];\n }\n }\n }\n\n return result;\n}\n\nexport function convertToCoreResource<T>(resource: T): IResourceStrings {\n const result: IResourceStrings = {};\n const resourceMap = getResourceMap(resource);\n\n if (resourceMap) {\n for (const [key, coreKey] of resourceMap) {\n if (coreKey) {\n const value = resource[key as keyof T];\n if (isString(value)) {\n result[coreKey as keyof IResourceStrings] = value;\n }\n }\n }\n } else {\n return resource as IResourceStrings;\n }\n\n return result;\n}\n"]}
|
|
@@ -4,8 +4,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
+
import { ValidationResourceStringsEN, } from 'igniteui-i18n-core';
|
|
7
8
|
import { property } from 'lit/decorators.js';
|
|
8
9
|
import { addInternalsController } from '../../controllers/internals.js';
|
|
10
|
+
import { addI18nController } from '../../i18n/i18n-controller.js';
|
|
9
11
|
import { addSafeEventListener, isFunction, isString } from '../../util.js';
|
|
10
12
|
import { InternalInvalidEvent, InternalResetEvent, } from './types.js';
|
|
11
13
|
const INVALID_STATE = 'ig-invalid';
|
|
@@ -60,9 +62,18 @@ function BaseFormAssociated(base) {
|
|
|
60
62
|
get willValidate() {
|
|
61
63
|
return this.__internals.willValidate;
|
|
62
64
|
}
|
|
65
|
+
set resourceStrings(value) {
|
|
66
|
+
this.__i18nController.resourceStrings = value;
|
|
67
|
+
}
|
|
68
|
+
get resourceStrings() {
|
|
69
|
+
return this.__i18nController.resourceStrings;
|
|
70
|
+
}
|
|
63
71
|
constructor(...args) {
|
|
64
72
|
super(args);
|
|
65
73
|
this.__internals = addInternalsController(this);
|
|
74
|
+
this.__i18nController = addI18nController(this, {
|
|
75
|
+
defaultEN: ValidationResourceStringsEN,
|
|
76
|
+
});
|
|
66
77
|
this._isFormSubmit = false;
|
|
67
78
|
this._isInternalValidation = false;
|
|
68
79
|
this._touched = false;
|
|
@@ -107,9 +118,15 @@ function BaseFormAssociated(base) {
|
|
|
107
118
|
validity[validator.key] = !isValid;
|
|
108
119
|
if (!isValid) {
|
|
109
120
|
validationFailed = true;
|
|
110
|
-
|
|
111
|
-
? validator.
|
|
112
|
-
: validator.
|
|
121
|
+
const resourceKey = (isFunction(validator.messageResourceKey)
|
|
122
|
+
? validator.messageResourceKey(this)
|
|
123
|
+
: validator.messageResourceKey);
|
|
124
|
+
message =
|
|
125
|
+
this.resourceStrings[resourceKey] ??
|
|
126
|
+
"Couldn't retrieve validation resource string!";
|
|
127
|
+
if (isFunction(validator.messageFormat)) {
|
|
128
|
+
message = validator.messageFormat(message, this);
|
|
129
|
+
}
|
|
113
130
|
}
|
|
114
131
|
}
|
|
115
132
|
this._invalid = validationFailed;
|
|
@@ -203,6 +220,9 @@ function BaseFormAssociated(base) {
|
|
|
203
220
|
__decorate([
|
|
204
221
|
property({ type: Boolean })
|
|
205
222
|
], BaseFormAssociatedElement.prototype, "invalid", null);
|
|
223
|
+
__decorate([
|
|
224
|
+
property({ attribute: false })
|
|
225
|
+
], BaseFormAssociatedElement.prototype, "resourceStrings", null);
|
|
206
226
|
return BaseFormAssociatedElement;
|
|
207
227
|
}
|
|
208
228
|
export function FormAssociatedMixin(base) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"associated.js","sourceRoot":"","sources":["../../../../../src/components/common/mixins/forms/associated.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI3E,OAAO,EAKL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF,SAAS,oBAAoB,CAAC,IAAgB;IAC5C,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAgB;IAC1C,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,kBAAkB,CAAoC,IAA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,cAAc,CAAC;gBACnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;QAED,IAAW,cAAc;YACvB,OAAO,IAAI,CAAC,UAAU,CAAC,YAAuB,CAAC;QACjD,CAAC;QAEe,wBAAwB,CACtC,IAAY,EACZ,IAAmB,EACnB,OAAsB;YAEtB,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YACpD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;KACF;IAxBC;QADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uEAS9B;IAkBH,OAAO,6BACJ,CAAC;AACN,CAAC","sourcesContent":["import type { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { addInternalsController } from '../../controllers/internals.js';\nimport { addSafeEventListener, isFunction, isString } from '../../util.js';\nimport type { Validator } from '../../validators.js';\nimport type { Constructor } from '../constructor.js';\nimport type { FormValue } from './form-value.js';\nimport {\n type FormAssociatedCheckboxElementInterface,\n type FormAssociatedElementInterface,\n type FormRestoreMode,\n type FormValueType,\n InternalInvalidEvent,\n InternalResetEvent,\n} from './types.js';\n\nconst INVALID_STATE = 'ig-invalid';\n\nconst eventOptions = {\n bubbles: false,\n composed: false,\n};\n\nfunction emitFormInvalidEvent(host: LitElement): void {\n host.dispatchEvent(new CustomEvent(InternalInvalidEvent, eventOptions));\n}\n\nfunction emitFormResetEvent(host: LitElement): void {\n host.dispatchEvent(new CustomEvent(InternalResetEvent, eventOptions));\n}\n\nfunction BaseFormAssociated<T extends Constructor<LitElement>>(base: T) {\n class BaseFormAssociatedElement extends base {\n public static readonly formAssociated = true;\n\n //#region Internal state and properties\n\n private readonly __internals = addInternalsController(this);\n protected readonly _formValue!: FormValue<unknown>;\n\n private _isFormSubmit = false;\n private _isInternalValidation = false;\n private _touched = false;\n private _isExternalInvalid = false;\n\n private get _hasUserInteraction(): boolean {\n return this._touched || this._isFormSubmit;\n }\n\n private get _shouldApplyStyles(): boolean {\n if (this._isExternalInvalid) {\n return true;\n }\n\n return (\n this._invalid && this._hasUserInteraction && !this._isInternalValidation\n );\n }\n\n protected _disabled = false;\n protected _invalid = false;\n protected _pristine = true;\n\n protected get __validators(): Validator[] {\n return [];\n }\n\n //#endregion\n\n //#region Public properties and attributes\n\n /**\n * The name attribute of the control.\n * @attr\n */\n @property({ reflect: true })\n public name!: string;\n\n /**\n * The disabled state of the component.\n * @attr\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public set disabled(value: boolean) {\n this._disabled = value;\n this.toggleAttribute('disabled', Boolean(this._disabled));\n }\n\n public get disabled(): boolean {\n return this._disabled;\n }\n\n /**\n * Sets the control into invalid state (visual state only).\n * @attr\n * @default false\n */\n @property({ type: Boolean })\n public set invalid(value: boolean) {\n this._isExternalInvalid = value;\n this._setInvalidStyles();\n }\n\n public get invalid(): boolean {\n return this._isExternalInvalid || this._shouldApplyStyles;\n }\n\n /** Returns the HTMLFormElement associated with this element. */\n public get form(): HTMLFormElement | null {\n return this.__internals.form;\n }\n\n /**\n * Returns a ValidityState object which represents the different validity states\n * the element can be in, with respect to constraint validation.\n */\n public get validity(): ValidityState {\n return this.__internals.validity;\n }\n\n /** A string containing the validation message of this element. */\n public get validationMessage(): string {\n return this.__internals.validationMessage;\n }\n\n /**\n * A boolean value which returns true if the element is a submittable element\n * that is a candidate for constraint validation.\n */\n public get willValidate(): boolean {\n return this.__internals.willValidate;\n }\n\n //#endregion\n\n //#region Life-cycle hooks\n\n constructor(...args: any[]) {\n super(args);\n addSafeEventListener(this, 'invalid', this._handleInvalid);\n }\n\n /** @internal */\n public override connectedCallback(): void {\n super.connectedCallback();\n this._pristine = true;\n this._touched = false;\n this._validate();\n }\n\n //#endregion\n\n //#region Form value and validation states\n\n private async _handleInvalid(event: Event): Promise<void> {\n event.preventDefault();\n this._invalid = true;\n\n if (this._isInternalValidation) {\n this._isInternalValidation = false;\n } else {\n this._isFormSubmit = true;\n emitFormInvalidEvent(this);\n }\n\n this._setInvalidStyles();\n this.requestUpdate();\n\n if (this._isFormSubmit) {\n await this.updateComplete;\n this._isFormSubmit = false;\n }\n }\n\n private _setInvalidStyles(): void {\n this.__internals.setState(INVALID_STATE, this._shouldApplyStyles);\n }\n\n private __runValidators() {\n const validity: ValidityStateFlags = {};\n let message = '';\n let validationFailed = false;\n\n for (const validator of this.__validators) {\n const isValid = validator.isValid(this);\n\n validity[validator.key] = !isValid;\n\n if (!isValid) {\n validationFailed = true;\n message = isFunction(validator.message)\n ? validator.message(this)\n : validator.message;\n }\n }\n\n this._invalid = validationFailed;\n\n return { validity, message };\n }\n\n /**\n * Executes the component validators and updates the internal validity state.\n */\n protected _validate(userMessage?: string): void {\n let { validity, message } = this.__runValidators();\n const hasCustomError = this.validity.customError;\n\n // valueMissing has precedence over the other validators aside from customError\n if (validity.valueMissing) {\n validity = {\n valueMissing: true,\n customError: hasCustomError,\n };\n }\n\n if (hasCustomError && userMessage === undefined) {\n // Internal validation cycle after the user has called setCustomValidity()\n // with some message. Keep the customError flag and the passed in message.\n validity.customError = true;\n message = this.validationMessage;\n } else if (hasCustomError && userMessage === '') {\n // setCustomValidity with an empty message.\n validity.customError = false;\n } else if (userMessage && userMessage !== '') {\n // setCustomValidity with a message.\n validity.customError = true;\n message = userMessage;\n }\n\n this.__internals.setValidity(validity, message);\n this._isInternalValidation = true;\n this._invalid = !this.__internals.checkValidity();\n }\n\n protected _handleBlur(): void {\n this._setTouchedState();\n this._validate();\n }\n\n protected _setTouchedState(): void {\n if (!this._touched) {\n this._touched = true;\n }\n }\n\n protected _setDefaultValue(current: string | null): void {\n this._formValue.defaultValue = current;\n }\n\n protected _restoreDefaultValue(): void {\n const value = this._formValue.value;\n this._formValue.setValueAndFormState(this._formValue.defaultValue);\n this.requestUpdate('value', value);\n }\n\n protected _setFormValue(value: FormValueType, state?: FormValueType): void {\n this._pristine = false;\n this.__internals.setFormValue(value, state);\n this._validate();\n this._setInvalidStyles();\n }\n\n //#region Form associated callback hooks\n\n protected formAssociatedCallback(_form: HTMLFormElement): void {}\n\n protected formDisabledCallback(state: boolean): void {\n this._disabled = state;\n this.requestUpdate();\n }\n\n protected formResetCallback(): void {\n this._restoreDefaultValue();\n this._pristine = true;\n this._touched = false;\n this._invalid = false;\n this._setInvalidStyles();\n emitFormResetEvent(this);\n }\n\n /* c8 ignore next 4 */\n protected formStateRestoreCallback(\n _state: FormValueType,\n _mode: FormRestoreMode\n ): void {}\n\n //#endregion\n\n //#region Public API\n\n /** Checks for validity of the control and shows the browser message if it invalid. */\n public reportValidity(): boolean {\n const state = this.__internals.reportValidity();\n this._invalid = !state;\n return state;\n }\n\n /** Checks for validity of the control and emits the invalid event if it invalid. */\n public checkValidity(): boolean {\n this._isInternalValidation = true;\n const state = this.__internals.checkValidity();\n this._invalid = !state;\n return state;\n }\n\n /**\n * Sets a custom validation message for the control.\n * As long as `message` is not empty, the control is considered invalid.\n */\n public setCustomValidity(message: string): void {\n this._validate(message);\n this._isInternalValidation = message === '';\n this._setInvalidStyles();\n this.requestUpdate();\n }\n\n //#endregion\n }\n return BaseFormAssociatedElement as Constructor<BaseFormAssociatedElement> &\n T;\n}\n\n/**\n * Mixes the passed in class and turns it into a form associated custom element.\n */\nexport function FormAssociatedMixin<T extends Constructor<LitElement>>(\n base: T\n) {\n class FormAssociatedElement extends BaseFormAssociated(base) {\n /* blazorCSSuppress */\n @property({ attribute: false })\n public set defaultValue(value: unknown) {\n this._formValue.defaultValue = value;\n\n if (this._pristine && 'value' in this) {\n this.value = this.defaultValue;\n this._pristine = true;\n this._validate();\n }\n }\n\n public get defaultValue(): unknown {\n return this._formValue.defaultValue;\n }\n\n public override attributeChangedCallback(\n name: string,\n prev: string | null,\n current: string | null\n ): void {\n super.attributeChangedCallback(name, prev, current);\n if (name === 'value') {\n this._setDefaultValue(current);\n }\n }\n }\n\n return FormAssociatedElement as unknown as Constructor<FormAssociatedElementInterface> &\n T;\n}\n\n/**\n * Mixes the passed in class and turns it into a form associated custom element.\n */\nexport function FormAssociatedCheckboxMixin<T extends Constructor<LitElement>>(\n base: T\n) {\n class FormAssociatedCheckboxElement extends BaseFormAssociated(base) {\n /* blazorCSSuppress */\n @property({ attribute: false })\n public set defaultChecked(value: boolean) {\n this._formValue.defaultValue = value;\n\n if (this._pristine && 'checked' in this) {\n this.checked = this.defaultChecked;\n this._pristine = true;\n this._validate();\n }\n }\n\n public get defaultChecked(): boolean {\n return this._formValue.defaultValue as boolean;\n }\n\n public override attributeChangedCallback(\n name: string,\n prev: string | null,\n current: string | null\n ): void {\n super.attributeChangedCallback(name, prev, current);\n if (name === 'checked') {\n this._setDefaultValue(isString(current) ? 'true' : null);\n }\n }\n }\n\n return FormAssociatedCheckboxElement as unknown as Constructor<FormAssociatedCheckboxElementInterface> &\n T;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"associated.js","sourceRoot":"","sources":["../../../../../src/components/common/mixins/forms/associated.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAEL,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI3E,OAAO,EAKL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE,KA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AAE,OAAO,CAAC,CAAC;YACpD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;KACF;IAxBC;QADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uEAS9B;IAkBH,OAAO,6BACJ,CAAC;AACN,CAAC","sourcesContent":["import {\n type IValidationResourceStrings,\n ValidationResourceStringsEN,\n} from 'igniteui-i18n-core';\nimport type { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { addInternalsController } from '../../controllers/internals.js';\nimport { addI18nController } from '../../i18n/i18n-controller.js';\nimport { addSafeEventListener, isFunction, isString } from '../../util.js';\nimport type { Validator } from '../../validators.js';\nimport type { Constructor } from '../constructor.js';\nimport type { FormValue } from './form-value.js';\nimport {\n type FormAssociatedCheckboxElementInterface,\n type FormAssociatedElementInterface,\n type FormRestoreMode,\n type FormValueType,\n InternalInvalidEvent,\n InternalResetEvent,\n} from './types.js';\n\nconst INVALID_STATE = 'ig-invalid';\n\nconst eventOptions = {\n bubbles: false,\n composed: false,\n};\n\nfunction emitFormInvalidEvent(host: LitElement): void {\n host.dispatchEvent(new CustomEvent(InternalInvalidEvent, eventOptions));\n}\n\nfunction emitFormResetEvent(host: LitElement): void {\n host.dispatchEvent(new CustomEvent(InternalResetEvent, eventOptions));\n}\n\nfunction BaseFormAssociated<T extends Constructor<LitElement>>(base: T) {\n class BaseFormAssociatedElement extends base {\n public static readonly formAssociated = true;\n\n //#region Internal state and properties\n\n private readonly __internals = addInternalsController(this);\n private readonly __i18nController =\n addI18nController<IValidationResourceStrings>(this, {\n defaultEN: ValidationResourceStringsEN,\n });\n protected readonly _formValue!: FormValue<unknown>;\n\n private _isFormSubmit = false;\n private _isInternalValidation = false;\n private _touched = false;\n private _isExternalInvalid = false;\n\n private get _hasUserInteraction(): boolean {\n return this._touched || this._isFormSubmit;\n }\n\n private get _shouldApplyStyles(): boolean {\n if (this._isExternalInvalid) {\n return true;\n }\n\n return (\n this._invalid && this._hasUserInteraction && !this._isInternalValidation\n );\n }\n\n protected _disabled = false;\n protected _invalid = false;\n protected _pristine = true;\n\n protected get __validators(): Validator[] {\n return [];\n }\n\n //#endregion\n\n //#region Public properties and attributes\n\n /**\n * The name attribute of the control.\n * @attr\n */\n @property({ reflect: true })\n public name!: string;\n\n /**\n * The disabled state of the component.\n * @attr\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public set disabled(value: boolean) {\n this._disabled = value;\n this.toggleAttribute('disabled', Boolean(this._disabled));\n }\n\n public get disabled(): boolean {\n return this._disabled;\n }\n\n /**\n * Sets the control into invalid state (visual state only).\n * @attr\n * @default false\n */\n @property({ type: Boolean })\n public set invalid(value: boolean) {\n this._isExternalInvalid = value;\n this._setInvalidStyles();\n }\n\n public get invalid(): boolean {\n return this._isExternalInvalid || this._shouldApplyStyles;\n }\n\n /** Returns the HTMLFormElement associated with this element. */\n public get form(): HTMLFormElement | null {\n return this.__internals.form;\n }\n\n /**\n * Returns a ValidityState object which represents the different validity states\n * the element can be in, with respect to constraint validation.\n */\n public get validity(): ValidityState {\n return this.__internals.validity;\n }\n\n /** A string containing the validation message of this element. */\n public get validationMessage(): string {\n return this.__internals.validationMessage;\n }\n\n /**\n * A boolean value which returns true if the element is a submittable element\n * that is a candidate for constraint validation.\n */\n public get willValidate(): boolean {\n return this.__internals.willValidate;\n }\n\n /**\n * The resource strings for localization.\n */\n @property({ attribute: false })\n public set resourceStrings(value: IValidationResourceStrings) {\n this.__i18nController.resourceStrings = value;\n }\n\n public get resourceStrings(): IValidationResourceStrings {\n return this.__i18nController.resourceStrings;\n }\n //#endregion\n\n //#region Life-cycle hooks\n\n constructor(...args: any[]) {\n super(args);\n addSafeEventListener(this, 'invalid', this._handleInvalid);\n }\n\n /** @internal */\n public override connectedCallback(): void {\n super.connectedCallback();\n this._pristine = true;\n this._touched = false;\n this._validate();\n }\n\n //#endregion\n\n //#region Form value and validation states\n\n private async _handleInvalid(event: Event): Promise<void> {\n event.preventDefault();\n this._invalid = true;\n\n if (this._isInternalValidation) {\n this._isInternalValidation = false;\n } else {\n this._isFormSubmit = true;\n emitFormInvalidEvent(this);\n }\n\n this._setInvalidStyles();\n this.requestUpdate();\n\n if (this._isFormSubmit) {\n await this.updateComplete;\n this._isFormSubmit = false;\n }\n }\n\n private _setInvalidStyles(): void {\n this.__internals.setState(INVALID_STATE, this._shouldApplyStyles);\n }\n\n private __runValidators() {\n const validity: ValidityStateFlags = {};\n let message = '';\n let validationFailed = false;\n\n for (const validator of this.__validators) {\n const isValid = validator.isValid(this);\n\n validity[validator.key] = !isValid;\n\n if (!isValid) {\n validationFailed = true;\n const resourceKey = (\n isFunction(validator.messageResourceKey)\n ? validator.messageResourceKey(this)\n : validator.messageResourceKey\n ) as keyof IValidationResourceStrings;\n\n message =\n this.resourceStrings[resourceKey] ??\n \"Couldn't retrieve validation resource string!\";\n if (isFunction(validator.messageFormat)) {\n message = validator.messageFormat(message, this);\n }\n }\n }\n\n this._invalid = validationFailed;\n\n return { validity, message };\n }\n\n /**\n * Executes the component validators and updates the internal validity state.\n */\n protected _validate(userMessage?: string): void {\n let { validity, message } = this.__runValidators();\n const hasCustomError = this.validity.customError;\n\n // valueMissing has precedence over the other validators aside from customError\n if (validity.valueMissing) {\n validity = {\n valueMissing: true,\n customError: hasCustomError,\n };\n }\n\n if (hasCustomError && userMessage === undefined) {\n // Internal validation cycle after the user has called setCustomValidity()\n // with some message. Keep the customError flag and the passed in message.\n validity.customError = true;\n message = this.validationMessage;\n } else if (hasCustomError && userMessage === '') {\n // setCustomValidity with an empty message.\n validity.customError = false;\n } else if (userMessage && userMessage !== '') {\n // setCustomValidity with a message.\n validity.customError = true;\n message = userMessage;\n }\n\n this.__internals.setValidity(validity, message);\n this._isInternalValidation = true;\n this._invalid = !this.__internals.checkValidity();\n }\n\n protected _handleBlur(): void {\n this._setTouchedState();\n this._validate();\n }\n\n protected _setTouchedState(): void {\n if (!this._touched) {\n this._touched = true;\n }\n }\n\n protected _setDefaultValue(current: string | null): void {\n this._formValue.defaultValue = current;\n }\n\n protected _restoreDefaultValue(): void {\n const value = this._formValue.value;\n this._formValue.setValueAndFormState(this._formValue.defaultValue);\n this.requestUpdate('value', value);\n }\n\n protected _setFormValue(value: FormValueType, state?: FormValueType): void {\n this._pristine = false;\n this.__internals.setFormValue(value, state);\n this._validate();\n this._setInvalidStyles();\n }\n\n //#region Form associated callback hooks\n\n protected formAssociatedCallback(_form: HTMLFormElement): void {}\n\n protected formDisabledCallback(state: boolean): void {\n this._disabled = state;\n this.requestUpdate();\n }\n\n protected formResetCallback(): void {\n this._restoreDefaultValue();\n this._pristine = true;\n this._touched = false;\n this._invalid = false;\n this._setInvalidStyles();\n emitFormResetEvent(this);\n }\n\n /* c8 ignore next 4 */\n protected formStateRestoreCallback(\n _state: FormValueType,\n _mode: FormRestoreMode\n ): void {}\n\n //#endregion\n\n //#region Public API\n\n /** Checks for validity of the control and shows the browser message if it invalid. */\n public reportValidity(): boolean {\n const state = this.__internals.reportValidity();\n this._invalid = !state;\n return state;\n }\n\n /** Checks for validity of the control and emits the invalid event if it invalid. */\n public checkValidity(): boolean {\n this._isInternalValidation = true;\n const state = this.__internals.checkValidity();\n this._invalid = !state;\n return state;\n }\n\n /**\n * Sets a custom validation message for the control.\n * As long as `message` is not empty, the control is considered invalid.\n */\n public setCustomValidity(message: string): void {\n this._validate(message);\n this._isInternalValidation = message === '';\n this._setInvalidStyles();\n this.requestUpdate();\n }\n\n //#endregion\n }\n return BaseFormAssociatedElement as Constructor<BaseFormAssociatedElement> &\n T;\n}\n\n/**\n * Mixes the passed in class and turns it into a form associated custom element.\n */\nexport function FormAssociatedMixin<T extends Constructor<LitElement>>(\n base: T\n) {\n class FormAssociatedElement extends BaseFormAssociated(base) {\n /* blazorCSSuppress */\n @property({ attribute: false })\n public set defaultValue(value: unknown) {\n this._formValue.defaultValue = value;\n\n if (this._pristine && 'value' in this) {\n this.value = this.defaultValue;\n this._pristine = true;\n this._validate();\n }\n }\n\n public get defaultValue(): unknown {\n return this._formValue.defaultValue;\n }\n\n public override attributeChangedCallback(\n name: string,\n prev: string | null,\n current: string | null\n ): void {\n super.attributeChangedCallback(name, prev, current);\n if (name === 'value') {\n this._setDefaultValue(current);\n }\n }\n }\n\n return FormAssociatedElement as unknown as Constructor<FormAssociatedElementInterface> &\n T;\n}\n\n/**\n * Mixes the passed in class and turns it into a form associated custom element.\n */\nexport function FormAssociatedCheckboxMixin<T extends Constructor<LitElement>>(\n base: T\n) {\n class FormAssociatedCheckboxElement extends BaseFormAssociated(base) {\n /* blazorCSSuppress */\n @property({ attribute: false })\n public set defaultChecked(value: boolean) {\n this._formValue.defaultValue = value;\n\n if (this._pristine && 'checked' in this) {\n this.checked = this.defaultChecked;\n this._pristine = true;\n this._validate();\n }\n }\n\n public get defaultChecked(): boolean {\n return this._formValue.defaultValue as boolean;\n }\n\n public override attributeChangedCallback(\n name: string,\n prev: string | null,\n current: string | null\n ): void {\n super.attributeChangedCallback(name, prev, current);\n if (name === 'checked') {\n this._setDefaultValue(isString(current) ? 'true' : null);\n }\n }\n }\n\n return FormAssociatedCheckboxElement as unknown as Constructor<FormAssociatedCheckboxElementInterface> &\n T;\n}\n"]}
|
|
@@ -58,7 +58,6 @@ export declare function getElementByIdFromRoot(root: HTMLElement, id: string): H
|
|
|
58
58
|
export declare function isElement(node: unknown): node is Element;
|
|
59
59
|
export declare function getElementsFromEventPath<T extends Element>(event: Event): T[];
|
|
60
60
|
export declare function findElementFromEventPath<T extends Element>(predicate: string | ((element: Element) => boolean), event: Event): T | undefined;
|
|
61
|
-
export declare function groupBy<T>(array: T[], key: keyof T | ((item: T) => any)): Record<string, T[]>;
|
|
62
61
|
export declare function first<T>(arr: T[]): T;
|
|
63
62
|
export declare function last<T>(arr: T[]): T;
|
|
64
63
|
export declare function modulo(n: number, d: number): number;
|