@aleph-alpha/settings-kit 0.1.0 → 1.0.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/README.md +465 -15
- package/dist/SkLayout.vue_vue_type_script_setup_true_lang-ZjV2AMdR.js +51 -0
- package/dist/SkLayoutPage-DGbCpQFm.js +2545 -0
- package/dist/UseFileConvertor-DN6cCXNi.js +50 -0
- package/dist/components/SkField/SkField.vue.d.ts +28 -0
- package/dist/components/SkField/SkField.vue.d.ts.map +1 -0
- package/dist/components/SkField/index.d.ts +2 -0
- package/dist/components/SkField/index.d.ts.map +1 -0
- package/dist/components/SkGroup/SkGroup.vue.d.ts +29 -0
- package/dist/components/SkGroup/SkGroup.vue.d.ts.map +1 -0
- package/dist/components/SkGroup/index.d.ts +2 -0
- package/dist/components/SkGroup/index.d.ts.map +1 -0
- package/dist/components/SkItem/SkItem.vue.d.ts +22 -0
- package/dist/components/SkItem/SkItem.vue.d.ts.map +1 -0
- package/dist/components/SkItem/index.d.ts +2 -0
- package/dist/components/SkItem/index.d.ts.map +1 -0
- package/dist/components/SkLayout/SkLayout.vue.d.ts +53 -0
- package/dist/components/SkLayout/SkLayout.vue.d.ts.map +1 -0
- package/dist/components/SkLayout/SkLayoutPage.d.ts +23 -0
- package/dist/components/SkLayout/SkLayoutPage.d.ts.map +1 -0
- package/dist/components/SkLayout/context.d.ts +61 -0
- package/dist/components/SkLayout/context.d.ts.map +1 -0
- package/dist/components/SkLayout/index.d.ts +5 -0
- package/dist/components/SkLayout/index.d.ts.map +1 -0
- package/dist/components/SkPage/SkPage.vue.d.ts +35 -0
- package/dist/components/SkPage/SkPage.vue.d.ts.map +1 -0
- package/dist/components/SkPage/index.d.ts +2 -0
- package/dist/components/SkPage/index.d.ts.map +1 -0
- package/dist/components/SkSection/SkSection.vue.d.ts +29 -0
- package/dist/components/SkSection/SkSection.vue.d.ts.map +1 -0
- package/dist/components/SkSection/index.d.ts +2 -0
- package/dist/components/SkSection/index.d.ts.map +1 -0
- package/dist/components/controls/SkActionsControl/SkActionsControl.vue.d.ts +37 -0
- package/dist/components/controls/SkActionsControl/SkActionsControl.vue.d.ts.map +1 -0
- package/dist/components/controls/SkActionsControl/index.d.ts +2 -0
- package/dist/components/controls/SkActionsControl/index.d.ts.map +1 -0
- package/dist/components/controls/SkCheckboxControl/SkCheckboxControl.vue.d.ts +35 -0
- package/dist/components/controls/SkCheckboxControl/SkCheckboxControl.vue.d.ts.map +1 -0
- package/dist/components/controls/SkCheckboxControl/index.d.ts +2 -0
- package/dist/components/controls/SkCheckboxControl/index.d.ts.map +1 -0
- package/dist/components/controls/SkColorControl/SkColorControl.vue.d.ts +35 -0
- package/dist/components/controls/SkColorControl/SkColorControl.vue.d.ts.map +1 -0
- package/dist/components/controls/SkColorControl/index.d.ts +2 -0
- package/dist/components/controls/SkColorControl/index.d.ts.map +1 -0
- package/dist/components/controls/SkFileUpload/SkFilePlaceholder.vue.d.ts +11 -0
- package/dist/components/controls/SkFileUpload/SkFilePlaceholder.vue.d.ts.map +1 -0
- package/dist/components/controls/SkFileUpload/SkFileUpload.vue.d.ts +46 -0
- package/dist/components/controls/SkFileUpload/SkFileUpload.vue.d.ts.map +1 -0
- package/dist/components/controls/SkFileUpload/index.d.ts +2 -0
- package/dist/components/controls/SkFileUpload/index.d.ts.map +1 -0
- package/dist/components/controls/SkPeriodControl/SkPeriodControl.vue.d.ts +35 -0
- package/dist/components/controls/SkPeriodControl/SkPeriodControl.vue.d.ts.map +1 -0
- package/dist/components/controls/SkPeriodControl/index.d.ts +2 -0
- package/dist/components/controls/SkPeriodControl/index.d.ts.map +1 -0
- package/dist/components/controls/SkSelectControl/SkSelectControl.vue.d.ts +40 -0
- package/dist/components/controls/SkSelectControl/SkSelectControl.vue.d.ts.map +1 -0
- package/dist/components/controls/SkSelectControl/index.d.ts +2 -0
- package/dist/components/controls/SkSelectControl/index.d.ts.map +1 -0
- package/dist/components/controls/SkTelControl/SKTelPrefixControl.vue.d.ts +16 -0
- package/dist/components/controls/SkTelControl/SKTelPrefixControl.vue.d.ts.map +1 -0
- package/dist/components/controls/SkTelControl/SkTelControl.vue.d.ts +35 -0
- package/dist/components/controls/SkTelControl/SkTelControl.vue.d.ts.map +1 -0
- package/dist/components/controls/SkTelControl/index.d.ts +4 -0
- package/dist/components/controls/SkTelControl/index.d.ts.map +1 -0
- package/dist/components/controls/SkTelControl/prefixes.d.ts +26 -0
- package/dist/components/controls/SkTelControl/prefixes.d.ts.map +1 -0
- package/dist/components/controls/SkTextControl/SkTextControl.vue.d.ts +45 -0
- package/dist/components/controls/SkTextControl/SkTextControl.vue.d.ts.map +1 -0
- package/dist/components/controls/SkTextControl/index.d.ts +2 -0
- package/dist/components/controls/SkTextControl/index.d.ts.map +1 -0
- package/dist/components/controls/SkUnsupportedControl/SkUnsupportedControl.vue.d.ts +8 -0
- package/dist/components/controls/SkUnsupportedControl/SkUnsupportedControl.vue.d.ts.map +1 -0
- package/dist/components/controls/storyEventLog.d.ts +33 -0
- package/dist/components/controls/storyEventLog.d.ts.map +1 -0
- package/dist/components/index.d.ts +7 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +12 -2
- package/dist/composables/UseFileConvertor/UseFileConvertor.d.ts +7 -0
- package/dist/composables/UseFileConvertor/UseFileConvertor.d.ts.map +1 -0
- package/dist/composables/index.d.ts +14 -0
- package/dist/composables/index.d.ts.map +1 -0
- package/dist/composables/useFieldInheritance/useFieldInheritance.d.ts +24 -0
- package/dist/composables/useFieldInheritance/useFieldInheritance.d.ts.map +1 -0
- package/dist/composables/useFieldValidator/useFieldValidator.d.ts +50 -0
- package/dist/composables/useFieldValidator/useFieldValidator.d.ts.map +1 -0
- package/dist/composables/useSettingField/useSettingField.d.ts +24 -0
- package/dist/composables/useSettingField/useSettingField.d.ts.map +1 -0
- package/dist/composables/useSettingsForm/useSettingsForm.d.ts +12 -0
- package/dist/composables/useSettingsForm/useSettingsForm.d.ts.map +1 -0
- package/dist/composables/useSettingsLayout/useSettingsLayout.d.ts +71 -0
- package/dist/composables/useSettingsLayout/useSettingsLayout.d.ts.map +1 -0
- package/dist/composables/useSettingsLocale/useSettingsLocale.d.ts +38 -0
- package/dist/composables/useSettingsLocale/useSettingsLocale.d.ts.map +1 -0
- package/dist/composables/useStateManager/useStateManager.d.ts +10 -0
- package/dist/composables/useStateManager/useStateManager.d.ts.map +1 -0
- package/dist/core/controls/controlDefinitions.d.ts +33 -0
- package/dist/core/controls/controlDefinitions.d.ts.map +1 -0
- package/dist/core/controls/index.d.ts +26 -0
- package/dist/core/controls/index.d.ts.map +1 -0
- package/dist/core/index.d.ts +18 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/layout/index.d.ts +8 -0
- package/dist/core/layout/index.d.ts.map +1 -0
- package/dist/core/layout/navigation.d.ts +33 -0
- package/dist/core/layout/navigation.d.ts.map +1 -0
- package/dist/core/layout/resolve.d.ts +41 -0
- package/dist/core/layout/resolve.d.ts.map +1 -0
- package/dist/core/layout/types.d.ts +160 -0
- package/dist/core/layout/types.d.ts.map +1 -0
- package/dist/core/layout/validate.d.ts +26 -0
- package/dist/core/layout/validate.d.ts.map +1 -0
- package/dist/core/types.d.ts +541 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/useControlModel.d.ts +13 -0
- package/dist/core/useControlModel.d.ts.map +1 -0
- package/dist/core/utils/a11y.d.ts +25 -0
- package/dist/core/utils/a11y.d.ts.map +1 -0
- package/dist/core/utils/cast.d.ts +8 -0
- package/dist/core/utils/cast.d.ts.map +1 -0
- package/dist/core/utils/consts.d.ts +978 -0
- package/dist/core/utils/consts.d.ts.map +1 -0
- package/dist/core/utils/kitMessages.d.ts +165 -0
- package/dist/core/utils/kitMessages.d.ts.map +1 -0
- package/dist/core/utils/localizedText.d.ts +10 -0
- package/dist/core/utils/localizedText.d.ts.map +1 -0
- package/dist/core/utils/useName.d.ts +7 -0
- package/dist/core/utils/useName.d.ts.map +1 -0
- package/dist/core/validate/constraints.d.ts +20 -0
- package/dist/core/validate/constraints.d.ts.map +1 -0
- package/dist/core/validate/rules.d.ts +29 -0
- package/dist/core/validate/rules.d.ts.map +1 -0
- package/dist/index-BQ6z6MK4.js +214 -0
- package/dist/index-BXs-0JdT.js +168 -0
- package/dist/index-BynIH0EE.js +92 -0
- package/dist/index-C-WLhRod.js +100 -0
- package/dist/index-CFMv8jSO.js +4 -0
- package/dist/index-CGYERet5.js +373 -0
- package/dist/index-KAbhkO1J.js +81 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -3
- package/dist/service/index.d.ts +2 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/shell/SkShell.vue.d.ts +80 -0
- package/dist/shell/SkShell.vue.d.ts.map +1 -0
- package/dist/shell/SkShellFrame.vue.d.ts +46 -0
- package/dist/shell/SkShellFrame.vue.d.ts.map +1 -0
- package/dist/shell/SkShellNav.vue.d.ts +19 -0
- package/dist/shell/SkShellNav.vue.d.ts.map +1 -0
- package/dist/shell/history.d.ts +9 -0
- package/dist/shell/history.d.ts.map +1 -0
- package/dist/shell/index.d.ts +12 -0
- package/dist/shell/index.d.ts.map +1 -0
- package/dist/shell/index.js +848 -0
- package/dist/shell/labels.d.ts +25 -0
- package/dist/shell/labels.d.ts.map +1 -0
- package/dist/shell/location.d.ts +18 -0
- package/dist/shell/location.d.ts.map +1 -0
- package/dist/shell/routes.d.ts +19 -0
- package/dist/shell/routes.d.ts.map +1 -0
- package/dist/shell/useMediaQuery.d.ts +4 -0
- package/dist/shell/useMediaQuery.d.ts.map +1 -0
- package/dist/shell/useShellLocation.d.ts +37 -0
- package/dist/shell/useShellLocation.d.ts.map +1 -0
- package/package.json +42 -23
- package/dist/SettingToggleUnit.vue_vue_type_script_setup_true_lang-BM7-6aXj.js +0 -61
- package/dist/components/SettingToggleUnit/SettingToggleUnit.vue.d.ts +0 -16
- package/dist/components/SettingToggleUnit/SettingToggleUnit.vue.d.ts.map +0 -1
- package/dist/components/SettingToggleUnit/index.d.ts +0 -3
- package/dist/components/SettingToggleUnit/index.d.ts.map +0 -1
- package/dist/components/SettingToggleUnit/types.d.ts +0 -11
- package/dist/components/SettingToggleUnit/types.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/core/utils/consts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;CAWxB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;EAKhB,CAAC;AAEX,mDAAmD;AACnD,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;AAEnE,8CAA8C;AAC9C,MAAM,MAAM,SAAS,GAAG;IACtB,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyOa,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { LocalizedText } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* All wording the kit shows by itself. Placeholders use `{name}`.
|
|
4
|
+
* An application can replace any entry with `provideSettingsLocale`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const kitMessages: {
|
|
7
|
+
'constraint.required': {
|
|
8
|
+
en: string;
|
|
9
|
+
de: string;
|
|
10
|
+
};
|
|
11
|
+
'constraint.maxLength': {
|
|
12
|
+
en: string;
|
|
13
|
+
de: string;
|
|
14
|
+
};
|
|
15
|
+
'constraint.pattern': {
|
|
16
|
+
en: string;
|
|
17
|
+
de: string;
|
|
18
|
+
};
|
|
19
|
+
'constraint.enum': {
|
|
20
|
+
en: string;
|
|
21
|
+
de: string;
|
|
22
|
+
};
|
|
23
|
+
'constraint.format.hex': {
|
|
24
|
+
en: string;
|
|
25
|
+
de: string;
|
|
26
|
+
};
|
|
27
|
+
'constraint.format.email': {
|
|
28
|
+
en: string;
|
|
29
|
+
de: string;
|
|
30
|
+
};
|
|
31
|
+
'constraint.format.phone': {
|
|
32
|
+
en: string;
|
|
33
|
+
de: string;
|
|
34
|
+
};
|
|
35
|
+
'constraint.mimeTypes': {
|
|
36
|
+
en: string;
|
|
37
|
+
de: string;
|
|
38
|
+
};
|
|
39
|
+
'constraint.invalid': {
|
|
40
|
+
en: string;
|
|
41
|
+
de: string;
|
|
42
|
+
};
|
|
43
|
+
'field.inheritLabel': {
|
|
44
|
+
en: string;
|
|
45
|
+
de: string;
|
|
46
|
+
};
|
|
47
|
+
'field.inheritLabelDefault': {
|
|
48
|
+
en: string;
|
|
49
|
+
de: string;
|
|
50
|
+
};
|
|
51
|
+
'text.charCount': {
|
|
52
|
+
en: string;
|
|
53
|
+
de: string;
|
|
54
|
+
};
|
|
55
|
+
'control.unsupported': {
|
|
56
|
+
en: string;
|
|
57
|
+
de: string;
|
|
58
|
+
};
|
|
59
|
+
'control.unsupportedNamed': {
|
|
60
|
+
en: string;
|
|
61
|
+
de: string;
|
|
62
|
+
};
|
|
63
|
+
'file.upload': {
|
|
64
|
+
en: string;
|
|
65
|
+
de: string;
|
|
66
|
+
};
|
|
67
|
+
'file.preview': {
|
|
68
|
+
en: string;
|
|
69
|
+
de: string;
|
|
70
|
+
};
|
|
71
|
+
'file.previewDefault': {
|
|
72
|
+
en: string;
|
|
73
|
+
de: string;
|
|
74
|
+
};
|
|
75
|
+
'file.readError': {
|
|
76
|
+
en: string;
|
|
77
|
+
de: string;
|
|
78
|
+
};
|
|
79
|
+
'color.hexValue': {
|
|
80
|
+
en: string;
|
|
81
|
+
de: string;
|
|
82
|
+
};
|
|
83
|
+
'color.hexValueDefault': {
|
|
84
|
+
en: string;
|
|
85
|
+
de: string;
|
|
86
|
+
};
|
|
87
|
+
'tel.countryCode': {
|
|
88
|
+
en: string;
|
|
89
|
+
de: string;
|
|
90
|
+
};
|
|
91
|
+
'tel.search': {
|
|
92
|
+
en: string;
|
|
93
|
+
de: string;
|
|
94
|
+
};
|
|
95
|
+
'tel.searchCountry': {
|
|
96
|
+
en: string;
|
|
97
|
+
de: string;
|
|
98
|
+
};
|
|
99
|
+
'tel.countryCodes': {
|
|
100
|
+
en: string;
|
|
101
|
+
de: string;
|
|
102
|
+
};
|
|
103
|
+
'period.unitAria': {
|
|
104
|
+
en: string;
|
|
105
|
+
de: string;
|
|
106
|
+
};
|
|
107
|
+
'period.unit.d': {
|
|
108
|
+
en: string;
|
|
109
|
+
de: string;
|
|
110
|
+
};
|
|
111
|
+
'period.unit.w': {
|
|
112
|
+
en: string;
|
|
113
|
+
de: string;
|
|
114
|
+
};
|
|
115
|
+
'period.unit.m': {
|
|
116
|
+
en: string;
|
|
117
|
+
de: string;
|
|
118
|
+
};
|
|
119
|
+
'period.unit.y': {
|
|
120
|
+
en: string;
|
|
121
|
+
de: string;
|
|
122
|
+
};
|
|
123
|
+
'shell.title': {
|
|
124
|
+
en: string;
|
|
125
|
+
de: string;
|
|
126
|
+
};
|
|
127
|
+
'shell.back': {
|
|
128
|
+
en: string;
|
|
129
|
+
de: string;
|
|
130
|
+
};
|
|
131
|
+
'shell.toggleSidebar': {
|
|
132
|
+
en: string;
|
|
133
|
+
de: string;
|
|
134
|
+
};
|
|
135
|
+
'shell.navigation': {
|
|
136
|
+
en: string;
|
|
137
|
+
de: string;
|
|
138
|
+
};
|
|
139
|
+
'shell.layout': {
|
|
140
|
+
en: string;
|
|
141
|
+
de: string;
|
|
142
|
+
};
|
|
143
|
+
'shell.focusLayout': {
|
|
144
|
+
en: string;
|
|
145
|
+
de: string;
|
|
146
|
+
};
|
|
147
|
+
'shell.sidebarLayout': {
|
|
148
|
+
en: string;
|
|
149
|
+
de: string;
|
|
150
|
+
};
|
|
151
|
+
'shell.pageHasErrors': {
|
|
152
|
+
en: string;
|
|
153
|
+
de: string;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export type KitMessageKey = keyof typeof kitMessages;
|
|
157
|
+
/** Replacement wording per message key. */
|
|
158
|
+
export type KitMessageOverrides = Partial<Record<KitMessageKey, LocalizedText>>;
|
|
159
|
+
/** Copies `base`, then adds each non-empty text of `override`. An empty text counts as missing. */
|
|
160
|
+
export declare function mergeLocalizedText(base: LocalizedText | undefined, override: LocalizedText | undefined): LocalizedText;
|
|
161
|
+
/** Replaces each `{name}` in `template` with `params.name`. */
|
|
162
|
+
export declare function formatMessage(template: string, params?: Record<string, string | number>): string;
|
|
163
|
+
/** Kit wording for `key`. Overrides win over the built-in catalog. */
|
|
164
|
+
export declare function resolveKitMessage(key: KitMessageKey, locale?: string, fallbackLocale?: string, overrides?: KitMessageOverrides, params?: Record<string, string | number>): string;
|
|
165
|
+
//# sourceMappingURL=kitMessages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kitMessages.d.ts","sourceRoot":"","sources":["../../../src/core/utils/kitMessages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFiB,CAAC;AAE1C,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,WAAW,CAAC;AAErD,2CAA2C;AAC3C,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;AAEhF,mGAAmG;AACnG,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,aAAa,GAAG,SAAS,EAC/B,QAAQ,EAAE,aAAa,GAAG,SAAS,GAClC,aAAa,CAMf;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAM,GAC3C,MAAM,CAIR;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,aAAa,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,MAAM,EACvB,SAAS,CAAC,EAAE,mBAAmB,EAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACvC,MAAM,CAMR"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LocalizedText } from '../types';
|
|
2
|
+
/** Locale the kit falls back to when neither `locale` nor `fallbackLocale` has the text. */
|
|
3
|
+
export declare const DEFAULT_LOCALE = "en";
|
|
4
|
+
/**
|
|
5
|
+
* Resolves localized text. The first non-empty translation wins, in this
|
|
6
|
+
* order: `locale`, `fallbackLocale`, `DEFAULT_LOCALE`, any translation.
|
|
7
|
+
* Returns `''` only when the text has no translation at all.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveLocalizedText(text: LocalizedText, locale?: string, fallbackLocale?: string): string;
|
|
10
|
+
//# sourceMappingURL=localizedText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localizedText.d.ts","sourceRoot":"","sources":["../../../src/core/utils/localizedText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,4FAA4F;AAC5F,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,aAAa,EACnB,MAAM,GAAE,MAAuB,EAC/B,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,CAMR"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComputedRef } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a control's form name, falling back to its id and then to a
|
|
4
|
+
* random value stable for the component instance.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useName(name?: string): ComputedRef<string>;
|
|
7
|
+
//# sourceMappingURL=useName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useName.d.ts","sourceRoot":"","sources":["../../../src/core/utils/useName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAGvC;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAM1D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SettingField, StandardSchemaV1 } from '../types';
|
|
2
|
+
import type { KitMessageOverrides } from '../utils/kitMessages';
|
|
3
|
+
/** Names of the constraints a field's value violates, checked while editing. */
|
|
4
|
+
export declare function checkFieldConstraints(field: SettingField, value: unknown): string[];
|
|
5
|
+
/**
|
|
6
|
+
* Message for a violated constraint, in the admin's language. Wording the
|
|
7
|
+
* owning application declared on `field.errors` wins over the generic
|
|
8
|
+
* kit wording; a plain fallback covers unknown constraints. `messages`
|
|
9
|
+
* replaces generic wording per key.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveConstraintMessage(field: SettingField | undefined, constraint: string | undefined, locale: string, options?: {
|
|
12
|
+
fallbackLocale?: string;
|
|
13
|
+
messages?: KitMessageOverrides;
|
|
14
|
+
}): string;
|
|
15
|
+
/**
|
|
16
|
+
* The built-in constraint validator for one field, as a Standard Schema.
|
|
17
|
+
* Interchangeable with any external validator (zod, valibot, ...).
|
|
18
|
+
*/
|
|
19
|
+
export declare function createConstraintValidator(field: SettingField, locale?: string): StandardSchemaV1;
|
|
20
|
+
//# sourceMappingURL=constraints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../../../src/core/validate/constraints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAiB,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AA2F/E,gFAAgF;AAChF,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,OAAO,GACb,MAAM,EAAE,CAaV;AAWD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAA;CAAO,GACxE,MAAM,CAUR;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,YAAY,EACnB,MAAM,SAAO,GACZ,gBAAgB,CAgBlB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { SettingField, SettingFieldCondition } from '../types';
|
|
2
|
+
/** Rule outcome for one field. Defaults (no rules): visible and enabled. */
|
|
3
|
+
export interface SettingFieldRuleState {
|
|
4
|
+
visible: boolean;
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Evaluates a rule condition against the current setting values. */
|
|
8
|
+
export declare function evaluateCondition(condition: SettingFieldCondition, values: Record<string, unknown>): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Applies all of a field's rules against the current values. Every rule
|
|
11
|
+
* applies: a HIDE that holds (or a SHOW that does not) hides the field;
|
|
12
|
+
* a DISABLE that holds (or an ENABLE that does not) disables it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function evaluateFieldRules(field: SettingField, values: Record<string, unknown>): SettingFieldRuleState;
|
|
15
|
+
/**
|
|
16
|
+
* Rules middleware: overlays every field's visible/enabled state from its
|
|
17
|
+
* rules and the current values, keyed by setting key. The renderer stays
|
|
18
|
+
* rule-agnostic — it only consumes the resulting states.
|
|
19
|
+
*/
|
|
20
|
+
export declare function evaluateRuleStates(fields: SettingField[], values: Record<string, unknown>): Record<string, SettingFieldRuleState>;
|
|
21
|
+
/**
|
|
22
|
+
* Validates a definition set before use. Throws when a rule references an
|
|
23
|
+
* unknown setting key or when rules and fallbacks form a dependency cycle
|
|
24
|
+
* (A gates B gates A, or A falls back to B falls back to A). A rule may gate
|
|
25
|
+
* on its field's own value; a field may not fall back to itself. A fallback
|
|
26
|
+
* to an unknown key is allowed: it resolves to no source.
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateFieldRules(fields: SettingField[]): void;
|
|
29
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/core/validate/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EAEtB,MAAM,UAAU,CAAC;AAElB,4EAA4E;AAC5E,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AA0DD,qEAAqE;AACrE,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,qBAAqB,EAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAWT;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,qBAAqB,CAYvB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EAAE,EACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAMvC;AAUD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAoD/D"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, createBlock, unref, withCtx, createVNode, ref, watch, Fragment, createElementVNode, renderSlot, toDisplayString, createCommentVNode, createTextVNode, mergeProps, mergeDefaults } from "vue";
|
|
2
|
+
import { UiSpinner, UiTooltip, UiButton, UiIcon } from "@aleph-alpha/ui-library";
|
|
3
|
+
import { I as useSettingsLocale, N as useControlModel, O as useName, P as useA11yAttrs, T as skDescriptionId, Q as skBaseControlDefaults } from "./SkLayoutPage-DGbCpQFm.js";
|
|
4
|
+
import { U as UseFileConvertor } from "./UseFileConvertor-DN6cCXNi.js";
|
|
5
|
+
import { CircleAlertIcon } from "@aleph-alpha/ui-library/icons";
|
|
6
|
+
const _hoisted_1$1 = ["src", "alt"];
|
|
7
|
+
const fallbackImage = "data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='currentColor' height='78' width='78' viewBox='24 24 102 102'%3E%3Cpath d='m34.67 106.43-5.55-13.55A19.14 19.14 0 0 0 29 57.42l5.47-13.59a33.78 33.78 0 0 1 .2 62.6Zm22.93 17.12-8.68-11.8a45.28 45.28 0 0 0 8.61-8.27L69 112.62a59.82 59.82 0 0 1-11.4 10.93Z'/%3E%3Cpath d='M82.23 75.17a60.37 60.37 0 0 0-24.64-48.39l-8.68 11.81a45.63 45.63 0 0 1 18.68 36.58 60.28 60.28 0 0 0 24.48 48.38l8.68-11.8a45.6 45.6 0 0 1-18.52-36.58Zm9.85-28.23-11.47-9.12a60.14 60.14 0 0 1 11.94-11.37l8.56 11.88a45.5 45.5 0 0 0-9.03 8.61ZM115 106.52a34.32 34.32 0 0 1-.29-62.52l6.1 13.32a19.68 19.68 0 0 0 .19 35.83Z'/%3E%3C/svg%3E";
|
|
8
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
9
|
+
__name: "SkFilePlaceholder",
|
|
10
|
+
props: {
|
|
11
|
+
isDisabled: { type: Boolean },
|
|
12
|
+
preview: {},
|
|
13
|
+
label: {},
|
|
14
|
+
loading: { type: Boolean },
|
|
15
|
+
error: {}
|
|
16
|
+
},
|
|
17
|
+
setup(__props) {
|
|
18
|
+
const props = __props;
|
|
19
|
+
const { message } = useSettingsLocale();
|
|
20
|
+
const loadableSrc = /^(data:|blob:|https?:)/;
|
|
21
|
+
const previewSrc = computed(
|
|
22
|
+
() => props.preview && loadableSrc.test(props.preview) ? props.preview : fallbackImage
|
|
23
|
+
);
|
|
24
|
+
return (_ctx, _cache) => {
|
|
25
|
+
return openBlock(), createElementBlock("div", {
|
|
26
|
+
class: normalizeClass(["border-input rounded-xl border px-3", [__props.error ? "py-3.5" : "py-2.5", { "opacity-50": __props.isDisabled }]])
|
|
27
|
+
}, [
|
|
28
|
+
__props.loading ? (openBlock(), createBlock(unref(UiSpinner), {
|
|
29
|
+
key: 0,
|
|
30
|
+
class: "size-11"
|
|
31
|
+
})) : __props.error ? (openBlock(), createBlock(unref(UiTooltip), {
|
|
32
|
+
key: 1,
|
|
33
|
+
content: __props.error,
|
|
34
|
+
side: "top",
|
|
35
|
+
align: "center",
|
|
36
|
+
"delay-duration": 500
|
|
37
|
+
}, {
|
|
38
|
+
default: withCtx(() => [
|
|
39
|
+
createVNode(unref(UiButton), {
|
|
40
|
+
size: "icon-lg",
|
|
41
|
+
variant: "ghost",
|
|
42
|
+
"aria-label": __props.error
|
|
43
|
+
}, {
|
|
44
|
+
default: withCtx(() => [
|
|
45
|
+
createVNode(unref(UiIcon), {
|
|
46
|
+
name: unref(CircleAlertIcon),
|
|
47
|
+
class: "text-border-input-error"
|
|
48
|
+
}, null, 8, ["name"])
|
|
49
|
+
]),
|
|
50
|
+
_: 1
|
|
51
|
+
}, 8, ["aria-label"])
|
|
52
|
+
]),
|
|
53
|
+
_: 1
|
|
54
|
+
}, 8, ["content"])) : (openBlock(), createElementBlock("img", {
|
|
55
|
+
key: 2,
|
|
56
|
+
src: previewSrc.value,
|
|
57
|
+
alt: __props.label ? unref(message)("file.preview", { label: __props.label }) : unref(message)("file.previewDefault"),
|
|
58
|
+
width: "44",
|
|
59
|
+
height: "44",
|
|
60
|
+
class: "size-11"
|
|
61
|
+
}, null, 8, _hoisted_1$1))
|
|
62
|
+
], 2);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const _hoisted_1 = { class: "flex items-start gap-2" };
|
|
67
|
+
const _hoisted_2 = { class: "flex min-w-0 flex-1 flex-col gap-2" };
|
|
68
|
+
const _hoisted_3 = { class: "flex items-start gap-2" };
|
|
69
|
+
const _hoisted_4 = { class: "flex min-w-0 flex-1 flex-col" };
|
|
70
|
+
const _hoisted_5 = ["for"];
|
|
71
|
+
const _hoisted_6 = ["id"];
|
|
72
|
+
const _hoisted_7 = { key: 0 };
|
|
73
|
+
const _hoisted_8 = ["id", "name", "accept", "disabled", "required"];
|
|
74
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
75
|
+
...{
|
|
76
|
+
name: "SkFileUpload",
|
|
77
|
+
inheritAttrs: false
|
|
78
|
+
},
|
|
79
|
+
__name: "SkFileUpload",
|
|
80
|
+
props: /* @__PURE__ */ mergeDefaults({
|
|
81
|
+
modelValue: {},
|
|
82
|
+
id: {},
|
|
83
|
+
name: {},
|
|
84
|
+
placeholder: {},
|
|
85
|
+
disabled: { type: Boolean },
|
|
86
|
+
inheriting: { type: Boolean },
|
|
87
|
+
required: { type: Boolean },
|
|
88
|
+
label: {},
|
|
89
|
+
tooltip: {},
|
|
90
|
+
errors: {},
|
|
91
|
+
description: {},
|
|
92
|
+
accept: {}
|
|
93
|
+
}, {
|
|
94
|
+
...skBaseControlDefaults,
|
|
95
|
+
label: void 0,
|
|
96
|
+
description: void 0,
|
|
97
|
+
accept: ".png,.svg,image/png,image/svg+xml"
|
|
98
|
+
}),
|
|
99
|
+
emits: ["update:modelValue", "change"],
|
|
100
|
+
setup(__props, { emit: __emit }) {
|
|
101
|
+
const props = __props;
|
|
102
|
+
const emit = __emit;
|
|
103
|
+
const model = useControlModel(props, emit, "");
|
|
104
|
+
const fileInput = ref();
|
|
105
|
+
const {
|
|
106
|
+
isLoading: fileIsLoading,
|
|
107
|
+
error: fileError,
|
|
108
|
+
handleConvertFile,
|
|
109
|
+
reset
|
|
110
|
+
} = UseFileConvertor();
|
|
111
|
+
const { message } = useSettingsLocale();
|
|
112
|
+
const controlName = useName(props?.name ?? props?.id);
|
|
113
|
+
const a11yAttrs = useA11yAttrs([
|
|
114
|
+
"aria-label",
|
|
115
|
+
"aria-labelledby",
|
|
116
|
+
"aria-describedby",
|
|
117
|
+
"aria-invalid",
|
|
118
|
+
"aria-required",
|
|
119
|
+
"aria-errormessage"
|
|
120
|
+
]);
|
|
121
|
+
const descriptionId = computed(
|
|
122
|
+
() => props.id && props.description ? skDescriptionId(props.id) : void 0
|
|
123
|
+
);
|
|
124
|
+
const isDisabled = computed(() => props.disabled || props.inheriting);
|
|
125
|
+
watch(
|
|
126
|
+
() => [props.inheriting, model.value],
|
|
127
|
+
([inheriting]) => {
|
|
128
|
+
if (!inheriting) return;
|
|
129
|
+
reset();
|
|
130
|
+
if (fileInput.value) fileInput.value.value = "";
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
watch(fileError, (raw) => {
|
|
134
|
+
if (raw) console.error(raw);
|
|
135
|
+
});
|
|
136
|
+
function openPicker() {
|
|
137
|
+
if (!isDisabled.value) {
|
|
138
|
+
fileInput.value?.click();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async function handleFileChange(event) {
|
|
142
|
+
const file = event.target.files?.[0];
|
|
143
|
+
if (!file) return;
|
|
144
|
+
const dataUrl = await handleConvertFile(file);
|
|
145
|
+
if (dataUrl !== void 0) {
|
|
146
|
+
model.value = dataUrl;
|
|
147
|
+
emit("change", dataUrl);
|
|
148
|
+
event.target.value = "";
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return (_ctx, _cache) => {
|
|
152
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
153
|
+
createElementVNode("div", _hoisted_1, [
|
|
154
|
+
createVNode(_sfc_main$1, {
|
|
155
|
+
"is-disabled": isDisabled.value,
|
|
156
|
+
preview: unref(model),
|
|
157
|
+
label: __props.label,
|
|
158
|
+
loading: unref(fileIsLoading),
|
|
159
|
+
error: unref(fileError) ? unref(message)("file.readError") : void 0,
|
|
160
|
+
class: "shrink-0"
|
|
161
|
+
}, null, 8, ["is-disabled", "preview", "label", "loading", "error"]),
|
|
162
|
+
createElementVNode("div", _hoisted_2, [
|
|
163
|
+
createElementVNode("div", _hoisted_3, [
|
|
164
|
+
createElementVNode("div", _hoisted_4, [
|
|
165
|
+
renderSlot(_ctx.$slots, "label", {}, () => [
|
|
166
|
+
createElementVNode("label", {
|
|
167
|
+
for: __props.id,
|
|
168
|
+
class: "label-s-medium text-content-on-surface-primary font-medium"
|
|
169
|
+
}, toDisplayString(__props.label), 9, _hoisted_5)
|
|
170
|
+
]),
|
|
171
|
+
__props.description ? (openBlock(), createElementBlock("p", {
|
|
172
|
+
key: 0,
|
|
173
|
+
id: descriptionId.value,
|
|
174
|
+
class: "label-xs-regular text-content-on-surface-muted"
|
|
175
|
+
}, toDisplayString(__props.description), 9, _hoisted_6)) : createCommentVNode("", true)
|
|
176
|
+
]),
|
|
177
|
+
createVNode(unref(UiButton), {
|
|
178
|
+
variant: "secondary",
|
|
179
|
+
class: "ml-auto shrink-0",
|
|
180
|
+
disabled: isDisabled.value,
|
|
181
|
+
onClick: openPicker
|
|
182
|
+
}, {
|
|
183
|
+
default: withCtx(() => [
|
|
184
|
+
createTextVNode(toDisplayString(unref(message)("file.upload")), 1)
|
|
185
|
+
]),
|
|
186
|
+
_: 1
|
|
187
|
+
}, 8, ["disabled"])
|
|
188
|
+
]),
|
|
189
|
+
_ctx.$slots.addons ? (openBlock(), createElementBlock("div", _hoisted_7, [
|
|
190
|
+
renderSlot(_ctx.$slots, "addons")
|
|
191
|
+
])) : createCommentVNode("", true)
|
|
192
|
+
]),
|
|
193
|
+
createElementVNode("input", mergeProps({
|
|
194
|
+
id: __props.id,
|
|
195
|
+
ref_key: "fileInput",
|
|
196
|
+
ref: fileInput
|
|
197
|
+
}, unref(a11yAttrs), {
|
|
198
|
+
type: "file",
|
|
199
|
+
class: "sr-only",
|
|
200
|
+
name: unref(controlName),
|
|
201
|
+
accept: __props.accept,
|
|
202
|
+
disabled: isDisabled.value,
|
|
203
|
+
required: __props.required,
|
|
204
|
+
onChange: handleFileChange
|
|
205
|
+
}), null, 16, _hoisted_8)
|
|
206
|
+
]),
|
|
207
|
+
renderSlot(_ctx.$slots, "error")
|
|
208
|
+
], 64);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
export {
|
|
213
|
+
_sfc_main as SkFileUpload
|
|
214
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, watch, openBlock, createElementBlock, Fragment, renderSlot, createVNode, unref, withCtx, mergeProps, createElementVNode, toDisplayString, renderList, createBlock, createCommentVNode, mergeDefaults } from "vue";
|
|
2
|
+
import { UiButtonGroup, UiInput, UiDropdownMenu, UiDropdownMenuTrigger, UiButton, UiIcon, UiDropdownMenuContent, UiDropdownMenuItem } from "@aleph-alpha/ui-library";
|
|
3
|
+
import { ChevronDownIcon, CheckIcon } from "@aleph-alpha/ui-library/icons";
|
|
4
|
+
import { N as useControlModel, I as useSettingsLocale, O as useName, P as useA11yAttrs, R as skPeriodUnits, Q as skBaseControlDefaults } from "./SkLayoutPage-DGbCpQFm.js";
|
|
5
|
+
const _hoisted_1 = { class: "body-s-regular !font-medium text-content-on-surface-primary" };
|
|
6
|
+
const _hoisted_2 = { class: "flex-1 body-s-regular text-content-on-surface-primary" };
|
|
7
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
|
+
...{
|
|
9
|
+
name: "SkPeriodControl",
|
|
10
|
+
inheritAttrs: false
|
|
11
|
+
},
|
|
12
|
+
__name: "SkPeriodControl",
|
|
13
|
+
props: /* @__PURE__ */ mergeDefaults({
|
|
14
|
+
modelValue: {},
|
|
15
|
+
id: {},
|
|
16
|
+
name: {},
|
|
17
|
+
placeholder: {},
|
|
18
|
+
disabled: { type: Boolean },
|
|
19
|
+
inheriting: { type: Boolean },
|
|
20
|
+
required: { type: Boolean },
|
|
21
|
+
label: {},
|
|
22
|
+
tooltip: {},
|
|
23
|
+
errors: {}
|
|
24
|
+
}, {
|
|
25
|
+
...skBaseControlDefaults
|
|
26
|
+
}),
|
|
27
|
+
emits: ["update:modelValue", "change"],
|
|
28
|
+
setup(__props, { emit: __emit }) {
|
|
29
|
+
const props = __props;
|
|
30
|
+
const emit = __emit;
|
|
31
|
+
const model = useControlModel(props, emit, "");
|
|
32
|
+
const { message } = useSettingsLocale();
|
|
33
|
+
const unitLabel = (unit2) => message(`period.unit.${unit2}`);
|
|
34
|
+
const controlName = useName(props?.name ?? props?.id);
|
|
35
|
+
const a11yAttrs = useA11yAttrs([
|
|
36
|
+
"aria-label",
|
|
37
|
+
"aria-labelledby",
|
|
38
|
+
"aria-describedby",
|
|
39
|
+
"aria-invalid",
|
|
40
|
+
"aria-required",
|
|
41
|
+
"aria-errormessage"
|
|
42
|
+
]);
|
|
43
|
+
const unitAliases = Object.fromEntries(
|
|
44
|
+
skPeriodUnits.flatMap(({ value, label }) => [
|
|
45
|
+
[value, value],
|
|
46
|
+
[label.toLowerCase(), value],
|
|
47
|
+
[label.toLowerCase().slice(0, -1), value]
|
|
48
|
+
])
|
|
49
|
+
);
|
|
50
|
+
function parsePeriod(value) {
|
|
51
|
+
const match = /^(\d+)[\s-]*([a-z]+)$/i.exec(value.trim());
|
|
52
|
+
const [, amountPart, unitPart] = match ?? [];
|
|
53
|
+
const unit2 = unitPart ? unitAliases[unitPart.toLowerCase()] : void 0;
|
|
54
|
+
if (!amountPart || !unit2) return void 0;
|
|
55
|
+
return { amount: amountPart, unit: unit2 };
|
|
56
|
+
}
|
|
57
|
+
function composePeriod(amount2, unit2) {
|
|
58
|
+
return amount2 ? `${amount2}${unit2}` : "";
|
|
59
|
+
}
|
|
60
|
+
const amount = ref("");
|
|
61
|
+
const unit = ref("d");
|
|
62
|
+
const composedPeriod = computed(() => composePeriod(amount.value, unit.value));
|
|
63
|
+
const selectedUnit = computed(
|
|
64
|
+
() => skPeriodUnits.find(({ value }) => value === unit.value) ?? skPeriodUnits[0]
|
|
65
|
+
);
|
|
66
|
+
watch(
|
|
67
|
+
() => model.value ?? "",
|
|
68
|
+
(value) => {
|
|
69
|
+
if (value === composedPeriod.value) return;
|
|
70
|
+
const parsed = parsePeriod(value);
|
|
71
|
+
if (parsed) {
|
|
72
|
+
amount.value = parsed.amount;
|
|
73
|
+
unit.value = parsed.unit;
|
|
74
|
+
} else {
|
|
75
|
+
amount.value = value.replace(/\D/g, "");
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{ immediate: true }
|
|
79
|
+
);
|
|
80
|
+
const amountInput = computed({
|
|
81
|
+
get: () => amount.value,
|
|
82
|
+
set: (value) => {
|
|
83
|
+
amount.value = String(value ?? "").replace(/\D/g, "");
|
|
84
|
+
model.value = composedPeriod.value;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
function selectUnit(value) {
|
|
88
|
+
unit.value = value;
|
|
89
|
+
model.value = composedPeriod.value;
|
|
90
|
+
emit("change", composedPeriod.value);
|
|
91
|
+
}
|
|
92
|
+
return (_ctx, _cache) => {
|
|
93
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
94
|
+
renderSlot(_ctx.$slots, "label"),
|
|
95
|
+
createVNode(unref(UiButtonGroup), { class: "w-full" }, {
|
|
96
|
+
default: withCtx(() => [
|
|
97
|
+
createVNode(unref(UiInput), mergeProps({
|
|
98
|
+
id: __props.id,
|
|
99
|
+
modelValue: amountInput.value,
|
|
100
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => amountInput.value = $event)
|
|
101
|
+
}, unref(a11yAttrs), {
|
|
102
|
+
type: "text",
|
|
103
|
+
inputmode: "numeric",
|
|
104
|
+
name: unref(controlName),
|
|
105
|
+
placeholder: __props.placeholder,
|
|
106
|
+
disabled: __props.disabled,
|
|
107
|
+
required: __props.required,
|
|
108
|
+
onChange: _cache[1] || (_cache[1] = ($event) => emit("change", composedPeriod.value))
|
|
109
|
+
}), null, 16, ["id", "modelValue", "name", "placeholder", "disabled", "required"]),
|
|
110
|
+
createVNode(unref(UiDropdownMenu), null, {
|
|
111
|
+
default: withCtx(() => [
|
|
112
|
+
createVNode(unref(UiDropdownMenuTrigger), { "as-child": "" }, {
|
|
113
|
+
default: withCtx(() => [
|
|
114
|
+
createVNode(unref(UiButton), {
|
|
115
|
+
variant: "outline",
|
|
116
|
+
class: "rounded-md",
|
|
117
|
+
disabled: __props.disabled,
|
|
118
|
+
"aria-label": unref(message)("period.unitAria", { unit: unitLabel(selectedUnit.value.value) })
|
|
119
|
+
}, {
|
|
120
|
+
default: withCtx(() => [
|
|
121
|
+
createElementVNode("span", _hoisted_1, toDisplayString(unitLabel(selectedUnit.value.value)), 1),
|
|
122
|
+
createVNode(unref(UiIcon), {
|
|
123
|
+
name: unref(ChevronDownIcon),
|
|
124
|
+
class: "shrink-0 text-content-on-surface-primary"
|
|
125
|
+
}, null, 8, ["name"])
|
|
126
|
+
]),
|
|
127
|
+
_: 1
|
|
128
|
+
}, 8, ["disabled", "aria-label"])
|
|
129
|
+
]),
|
|
130
|
+
_: 1
|
|
131
|
+
}),
|
|
132
|
+
createVNode(unref(UiDropdownMenuContent), { align: "start" }, {
|
|
133
|
+
default: withCtx(() => [
|
|
134
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(skPeriodUnits), (periodUnit) => {
|
|
135
|
+
return openBlock(), createBlock(unref(UiDropdownMenuItem), {
|
|
136
|
+
key: periodUnit.value,
|
|
137
|
+
"text-value": unitLabel(periodUnit.value),
|
|
138
|
+
onSelect: ($event) => selectUnit(periodUnit.value)
|
|
139
|
+
}, {
|
|
140
|
+
default: withCtx(() => [
|
|
141
|
+
createElementVNode("span", _hoisted_2, toDisplayString(unitLabel(periodUnit.value)), 1),
|
|
142
|
+
periodUnit.value === unit.value ? (openBlock(), createBlock(unref(UiIcon), {
|
|
143
|
+
key: 0,
|
|
144
|
+
name: unref(CheckIcon),
|
|
145
|
+
size: "s",
|
|
146
|
+
class: "shrink-0"
|
|
147
|
+
}, null, 8, ["name"])) : createCommentVNode("", true)
|
|
148
|
+
]),
|
|
149
|
+
_: 2
|
|
150
|
+
}, 1032, ["text-value", "onSelect"]);
|
|
151
|
+
}), 128))
|
|
152
|
+
]),
|
|
153
|
+
_: 1
|
|
154
|
+
})
|
|
155
|
+
]),
|
|
156
|
+
_: 1
|
|
157
|
+
})
|
|
158
|
+
]),
|
|
159
|
+
_: 1
|
|
160
|
+
}),
|
|
161
|
+
renderSlot(_ctx.$slots, "error")
|
|
162
|
+
], 64);
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
export {
|
|
167
|
+
_sfc_main as SkPeriodControl
|
|
168
|
+
};
|