igniteui-webcomponents 7.1.2 → 7.2.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 +51 -0
- package/components/banner/banner.d.ts +53 -17
- package/components/banner/banner.js +5 -0
- package/components/banner/banner.js.map +1 -1
- package/components/button/button-base.d.ts +80 -26
- package/components/button/button-base.js +64 -23
- package/components/button/button-base.js.map +1 -1
- package/components/button/button.d.ts +12 -3
- package/components/button/button.js +1 -1
- package/components/button/button.js.map +1 -1
- package/components/button/icon-button.d.ts +25 -9
- package/components/button/icon-button.js +2 -2
- package/components/button/icon-button.js.map +1 -1
- package/components/button-group/themes/shared/button/button.common.css.js +1 -1
- package/components/button-group/themes/shared/button/button.common.css.js.map +1 -1
- package/components/button-group/themes/shared/button/button.indigo.css.js +1 -1
- package/components/button-group/themes/shared/button/button.indigo.css.js.map +1 -1
- package/components/calendar/base.d.ts +5 -4
- package/components/calendar/base.js +3 -2
- package/components/calendar/base.js.map +1 -1
- package/components/calendar/calendar.js +17 -13
- package/components/calendar/calendar.js.map +1 -1
- package/components/calendar/days-view/days-view.d.ts +1 -0
- package/components/calendar/days-view/days-view.js +7 -4
- package/components/calendar/days-view/days-view.js.map +1 -1
- package/components/calendar/helpers.d.ts +1 -1
- package/components/calendar/helpers.js.map +1 -1
- package/components/chat/chat-message.js +8 -8
- package/components/chat/chat-message.js.map +1 -1
- package/components/chat/chat-state.d.ts +3 -1
- package/components/chat/chat-state.js +3 -2
- package/components/chat/chat-state.js.map +1 -1
- package/components/chat/chat.d.ts +5 -1
- package/components/chat/chat.js +14 -4
- package/components/chat/chat.js.map +1 -1
- package/components/checkbox/checkbox.js +1 -0
- package/components/checkbox/checkbox.js.map +1 -1
- package/components/checkbox/switch.js +1 -0
- package/components/checkbox/switch.js.map +1 -1
- package/components/combo/combo.d.ts +1 -0
- package/components/combo/combo.js +7 -0
- package/components/combo/combo.js.map +1 -1
- package/components/combo/controllers/navigation.js +3 -0
- package/components/combo/controllers/navigation.js.map +1 -1
- package/components/common/controllers/command.d.ts +62 -0
- package/components/common/controllers/command.js +25 -0
- package/components/common/controllers/command.js.map +1 -0
- package/components/common/controllers/id-resolver.d.ts +31 -0
- package/components/common/controllers/id-resolver.js +136 -0
- package/components/common/controllers/id-resolver.js.map +1 -0
- package/components/common/i18n/EN/calendar.resources.d.ts +16 -14
- package/components/common/i18n/EN/calendar.resources.js +1 -1
- package/components/common/i18n/EN/calendar.resources.js.map +1 -1
- package/components/common/i18n/EN/chat.resources.d.ts +10 -8
- package/components/common/i18n/EN/chat.resources.js.map +1 -1
- package/components/common/i18n/EN/date-picker.resources.d.ts +8 -0
- package/components/common/i18n/EN/date-picker.resources.js +8 -0
- package/components/common/i18n/EN/date-picker.resources.js.map +1 -0
- package/components/common/i18n/EN/date-range-picker.resources.d.ts +9 -7
- package/components/common/i18n/EN/date-range-picker.resources.js +1 -1
- package/components/common/i18n/EN/date-range-picker.resources.js.map +1 -1
- package/components/common/i18n/i18n-controller.d.ts +14 -11
- package/components/common/i18n/i18n-controller.js +33 -41
- package/components/common/i18n/i18n-controller.js.map +1 -1
- package/components/common/i18n/utils.d.ts +8 -2
- package/components/common/i18n/utils.js +52 -44
- package/components/common/i18n/utils.js.map +1 -1
- package/components/common/mixins/alert.d.ts +47 -9
- package/components/common/mixins/alert.js +55 -12
- package/components/common/mixins/alert.js.map +1 -1
- package/components/common/mixins/forms/associated.js +11 -0
- package/components/common/mixins/forms/associated.js.map +1 -1
- package/components/common/mixins/forms/form-transformers.d.ts +1 -1
- package/components/common/mixins/forms/form-transformers.js.map +1 -1
- package/components/common/mixins/forms/types.d.ts +5 -0
- package/components/common/mixins/forms/types.js.map +1 -1
- package/components/common/mixins/mask-behavior.d.ts +73 -0
- package/components/common/mixins/mask-behavior.js +159 -0
- package/components/common/mixins/mask-behavior.js.map +1 -0
- package/components/common/templates/input-shell.d.ts +24 -0
- package/components/common/templates/input-shell.js +43 -0
- package/components/common/templates/input-shell.js.map +1 -0
- package/components/common/templates/masked-input.d.ts +39 -0
- package/components/common/templates/masked-input.js +37 -0
- package/components/common/templates/masked-input.js.map +1 -0
- package/components/common/util.d.ts +11 -0
- package/components/common/util.js +20 -0
- package/components/common/util.js.map +1 -1
- package/components/date-picker/date-picker.d.ts +6 -4
- package/components/date-picker/date-picker.js +16 -5
- package/components/date-picker/date-picker.js.map +1 -1
- package/components/date-range-picker/date-range-input.d.ts +60 -0
- package/components/date-range-picker/date-range-input.js +251 -0
- package/components/date-range-picker/date-range-input.js.map +1 -0
- package/components/date-range-picker/date-range-mask-parser.d.ts +106 -0
- package/components/date-range-picker/date-range-mask-parser.js +121 -0
- package/components/date-range-picker/date-range-mask-parser.js.map +1 -0
- package/components/date-range-picker/date-range-picker.d.ts +17 -11
- package/components/date-range-picker/date-range-picker.js +89 -61
- package/components/date-range-picker/date-range-picker.js.map +1 -1
- package/components/date-range-picker/predefined-ranges-area.d.ts +4 -4
- package/components/date-range-picker/predefined-ranges-area.js +8 -4
- package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
- package/components/date-range-picker/validators.d.ts +5 -19
- package/components/date-range-picker/validators.js +20 -16
- package/components/date-range-picker/validators.js.map +1 -1
- package/components/date-time-input/date-time-input.base.d.ts +155 -0
- package/components/date-time-input/date-time-input.base.js +275 -0
- package/components/date-time-input/date-time-input.base.js.map +1 -0
- package/components/date-time-input/date-time-input.d.ts +33 -122
- package/components/date-time-input/date-time-input.js +45 -258
- package/components/date-time-input/date-time-input.js.map +1 -1
- package/components/date-time-input/datetime-mask-parser.d.ts +11 -1
- package/components/date-time-input/datetime-mask-parser.js +5 -5
- package/components/date-time-input/datetime-mask-parser.js.map +1 -1
- package/components/dialog/dialog.d.ts +88 -31
- package/components/dialog/dialog.js +29 -31
- package/components/dialog/dialog.js.map +1 -1
- package/components/file-input/file-input.d.ts +1 -1
- package/components/input/input-base.d.ts +2 -10
- package/components/input/input-base.js +11 -57
- package/components/input/input-base.js.map +1 -1
- package/components/input/input.d.ts +1 -1
- package/components/input/input.js +1 -0
- package/components/input/input.js.map +1 -1
- package/components/input/themes/dark/input.shared.css.d.ts +1 -0
- package/components/input/themes/dark/input.shared.css.js +3 -0
- package/components/input/themes/dark/input.shared.css.js.map +1 -0
- package/components/input/themes/light/input.shared.css.js +1 -1
- package/components/input/themes/light/input.shared.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.material.css.js +1 -1
- package/components/input/themes/shared/input.material.css.js.map +1 -1
- package/components/input/themes/themes.js +4 -3
- package/components/input/themes/themes.js.map +1 -1
- package/components/mask-input/mask-input.d.ts +9 -4
- package/components/mask-input/mask-input.js +30 -36
- package/components/mask-input/mask-input.js.map +1 -1
- package/components/nav-drawer/nav-drawer.d.ts +93 -17
- package/components/nav-drawer/nav-drawer.js +148 -21
- package/components/nav-drawer/nav-drawer.js.map +1 -1
- package/components/nav-drawer/themes/container.base.css.js +1 -1
- package/components/nav-drawer/themes/container.base.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.common.css.js +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.common.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.fluent.css.js +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.fluent.css.js.map +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.indigo.css.js +1 -1
- package/components/nav-drawer/themes/shared/container/nav-drawer.indigo.css.js.map +1 -1
- package/components/radio/radio.js +1 -0
- package/components/radio/radio.js.map +1 -1
- package/components/snackbar/snackbar.d.ts +9 -5
- package/components/snackbar/snackbar.js +6 -8
- package/components/snackbar/snackbar.js.map +1 -1
- package/components/snackbar/themes/snackbar.base.css.js +1 -1
- package/components/snackbar/themes/snackbar.base.css.js.map +1 -1
- package/components/stepper/step.d.ts +1 -1
- package/components/stepper/step.js +4 -4
- package/components/stepper/step.js.map +1 -1
- package/components/stepper/stepper.js +5 -0
- package/components/stepper/stepper.js.map +1 -1
- package/components/stepper/themes/step/step.base.css.js +1 -1
- package/components/stepper/themes/step/step.base.css.js.map +1 -1
- package/components/stepper/themes/stepper/stepper.base.css.js +1 -1
- package/components/stepper/themes/stepper/stepper.base.css.js.map +1 -1
- package/components/toast/themes/toast.base.css.js +1 -1
- package/components/toast/themes/toast.base.css.js.map +1 -1
- package/components/toast/toast.d.ts +9 -2
- package/components/toast/toast.js +0 -2
- package/components/toast/toast.js.map +1 -1
- package/components/types.d.ts +4 -0
- package/components/types.js.map +1 -1
- package/custom-elements.json +34882 -28909
- package/igniteui-webcomponents.css-data.json +1 -1
- package/igniteui-webcomponents.html-data.json +1 -1
- package/index.d.ts +5 -2
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/skills/igniteui-wc-choose-components/SKILL.md +23 -6
- package/skills/igniteui-wc-choose-components/reference/mcp-setup.md +82 -0
- package/skills/igniteui-wc-generate-from-image-design/references/component-mapping.md +4 -2
- package/web-types.json +2 -2
- package/components/mask-input/mask-input-base.d.ts +0 -51
- package/components/mask-input/mask-input-base.js +0 -146
- package/components/mask-input/mask-input-base.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { getCurrentI18n, getDateFormatter,
|
|
2
|
-
import {
|
|
1
|
+
import { getCurrentI18n, getDateFormatter, getI18nManager, } from 'igniteui-i18n-core';
|
|
2
|
+
import { convertToCoreResource, convertToIgcResource, } from './utils.js';
|
|
3
3
|
class I18nController {
|
|
4
4
|
set locale(value) {
|
|
5
5
|
if (this._locale !== value) {
|
|
6
6
|
this._locale = value;
|
|
7
|
-
this._defaultResourceStrings = this.
|
|
7
|
+
this._defaultResourceStrings = this._getDefaultResourceStrings();
|
|
8
8
|
this._host.requestUpdate();
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -13,7 +13,16 @@ class I18nController {
|
|
|
13
13
|
}
|
|
14
14
|
set resourceStrings(value) {
|
|
15
15
|
if (this._resourceStrings !== value) {
|
|
16
|
-
|
|
16
|
+
if (value) {
|
|
17
|
+
this._customResourceStrings = this._resourceMapName
|
|
18
|
+
? this.getMixedResourceStrings(value)
|
|
19
|
+
: value;
|
|
20
|
+
this._resourceStrings = Object.assign({}, this._defaultResourceStrings, this._customResourceStrings);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this._customResourceStrings = value;
|
|
24
|
+
this._resourceStrings = value;
|
|
25
|
+
}
|
|
17
26
|
this._host.requestUpdate();
|
|
18
27
|
}
|
|
19
28
|
}
|
|
@@ -23,9 +32,10 @@ class I18nController {
|
|
|
23
32
|
constructor(host, config) {
|
|
24
33
|
this._host = host;
|
|
25
34
|
this._defaultEN = config.defaultEN;
|
|
35
|
+
this._resourceMapName = config.resourceMapName;
|
|
26
36
|
this._resourceChangeCallback = config.onResourceChange;
|
|
27
|
-
this._defaultResourceStrings = this.
|
|
28
|
-
|
|
37
|
+
this._defaultResourceStrings = this._getDefaultResourceStrings();
|
|
38
|
+
getI18nManager().registerI18n(this._defaultEN, getI18nManager().defaultLocale);
|
|
29
39
|
this._host.addController(this);
|
|
30
40
|
}
|
|
31
41
|
hostConnected() {
|
|
@@ -35,49 +45,31 @@ class I18nController {
|
|
|
35
45
|
getI18nManager().removeEventListener('onResourceChange', this);
|
|
36
46
|
}
|
|
37
47
|
handleEvent(event) {
|
|
38
|
-
this._defaultResourceStrings = this.
|
|
48
|
+
this._defaultResourceStrings = this._getDefaultResourceStrings();
|
|
49
|
+
if (this._customResourceStrings) {
|
|
50
|
+
this._resourceStrings = Object.assign({}, this._defaultResourceStrings, this._customResourceStrings);
|
|
51
|
+
}
|
|
39
52
|
this._resourceChangeCallback?.call(this._host, event);
|
|
40
53
|
this._host.requestUpdate();
|
|
41
54
|
}
|
|
42
|
-
|
|
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() {
|
|
55
|
+
_getDefaultResourceStrings() {
|
|
58
56
|
const coreResourceStrings = getI18nManager().getCurrentResourceStrings(this.locale);
|
|
59
|
-
const resourceMap = this._getResourceMapForComponent();
|
|
60
57
|
const normalizedResourceStrings = {};
|
|
61
58
|
const defaultComponentKeys = Object.keys(this._defaultEN);
|
|
62
|
-
for (const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (coreKey.includes('getWeekLabel')) {
|
|
67
|
-
resolvedValue = getDisplayNamesFormatter().getWeekLabel(this.locale, {
|
|
68
|
-
style: 'short',
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
else if (coreKey in coreResourceStrings) {
|
|
72
|
-
resolvedValue = coreResourceStrings[coreKey];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else if (igcKey in coreResourceStrings) {
|
|
76
|
-
resolvedValue = coreResourceStrings[igcKey];
|
|
59
|
+
for (const key of defaultComponentKeys) {
|
|
60
|
+
let resolvedValue = this._defaultEN[key];
|
|
61
|
+
if (key in coreResourceStrings) {
|
|
62
|
+
resolvedValue = coreResourceStrings[key];
|
|
77
63
|
}
|
|
78
|
-
normalizedResourceStrings[
|
|
64
|
+
normalizedResourceStrings[key] = resolvedValue;
|
|
65
|
+
}
|
|
66
|
+
return this.getMixedResourceStrings(normalizedResourceStrings);
|
|
67
|
+
}
|
|
68
|
+
getMixedResourceStrings(value) {
|
|
69
|
+
if (this._resourceMapName) {
|
|
70
|
+
return Object.assign({}, convertToCoreResource(value, this._resourceMapName), convertToIgcResource(value, this._resourceMapName));
|
|
79
71
|
}
|
|
80
|
-
return
|
|
72
|
+
return value;
|
|
81
73
|
}
|
|
82
74
|
}
|
|
83
75
|
const DATE_TIME_STYLES = new Set(['short', 'long', 'medium', 'full']);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-controller.js","sourceRoot":"","sources":["../../../../src/components/common/i18n/i18n-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,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,IAAI,CAAC,uBAAuB,CAAC;IAC/D,CAAC;IAMD,YAAY,IAAwB,EAAE,MAA+B;QACnE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UA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;YACtD,SAAS,EAAE,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC;SAC/C,CAAC,CAAC;IACL,CAAC;IAGD,OAAO,gBAAgB,EAAE,CAAC,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE;QACrE,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAGD,MAAM,UAAU,iBAAiB,CAC/B,IAAwB,EACxB,MAA+B;IAE/B,OAAO,IAAI,cAAc,CAAI,IAAI,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import {\n getCurrentI18n,\n getDateFormatter,\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?.call(this._host, 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\n const resourceMap = this._getResourceMapForComponent();\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 // To be removed once the Calendar switches completely to the new i18n resources.\n resolvedValue = getDisplayNamesFormatter().getWeekLabel(this.locale, {\n style: 'short',\n }) as T[keyof T];\n } else if (coreKey in coreResourceStrings) {\n resolvedValue = coreResourceStrings[\n coreKey as keyof IResourceStrings\n ] as T[keyof T];\n }\n } else if (igcKey in coreResourceStrings) {\n // For a mix of old and core resources.\n // Only for internal default resources. Users shouldn't mix them.\n resolvedValue = coreResourceStrings[\n igcKey as keyof IResourceStrings\n ] as T[keyof T];\n }\n\n normalizedResourceStrings[igcKey] = resolvedValue;\n }\n\n return normalizedResourceStrings;\n }\n\n //#endregion\n}\n\n/**\n * Formats a date for display based on the specified format and locale.\n */\ntype DateTimeStyle = 'short' | 'long' | 'medium' | 'full';\n\nconst DATE_TIME_STYLES = new Set<string>(['short', 'long', 'medium', 'full']);\n\nfunction extractStyle(format: string, suffix: string): DateTimeStyle {\n return format.toLowerCase().split(suffix)[0] as DateTimeStyle;\n}\n\n/** Returns the default date-time input format for a given locale */\nexport function getDefaultDateTimeFormat(locale: string): string {\n return getDateFormatter().getLocaleDateTimeFormat(locale, true);\n}\n\n/** Returns the date-time format string with the appropriate suffix if it's a predefined style */\nexport function getDateTimeFormat(\n format?: string,\n suffix: 'Date' | 'Time' = 'Date'\n): string | undefined {\n return format && DATE_TIME_STYLES.has(format) ? `${format}${suffix}` : format;\n}\n\n/**\n * Formats a date for display using the specified format.\n */\nexport function formatDisplayDate(\n value: Date,\n locale: string,\n displayFormat?: string\n): string {\n if (!displayFormat) {\n return getDateFormatter().formatDateTime(value, locale, {});\n }\n\n // Full date+time styles (short, long, medium, full)\n if (DATE_TIME_STYLES.has(displayFormat)) {\n const style = displayFormat as DateTimeStyle;\n return getDateFormatter().formatDateTime(value, locale, {\n dateStyle: style,\n timeStyle: style,\n });\n }\n\n // Date-only styles (shortDate, longDate, etc.)\n if (displayFormat.endsWith('Date')) {\n return getDateFormatter().formatDateTime(value, locale, {\n dateStyle: extractStyle(displayFormat, 'date'),\n });\n }\n\n // Time-only styles (shortTime, longTime, etc.)\n if (displayFormat.endsWith('Time')) {\n return getDateFormatter().formatDateTime(value, locale, {\n timeStyle: extractStyle(displayFormat, 'time'),\n });\n }\n\n // Custom format string\n return getDateFormatter().formatDateCustomFormat(value, displayFormat, {\n locale,\n });\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"]}
|
|
1
|
+
{"version":3,"file":"i18n-controller.js","sourceRoot":"","sources":["../../../../src/components/common/i18n/i18n-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,cAAc,GAGf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAErB,MAAM,YAAY,CAAC;AA+BpB,MAAM,cAAc;IAyBlB,IAAW,MAAM,CAAC,KAAyB;QACzC,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,IAAI,CAAC,uBA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C,aAAa,CAAC,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,aAA8B,CAAC;QAC7C,OAAO,gBAAgB,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE;YACtD,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;IACL,CAAC;IAGD,IAAI,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,OAAO,gBAAgB,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE;YACtD,SAAS,EAAE,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC;SAC/C,CAAC,CAAC;IACL,CAAC;IAGD,IAAI,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,OAAO,gBAAgB,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE;YACtD,SAAS,EAAE,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC;SAC/C,CAAC,CAAC;IACL,CAAC;IAGD,OAAO,gBAAgB,EAAE,CAAC,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE;QACrE,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAGD,MAAM,UAAU,iBAAiB,CAC/B,IAAwB,EACxB,MAA+B;IAE/B,OAAO,IAAI,cAAc,CAAI,IAAI,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import {\n getCurrentI18n,\n getDateFormatter,\n getI18nManager,\n type IResourceChangeEventArgs,\n type IResourceStrings,\n} from 'igniteui-i18n-core';\nimport type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport {\n convertToCoreResource,\n convertToIgcResource,\n type I18nResourceMapNames,\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. Should always come from igniteui-i18n-core. */\n defaultEN: T;\n /** @deprecated since 7.2.0. Optional name if component uses mixed resource strings. To be removed with deprecated resources. */\n resourceMapName?: I18nResourceMapNames;\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 /** @deprecated since 7.2.0. Resource name to use when converting new to old and vice versa resource objects. */\n private readonly _resourceMapName?: I18nResourceMapNames;\n private readonly _resourceChangeCallback?: ResourceChangeCallback;\n\n private _locale?: string;\n /** Cache of default resource strings coming from i18n Manager. */\n private _defaultResourceStrings: T;\n /** Collection containing only custom resource strings provided. Allows for partial override of resource strings. */\n private _customResourceStrings?: T;\n /** Merged collection of custom resource strings and default resource strings. */\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._getDefaultResourceStrings();\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 if (value) {\n this._customResourceStrings = this._resourceMapName\n ? this.getMixedResourceStrings(value)\n : value;\n this._resourceStrings = Object.assign(\n {},\n this._defaultResourceStrings,\n this._customResourceStrings\n );\n } else {\n this._customResourceStrings = value;\n this._resourceStrings = value;\n }\n\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._resourceMapName = config.resourceMapName;\n this._resourceChangeCallback = config.onResourceChange;\n\n this._defaultResourceStrings = this._getDefaultResourceStrings();\n getI18nManager().registerI18n(\n this._defaultEN,\n getI18nManager().defaultLocale\n );\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._getDefaultResourceStrings();\n if (this._customResourceStrings) {\n this._resourceStrings = Object.assign(\n {},\n this._defaultResourceStrings,\n this._customResourceStrings\n );\n }\n this._resourceChangeCallback?.call(this._host, event);\n this._host.requestUpdate();\n }\n\n //#endregion\n\n //#region Internal API\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 _getDefaultResourceStrings(): T {\n const coreResourceStrings = getI18nManager().getCurrentResourceStrings(\n this.locale\n );\n\n // Get all related resources to the component, based on the default resources.\n const normalizedResourceStrings: T = {} as T;\n const defaultComponentKeys = Object.keys(this._defaultEN) as (keyof T)[];\n for (const key of defaultComponentKeys) {\n let resolvedValue: T[keyof T] = this._defaultEN[key];\n if (key in coreResourceStrings) {\n // For a mix of old and core resources.\n // Only for internal default resources. Users shouldn't mix them.\n resolvedValue = coreResourceStrings[\n key as keyof IResourceStrings\n ] as T[keyof T];\n }\n\n normalizedResourceStrings[key] = resolvedValue;\n }\n\n return this.getMixedResourceStrings(normalizedResourceStrings);\n }\n\n private getMixedResourceStrings(value: T): T {\n if (this._resourceMapName) {\n return Object.assign(\n {},\n convertToCoreResource(value, this._resourceMapName),\n convertToIgcResource(value, this._resourceMapName)\n ) as T;\n }\n return value;\n }\n\n //#endregion\n}\n\n/**\n * Formats a date for display based on the specified format and locale.\n */\ntype DateTimeStyle = 'short' | 'long' | 'medium' | 'full';\n\nconst DATE_TIME_STYLES = new Set<string>(['short', 'long', 'medium', 'full']);\n\nfunction extractStyle(format: string, suffix: string): DateTimeStyle {\n return format.toLowerCase().split(suffix)[0] as DateTimeStyle;\n}\n\n/** Returns the default date-time input format for a given locale */\nexport function getDefaultDateTimeFormat(locale: string): string {\n return getDateFormatter().getLocaleDateTimeFormat(locale, true);\n}\n\n/** Returns the date-time format string with the appropriate suffix if it's a predefined style */\nexport function getDateTimeFormat(\n format?: string,\n suffix: 'Date' | 'Time' = 'Date'\n): string | undefined {\n return format && DATE_TIME_STYLES.has(format) ? `${format}${suffix}` : format;\n}\n\n/**\n * Formats a date for display using the specified format.\n */\nexport function formatDisplayDate(\n value: Date,\n locale: string,\n displayFormat?: string\n): string {\n if (!displayFormat) {\n return getDateFormatter().formatDateTime(value, locale, {});\n }\n\n // Full date+time styles (short, long, medium, full)\n if (DATE_TIME_STYLES.has(displayFormat)) {\n const style = displayFormat as DateTimeStyle;\n return getDateFormatter().formatDateTime(value, locale, {\n dateStyle: style,\n timeStyle: style,\n });\n }\n\n // Date-only styles (shortDate, longDate, etc.)\n if (displayFormat.endsWith('Date')) {\n return getDateFormatter().formatDateTime(value, locale, {\n dateStyle: extractStyle(displayFormat, 'date'),\n });\n }\n\n // Time-only styles (shortTime, longTime, etc.)\n if (displayFormat.endsWith('Time')) {\n return getDateFormatter().formatDateTime(value, locale, {\n timeStyle: extractStyle(displayFormat, 'time'),\n });\n }\n\n // Custom format string\n return getDateFormatter().formatDateCustomFormat(value, displayFormat, {\n locale,\n });\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"]}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { IResourceStrings } from 'igniteui-i18n-core';
|
|
2
2
|
import type { IgcCalendarResourceStrings } from './EN/calendar.resources.js';
|
|
3
|
+
import type { IgcChatResourceStrings } from './EN/chat.resources.js';
|
|
4
|
+
import type { IgcDatePickerResourceStrings } from './EN/date-picker.resources.js';
|
|
3
5
|
import type { IgcDateRangePickerResourceStrings } from './EN/date-range-picker.resources.js';
|
|
6
|
+
/** Names of components currently handling a mix of old and new resource strings. */
|
|
7
|
+
export type I18nResourceMapNames = 'calendar' | 'date-picker' | 'date-range-picker' | 'chat';
|
|
4
8
|
export declare const calendarResourcesMap: Map<keyof IgcCalendarResourceStrings, string | undefined>;
|
|
9
|
+
export declare const chatResourcesMap: Map<keyof IgcChatResourceStrings, string>;
|
|
5
10
|
export declare const dateRangePickerResourcesMap: Map<keyof IgcDateRangePickerResourceStrings, string | undefined>;
|
|
6
|
-
export declare
|
|
7
|
-
export declare function
|
|
11
|
+
export declare const datePickerResourcesMap: Map<keyof IgcDatePickerResourceStrings, string | undefined>;
|
|
12
|
+
export declare function convertToIgcResource<T extends object>(resource: IResourceStrings, resourceMapName: I18nResourceMapNames): T;
|
|
13
|
+
export declare function convertToCoreResource<T extends object>(resource: T, resourceMapName: I18nResourceMapNames): IResourceStrings;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isString } from '../util.js';
|
|
2
2
|
export const calendarResourcesMap = new Map([
|
|
3
3
|
['selectMonth', 'calendar_select_month'],
|
|
4
4
|
['selectYear', 'calendar_select_year'],
|
|
@@ -15,6 +15,16 @@ export const calendarResourcesMap = new Map([
|
|
|
15
15
|
['nextYears', 'calendar_next_years'],
|
|
16
16
|
['weekLabel', 'i18n/getWeekLabel'],
|
|
17
17
|
]);
|
|
18
|
+
export const chatResourcesMap = new Map([
|
|
19
|
+
['suggestionsHeader', 'chat_suggestions_header'],
|
|
20
|
+
['reactionCopy', 'chat_reaction_copy'],
|
|
21
|
+
['reactionLike', 'chat_reaction_like'],
|
|
22
|
+
['reactionDislike', 'chat_reaction_dislike'],
|
|
23
|
+
['reactionRegenerate', 'chat_reaction_regenerate'],
|
|
24
|
+
['attachmentLabel', 'chat_attachment_label'],
|
|
25
|
+
['attachmentsListLabel', 'chat_attachments_list_label'],
|
|
26
|
+
['messageCopied', 'chat_message_copied'],
|
|
27
|
+
]);
|
|
18
28
|
export const dateRangePickerResourcesMap = new Map([
|
|
19
29
|
['separator', 'date_range_picker_date_separator'],
|
|
20
30
|
['done', 'date_range_picker_done_button'],
|
|
@@ -25,64 +35,62 @@ export const dateRangePickerResourcesMap = new Map([
|
|
|
25
35
|
['yearToDate', 'date_range_picker_yearToDate'],
|
|
26
36
|
...calendarResourcesMap.entries(),
|
|
27
37
|
]);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function getResourceMapForCore(resource) {
|
|
46
|
-
if ('date_range_picker_last7Days' in resource) {
|
|
47
|
-
return dateRangePickerResourcesMap;
|
|
48
|
-
}
|
|
49
|
-
if ('calendar_select_month' in resource) {
|
|
50
|
-
return calendarResourcesMap;
|
|
38
|
+
export const datePickerResourcesMap = new Map([
|
|
39
|
+
['changeDate', 'date_picker_change_date'],
|
|
40
|
+
['chooseDate', 'date_picker_choose_date'],
|
|
41
|
+
...calendarResourcesMap.entries(),
|
|
42
|
+
]);
|
|
43
|
+
function getResourceMap(name) {
|
|
44
|
+
switch (name) {
|
|
45
|
+
case 'calendar':
|
|
46
|
+
return calendarResourcesMap;
|
|
47
|
+
case 'chat':
|
|
48
|
+
return chatResourcesMap;
|
|
49
|
+
case 'date-picker':
|
|
50
|
+
return datePickerResourcesMap;
|
|
51
|
+
case 'date-range-picker':
|
|
52
|
+
return dateRangePickerResourcesMap;
|
|
53
|
+
default:
|
|
54
|
+
break;
|
|
51
55
|
}
|
|
52
|
-
return
|
|
56
|
+
return new Map();
|
|
53
57
|
}
|
|
54
|
-
export function convertToIgcResource(resource) {
|
|
58
|
+
export function convertToIgcResource(resource, resourceMapName) {
|
|
55
59
|
const result = {};
|
|
56
|
-
const resourceMap =
|
|
60
|
+
const resourceMap = getResourceMap(resourceMapName);
|
|
57
61
|
if (!resourceMap) {
|
|
58
62
|
return resource;
|
|
59
63
|
}
|
|
60
|
-
for (const [
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
for (const [igcKey, coreKey] of resourceMap) {
|
|
65
|
+
if (igcKey in resource) {
|
|
66
|
+
result[igcKey] = resource[igcKey];
|
|
67
|
+
}
|
|
68
|
+
else if (coreKey && coreKey in resource) {
|
|
69
|
+
const value = resource[coreKey];
|
|
70
|
+
if (isString(value)) {
|
|
71
|
+
result[igcKey] = value;
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
75
|
return result;
|
|
69
76
|
}
|
|
70
|
-
export function convertToCoreResource(resource) {
|
|
77
|
+
export function convertToCoreResource(resource, resourceMapName) {
|
|
71
78
|
const result = {};
|
|
72
|
-
const resourceMap = getResourceMap(
|
|
73
|
-
if (resourceMap) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
const resourceMap = getResourceMap(resourceMapName);
|
|
80
|
+
if (!resourceMap) {
|
|
81
|
+
return resource;
|
|
82
|
+
}
|
|
83
|
+
for (const [igcKey, coreKey] of resourceMap) {
|
|
84
|
+
if (coreKey && coreKey in resource) {
|
|
85
|
+
result[coreKey] = resource[coreKey];
|
|
86
|
+
}
|
|
87
|
+
else if (coreKey) {
|
|
88
|
+
const value = resource[igcKey];
|
|
89
|
+
if (isString(value)) {
|
|
90
|
+
result[coreKey] = value;
|
|
80
91
|
}
|
|
81
92
|
}
|
|
82
93
|
}
|
|
83
|
-
else {
|
|
84
|
-
return resource;
|
|
85
|
-
}
|
|
86
94
|
return result;
|
|
87
95
|
}
|
|
88
96
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/components/common/i18n/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/components/common/i18n/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAatC,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,WAAW,EAAE,4BAA4B,CAAC;IAC3C,CAAC,SAAS,EAAE,0BAA0B,CAAC;IACvC,CAAC,eAAe,EAAE,yBAAyB,CAAC;IAC5C,CAAC,WAAW,EAAE,qBAAqB,CAAC;IACpC,CAAC,cAAc,EAAE,wBAAwB,CAAC;IAC1C,CAAC,UAAU,EAAE,oBAAoB,CAAC;IAClC,CAAC,eAAe,EAAE,yBAAyB,CAAC;IAC5C,CAAC,WAAW,EAAE,qBAAqB,CAAC;IACpC,CAAC,WAAW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AAO,EAAE,CAAC;YACnB,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAiB,CAAC,CAAC;YAC1C,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpB,MAAM,CAAC,OAAiC,CAAC,GAAG,KAAK,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { IResourceStrings } from 'igniteui-i18n-core';\nimport { isString } from '../util.js';\nimport type { IgcCalendarResourceStrings } from './EN/calendar.resources.js';\nimport type { IgcChatResourceStrings } from './EN/chat.resources.js';\nimport type { IgcDatePickerResourceStrings } from './EN/date-picker.resources.js';\nimport type { IgcDateRangePickerResourceStrings } from './EN/date-range-picker.resources.js';\n\n/** Names of components currently handling a mix of old and new resource strings. */\nexport type I18nResourceMapNames =\n | 'calendar'\n | 'date-picker'\n | 'date-range-picker'\n | 'chat';\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 chatResourcesMap = new Map<keyof IgcChatResourceStrings, string>([\n ['suggestionsHeader', 'chat_suggestions_header'],\n ['reactionCopy', 'chat_reaction_copy'],\n ['reactionLike', 'chat_reaction_like'],\n ['reactionDislike', 'chat_reaction_dislike'],\n ['reactionRegenerate', 'chat_reaction_regenerate'],\n ['attachmentLabel', 'chat_attachment_label'],\n ['attachmentsListLabel', 'chat_attachments_list_label'],\n ['messageCopied', 'chat_message_copied'],\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\nexport const datePickerResourcesMap = new Map<\n keyof IgcDatePickerResourceStrings,\n string | undefined\n>([\n ['changeDate', 'date_picker_change_date'],\n ['chooseDate', 'date_picker_choose_date'],\n ...(\n calendarResourcesMap as Map<\n keyof IgcCalendarResourceStrings,\n string | undefined\n >\n ).entries(),\n]);\n\nfunction getResourceMap(\n name: I18nResourceMapNames\n): Map<string, string | undefined> | undefined {\n switch (name) {\n case 'calendar':\n return calendarResourcesMap;\n case 'chat':\n return chatResourcesMap;\n case 'date-picker':\n return datePickerResourcesMap;\n case 'date-range-picker':\n return dateRangePickerResourcesMap;\n default:\n break;\n }\n\n return new Map<string, string | undefined>();\n}\n\nexport function convertToIgcResource<T extends object>(\n resource: IResourceStrings,\n resourceMapName: I18nResourceMapNames\n): T {\n const result = {} as T;\n const resourceMap = getResourceMap(resourceMapName);\n\n if (!resourceMap) {\n return resource as T;\n }\n\n for (const [igcKey, coreKey] of resourceMap) {\n if (igcKey in resource) {\n result[igcKey as keyof T] = resource[\n igcKey as keyof IResourceStrings\n ] as T[keyof T];\n } else if (coreKey && coreKey in resource) {\n const value = resource[coreKey as keyof IResourceStrings];\n if (isString(value)) {\n result[igcKey as keyof T] = value as T[keyof T];\n }\n }\n }\n\n return result;\n}\n\nexport function convertToCoreResource<T extends object>(\n resource: T,\n resourceMapName: I18nResourceMapNames\n): IResourceStrings {\n const result: IResourceStrings = {};\n const resourceMap = getResourceMap(resourceMapName);\n\n if (!resourceMap) {\n return resource as IResourceStrings;\n }\n\n for (const [igcKey, coreKey] of resourceMap) {\n if (coreKey && coreKey in resource) {\n result[coreKey as keyof IResourceStrings] = resource[\n coreKey as keyof T\n ] as string;\n } else if (coreKey) {\n const value = resource[igcKey as keyof T];\n if (isString(value)) {\n result[coreKey as keyof IResourceStrings] = value;\n }\n }\n }\n\n return result;\n}\n"]}
|
|
@@ -1,37 +1,75 @@
|
|
|
1
1
|
import { LitElement, type PropertyValues } from 'lit';
|
|
2
|
-
import type { AnimationController } from '../../../animations/player.js';
|
|
3
2
|
import type { AbsolutePosition } from '../../types.js';
|
|
4
3
|
export declare abstract class IgcBaseAlertLikeComponent extends LitElement {
|
|
5
|
-
protected
|
|
4
|
+
protected readonly _player: import("../../../animations/player.js").AnimationController;
|
|
6
5
|
protected _autoHideTimeout?: ReturnType<typeof setTimeout>;
|
|
7
6
|
/**
|
|
8
7
|
* Whether the component is in shown state.
|
|
9
|
-
*
|
|
8
|
+
*
|
|
9
|
+
* @attr open
|
|
10
|
+
* @default false
|
|
10
11
|
*/
|
|
11
12
|
open: boolean;
|
|
12
13
|
/**
|
|
13
|
-
* Determines the duration in
|
|
14
|
+
* Determines the duration in milliseconds in which the component will be visible.
|
|
15
|
+
*
|
|
14
16
|
* @attr display-time
|
|
17
|
+
* @default 4000
|
|
15
18
|
*/
|
|
16
19
|
displayTime: number;
|
|
17
20
|
/**
|
|
18
21
|
* Determines whether the component should close after the `displayTime` is over.
|
|
22
|
+
*
|
|
19
23
|
* @attr keep-open
|
|
24
|
+
* @default false
|
|
20
25
|
*/
|
|
21
26
|
keepOpen: boolean;
|
|
22
27
|
/**
|
|
23
28
|
* Sets the position of the component in the viewport.
|
|
24
|
-
*
|
|
29
|
+
*
|
|
30
|
+
* `bottom` - positions the component at the bottom. This is the default.
|
|
31
|
+
* `middle` - positions the component at the center.
|
|
32
|
+
* `top` - positions the component at the top.
|
|
33
|
+
*
|
|
34
|
+
* @attr position
|
|
35
|
+
* @default 'bottom'
|
|
25
36
|
*/
|
|
26
37
|
position: AbsolutePosition;
|
|
38
|
+
/**
|
|
39
|
+
* Sets the positioning strategy of the component.
|
|
40
|
+
*
|
|
41
|
+
* `viewport` - positions the component relative to the viewport, ignoring any ancestor elements. This is the default behavior.
|
|
42
|
+
* `container` - positions the component relative to the nearest visible ancestor. In this mode, the component will be constrained within the bounding box of the ancestor and will be positioned according to the `position` attribute.
|
|
43
|
+
*
|
|
44
|
+
* @attr positioning
|
|
45
|
+
* @default 'viewport'
|
|
46
|
+
*/
|
|
47
|
+
positioning: 'viewport' | 'container';
|
|
27
48
|
constructor();
|
|
28
|
-
|
|
49
|
+
connectedCallback(): void;
|
|
50
|
+
protected update(props: PropertyValues<this>): void;
|
|
51
|
+
private _showPopover;
|
|
29
52
|
private _setOpenState;
|
|
30
53
|
private _setAutoHideTimer;
|
|
31
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Opens the component.
|
|
56
|
+
*
|
|
57
|
+
* Returns a promise that resolves to `true` if the component was successfully opened, or `false`
|
|
58
|
+
* if it was already open or could not be shown (e.g., in `container` positioning mode with no visible ancestors).
|
|
59
|
+
*/
|
|
32
60
|
show(): Promise<boolean>;
|
|
33
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Closes the component.
|
|
63
|
+
*
|
|
64
|
+
* Returns a promise that resolves to `true` if the component was successfully closed, or `false`
|
|
65
|
+
* if it was already closed.
|
|
66
|
+
*/
|
|
34
67
|
hide(): Promise<boolean>;
|
|
35
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Toggles the open state of the component.
|
|
70
|
+
*
|
|
71
|
+
* Returns a promise that resolves to `true` if the operation completed successfully, or `false`
|
|
72
|
+
* if it was already in the desired state.
|
|
73
|
+
*/
|
|
36
74
|
toggle(): Promise<boolean>;
|
|
37
75
|
}
|
|
@@ -6,15 +6,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { LitElement } from 'lit';
|
|
8
8
|
import { property } from 'lit/decorators.js';
|
|
9
|
+
import { addAnimationController } from '../../../animations/player.js';
|
|
9
10
|
import { fadeIn, fadeOut } from '../../../animations/presets/fade/index.js';
|
|
11
|
+
import { addCommandController } from '../controllers/command.js';
|
|
10
12
|
import { addInternalsController } from '../controllers/internals.js';
|
|
13
|
+
import { getVisibleAncestor, isPopoverOpen } from '../util.js';
|
|
11
14
|
export class IgcBaseAlertLikeComponent extends LitElement {
|
|
12
15
|
constructor() {
|
|
13
16
|
super();
|
|
17
|
+
this._player = addAnimationController(this);
|
|
14
18
|
this.open = false;
|
|
15
19
|
this.displayTime = 4000;
|
|
16
20
|
this.keepOpen = false;
|
|
17
21
|
this.position = 'bottom';
|
|
22
|
+
this.positioning = 'viewport';
|
|
23
|
+
addCommandController(this)
|
|
24
|
+
.set('--show', this.show)
|
|
25
|
+
.set('--hide', this.hide)
|
|
26
|
+
.set('--toggle', this.toggle);
|
|
18
27
|
addInternalsController(this, {
|
|
19
28
|
initialARIA: {
|
|
20
29
|
role: 'status',
|
|
@@ -22,26 +31,57 @@ export class IgcBaseAlertLikeComponent extends LitElement {
|
|
|
22
31
|
},
|
|
23
32
|
});
|
|
24
33
|
}
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
connectedCallback() {
|
|
35
|
+
super.connectedCallback();
|
|
36
|
+
this.popover = 'manual';
|
|
37
|
+
}
|
|
38
|
+
update(props) {
|
|
39
|
+
if (props.has('open')) {
|
|
40
|
+
if (this.open && !isPopoverOpen(this)) {
|
|
41
|
+
this._showPopover();
|
|
42
|
+
}
|
|
43
|
+
else if (!this.open && isPopoverOpen(this)) {
|
|
44
|
+
this.hidePopover();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (this.open && (props.has('positioning') || props.has('position'))) {
|
|
48
|
+
this.hidePopover();
|
|
49
|
+
this._showPopover();
|
|
50
|
+
}
|
|
51
|
+
if (props.has('open') ||
|
|
52
|
+
props.has('displayTime') ||
|
|
53
|
+
props.has('keepOpen')) {
|
|
27
54
|
this._setAutoHideTimer();
|
|
28
55
|
}
|
|
29
|
-
|
|
30
|
-
|
|
56
|
+
super.update(props);
|
|
57
|
+
}
|
|
58
|
+
_showPopover() {
|
|
59
|
+
if (this.positioning !== 'container') {
|
|
60
|
+
this.showPopover();
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
const visibleAncestor = getVisibleAncestor(this);
|
|
64
|
+
if (!visibleAncestor) {
|
|
65
|
+
return false;
|
|
31
66
|
}
|
|
67
|
+
this.showPopover({ source: visibleAncestor });
|
|
68
|
+
return true;
|
|
32
69
|
}
|
|
33
70
|
async _setOpenState(open) {
|
|
34
|
-
let state;
|
|
35
71
|
if (open) {
|
|
36
|
-
this.open =
|
|
37
|
-
|
|
72
|
+
this.open = true;
|
|
73
|
+
if (!this._showPopover()) {
|
|
74
|
+
this.open = false;
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const state = await this._player.playExclusive(fadeIn());
|
|
38
78
|
this._setAutoHideTimer();
|
|
79
|
+
return state;
|
|
39
80
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
81
|
+
clearTimeout(this._autoHideTimeout);
|
|
82
|
+
const state = await this._player.playExclusive(fadeOut());
|
|
83
|
+
this.hidePopover();
|
|
84
|
+
this.open = false;
|
|
45
85
|
return state;
|
|
46
86
|
}
|
|
47
87
|
_setAutoHideTimer() {
|
|
@@ -72,4 +112,7 @@ __decorate([
|
|
|
72
112
|
__decorate([
|
|
73
113
|
property({ reflect: true })
|
|
74
114
|
], IgcBaseAlertLikeComponent.prototype, "position", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ reflect: true })
|
|
117
|
+
], IgcBaseAlertLikeComponent.prototype, "positioning", void 0);
|
|
75
118
|
//# sourceMappingURL=alert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../../../src/components/common/mixins/alert.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../../../src/components/common/mixins/alert.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE/D,MAAM,OAAgB,yBAA0B,SAAQ,UAAU;IAyDhE;QACE,KAAK,EAAE,CAAC;QAzDS,YAAO,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAWnD,SAAI,GAAG,KAAK,CAAC;QASb,gBAAW,GAAG,IAAI,CAAC;QASnB,aAAQ,GAAG,KAAK,CAAC;QAajB,aAAQ,GAAqB,QAAQ,CAAC;QAYtC,gBAAW,GAA6B,UAAU,CAAC;QAKxD,oBAAoB,CAAC,IAAI,CAAC;aACvB,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC;aACxB,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC;aACxB,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAEhC,sBAAsB,CAAC,IAAI,EAAE;YAC3B,WAAW,EA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AC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAQM,KAAK,CAAC,IAAI;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACvD,CAAC;IAQM,KAAK,CAAC,MAAM;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC/C,CAAC;CACF;AAnKQ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uDACvB;AASb;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;8DAC5B;AASnB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;2DAC3C;AAajB;IADN,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2DACiB;AAYtC;IADN,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8DAC8B","sourcesContent":["import { LitElement, type PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { addAnimationController } from '../../../animations/player.js';\nimport { fadeIn, fadeOut } from '../../../animations/presets/fade/index.js';\nimport type { AbsolutePosition } from '../../types.js';\nimport { addCommandController } from '../controllers/command.js';\nimport { addInternalsController } from '../controllers/internals.js';\nimport { getVisibleAncestor, isPopoverOpen } from '../util.js';\n\nexport abstract class IgcBaseAlertLikeComponent extends LitElement {\n protected readonly _player = addAnimationController(this);\n\n protected _autoHideTimeout?: ReturnType<typeof setTimeout>;\n\n /**\n * Whether the component is in shown state.\n *\n * @attr open\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n /**\n * Determines the duration in milliseconds in which the component will be visible.\n *\n * @attr display-time\n * @default 4000\n */\n @property({ type: Number, attribute: 'display-time' })\n public displayTime = 4000;\n\n /**\n * Determines whether the component should close after the `displayTime` is over.\n *\n * @attr keep-open\n * @default false\n */\n @property({ type: Boolean, reflect: true, attribute: 'keep-open' })\n public keepOpen = false;\n\n /**\n * Sets the position of the component in the viewport.\n *\n * `bottom` - positions the component at the bottom. This is the default.\n * `middle` - positions the component at the center.\n * `top` - positions the component at the top.\n *\n * @attr position\n * @default 'bottom'\n */\n @property({ reflect: true })\n public position: AbsolutePosition = 'bottom';\n\n /**\n * Sets the positioning strategy of the component.\n *\n * `viewport` - positions the component relative to the viewport, ignoring any ancestor elements. This is the default behavior.\n * `container` - positions the component relative to the nearest visible ancestor. In this mode, the component will be constrained within the bounding box of the ancestor and will be positioned according to the `position` attribute.\n *\n * @attr positioning\n * @default 'viewport'\n */\n @property({ reflect: true })\n public positioning: 'viewport' | 'container' = 'viewport';\n\n constructor() {\n super();\n\n addCommandController(this)\n .set('--show', this.show)\n .set('--hide', this.hide)\n .set('--toggle', this.toggle);\n\n addInternalsController(this, {\n initialARIA: {\n role: 'status',\n ariaLive: 'polite',\n },\n });\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.popover = 'manual';\n }\n\n protected override update(props: PropertyValues<this>): void {\n if (props.has('open')) {\n if (this.open && !isPopoverOpen(this)) {\n this._showPopover();\n } else if (!this.open && isPopoverOpen(this)) {\n this.hidePopover();\n }\n }\n\n if (this.open && (props.has('positioning') || props.has('position'))) {\n this.hidePopover();\n this._showPopover();\n }\n\n if (\n props.has('open') ||\n props.has('displayTime') ||\n props.has('keepOpen')\n ) {\n this._setAutoHideTimer();\n }\n\n super.update(props);\n }\n\n private _showPopover(): boolean {\n if (this.positioning !== 'container') {\n this.showPopover();\n return true;\n }\n\n const visibleAncestor = getVisibleAncestor(this);\n if (!visibleAncestor) {\n return false;\n }\n\n this.showPopover({ source: visibleAncestor });\n return true;\n }\n\n private async _setOpenState(open: boolean): Promise<boolean> {\n if (open) {\n this.open = true;\n\n if (!this._showPopover()) {\n this.open = false;\n return false;\n }\n\n const state = await this._player.playExclusive(fadeIn());\n this._setAutoHideTimer();\n return state;\n }\n\n clearTimeout(this._autoHideTimeout);\n const state = await this._player.playExclusive(fadeOut());\n this.hidePopover();\n this.open = false;\n return state;\n }\n\n private _setAutoHideTimer(): void {\n clearTimeout(this._autoHideTimeout);\n if (this.open && this.displayTime > 0 && !this.keepOpen) {\n this._autoHideTimeout = setTimeout(() => this.hide(), this.displayTime);\n }\n }\n\n /**\n * Opens the component.\n *\n * Returns a promise that resolves to `true` if the component was successfully opened, or `false`\n * if it was already open or could not be shown (e.g., in `container` positioning mode with no visible ancestors).\n */\n public async show(): Promise<boolean> {\n return this.open ? false : this._setOpenState(true);\n }\n\n /**\n * Closes the component.\n *\n * Returns a promise that resolves to `true` if the component was successfully closed, or `false`\n * if it was already closed.\n */\n public async hide(): Promise<boolean> {\n return this.open ? this._setOpenState(false) : false;\n }\n\n /**\n * Toggles the open state of the component.\n *\n * Returns a promise that resolves to `true` if the operation completed successfully, or `false`\n * if it was already in the desired state.\n */\n public async toggle(): Promise<boolean> {\n return this.open ? this.hide() : this.show();\n }\n}\n"]}
|
|
@@ -6,6 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { property } from 'lit/decorators.js';
|
|
8
8
|
import { addInternalsController } from '../../controllers/internals.js';
|
|
9
|
+
import { enterKey } from '../../controllers/key-bindings.js';
|
|
9
10
|
import { addSafeEventListener, isFunction, isString } from '../../util.js';
|
|
10
11
|
import { InternalInvalidEvent, InternalResetEvent, } from './types.js';
|
|
11
12
|
const INVALID_STATE = 'ig-invalid';
|
|
@@ -78,6 +79,16 @@ function BaseFormAssociated(base) {
|
|
|
78
79
|
this._touched = false;
|
|
79
80
|
this._validate();
|
|
80
81
|
}
|
|
82
|
+
_handleEnterKeydown(event) {
|
|
83
|
+
if (event.key !== enterKey)
|
|
84
|
+
return;
|
|
85
|
+
if (event.repeat)
|
|
86
|
+
return;
|
|
87
|
+
const canSubmit = this.form && (this.form.noValidate || this.checkValidity());
|
|
88
|
+
if (canSubmit) {
|
|
89
|
+
this.form?.requestSubmit();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
81
92
|
async _handleInvalid(event) {
|
|
82
93
|
event.preventDefault();
|
|
83
94
|
this._invalid = true;
|