@xleddyl/443-components-vue 0.1.0 → 0.2.2

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.
Files changed (215) hide show
  1. package/README.md +81 -20
  2. package/dist/chart/BarChart.vue.d.ts +6 -6
  3. package/dist/chart/ChartLegend.vue.d.ts +16 -16
  4. package/dist/chart/ChartPanel.vue +10 -6
  5. package/dist/chart/ChartPanel.vue.d.ts +6 -8
  6. package/dist/chart/ChartSummary.vue.d.ts +6 -6
  7. package/dist/chart/DoughnutChart.vue.d.ts +6 -6
  8. package/dist/chart/LineChart.vue.d.ts +6 -6
  9. package/dist/components/core/Button.vue +3 -1
  10. package/dist/components/core/Button.vue.d.ts +6 -6
  11. package/dist/components/core/FormField.vue.d.ts +6 -6
  12. package/dist/components/core/Icon.vue +9 -1
  13. package/dist/components/core/Icon.vue.d.ts +4 -4
  14. package/dist/components/core/Input.vue +6 -3
  15. package/dist/components/core/Input.vue.d.ts +18 -19
  16. package/dist/components/core/Kbd.vue.d.ts +6 -6
  17. package/dist/components/core/Root.vue.d.ts +10 -10
  18. package/dist/components/core/Spinner.vue +7 -3
  19. package/dist/components/core/Spinner.vue.d.ts +6 -7
  20. package/dist/components/core/Textarea.vue +36 -23
  21. package/dist/components/core/Textarea.vue.d.ts +31 -21
  22. package/dist/components/core/VisuallyHidden.vue.d.ts +10 -10
  23. package/dist/components/data/Avatar.vue +4 -2
  24. package/dist/components/data/Avatar.vue.d.ts +6 -6
  25. package/dist/components/data/AvatarGroup.vue +5 -2
  26. package/dist/components/data/AvatarGroup.vue.d.ts +7 -8
  27. package/dist/components/data/Badge.vue.d.ts +6 -6
  28. package/dist/components/data/DescriptionList.vue +7 -3
  29. package/dist/components/data/DescriptionList.vue.d.ts +7 -8
  30. package/dist/components/data/FilterPills.vue +13 -4
  31. package/dist/components/data/FilterPills.vue.d.ts +16 -18
  32. package/dist/components/data/Pagination.vue +23 -14
  33. package/dist/components/data/Pagination.vue.d.ts +16 -23
  34. package/dist/components/data/Stat.vue +9 -6
  35. package/dist/components/data/Stat.vue.d.ts +10 -13
  36. package/dist/components/data/Table.vue +12 -7
  37. package/dist/components/data/Tag.vue +7 -4
  38. package/dist/components/data/Tag.vue.d.ts +16 -17
  39. package/dist/components/data/Timeline.vue.d.ts +6 -6
  40. package/dist/components/data/Tree.vue +5 -2
  41. package/dist/components/data/Tree.vue.d.ts +16 -17
  42. package/dist/components/feedback/Alert.vue +5 -2
  43. package/dist/components/feedback/Alert.vue.d.ts +14 -15
  44. package/dist/components/feedback/EmptyState.vue.d.ts +7 -7
  45. package/dist/components/feedback/LoadingOverlay.vue +8 -4
  46. package/dist/components/feedback/LoadingOverlay.vue.d.ts +6 -7
  47. package/dist/components/feedback/Meter.vue.d.ts +6 -6
  48. package/dist/components/feedback/Progress.vue +6 -3
  49. package/dist/components/feedback/Progress.vue.d.ts +6 -7
  50. package/dist/components/feedback/ProgressRing.vue +5 -2
  51. package/dist/components/feedback/ProgressRing.vue.d.ts +6 -7
  52. package/dist/components/feedback/Skeleton.vue.d.ts +6 -6
  53. package/dist/components/forms/Calendar.vue +16 -11
  54. package/dist/components/forms/Calendar.vue.d.ts +17 -21
  55. package/dist/components/forms/ColorInput.vue +8 -4
  56. package/dist/components/forms/ColorInput.vue.d.ts +18 -20
  57. package/dist/components/forms/Combobox.vue +31 -19
  58. package/dist/components/forms/Combobox.vue.d.ts +2 -2
  59. package/dist/components/forms/DateInput.vue.d.ts +16 -16
  60. package/dist/components/forms/DatePicker.vue +17 -11
  61. package/dist/components/forms/DatePicker.vue.d.ts +14 -18
  62. package/dist/components/forms/FileInput.vue +23 -13
  63. package/dist/components/forms/FileInput.vue.d.ts +17 -23
  64. package/dist/components/forms/InputAddon.vue.d.ts +6 -6
  65. package/dist/components/forms/InputGroup.vue.d.ts +6 -6
  66. package/dist/components/forms/NumberInput.vue +15 -10
  67. package/dist/components/forms/NumberInput.vue.d.ts +16 -19
  68. package/dist/components/forms/PasswordInput.vue +21 -13
  69. package/dist/components/forms/PasswordInput.vue.d.ts +14 -20
  70. package/dist/components/forms/PinInput.vue +7 -2
  71. package/dist/components/forms/PinInput.vue.d.ts +18 -16
  72. package/dist/components/forms/Radio.vue.d.ts +6 -6
  73. package/dist/components/forms/Slider.vue.d.ts +18 -18
  74. package/dist/components/forms/Switch.vue.d.ts +16 -16
  75. package/dist/components/forms/TimeInput.vue.d.ts +16 -16
  76. package/dist/components/layout/Accordion.vue.d.ts +16 -16
  77. package/dist/components/layout/AppShell.vue +11 -6
  78. package/dist/components/layout/AppShell.vue.d.ts +16 -19
  79. package/dist/components/layout/Breadcrumbs.vue +5 -2
  80. package/dist/components/layout/Breadcrumbs.vue.d.ts +6 -7
  81. package/dist/components/layout/Card.vue.d.ts +8 -8
  82. package/dist/components/layout/CopyButton.vue +11 -6
  83. package/dist/components/layout/CopyButton.vue.d.ts +16 -18
  84. package/dist/components/layout/Grid.vue.d.ts +7 -7
  85. package/dist/components/layout/NavLink.vue.d.ts +10 -10
  86. package/dist/components/layout/PageHeader.vue.d.ts +6 -6
  87. package/dist/components/layout/Separator.vue.d.ts +6 -6
  88. package/dist/components/layout/Sidebar.vue +10 -5
  89. package/dist/components/layout/Sidebar.vue.d.ts +7 -11
  90. package/dist/components/layout/SidebarSection.vue.d.ts +6 -6
  91. package/dist/components/layout/Stack.vue.d.ts +10 -10
  92. package/dist/components/layout/Tabs.vue.d.ts +16 -16
  93. package/dist/components/layout/ThemeSwitch.vue +12 -6
  94. package/dist/components/layout/ThemeSwitch.vue.d.ts +6 -7
  95. package/dist/components/layout/Toolbar.vue.d.ts +6 -6
  96. package/dist/components/overlays/CommandPalette.vue +38 -24
  97. package/dist/components/overlays/CommandPalette.vue.d.ts +18 -30
  98. package/dist/components/overlays/ConfirmDialog.vue +14 -9
  99. package/dist/components/overlays/ConfirmDialog.vue.d.ts +12 -15
  100. package/dist/components/overlays/ConfirmHost.vue +6 -3
  101. package/dist/components/overlays/ConfirmHost.vue.d.ts +16 -16
  102. package/dist/components/overlays/ContextMenu.vue +6 -3
  103. package/dist/components/overlays/ContextMenu.vue.d.ts +11 -13
  104. package/dist/components/overlays/Drawer.vue +1 -1
  105. package/dist/components/overlays/Drawer.vue.d.ts +10 -11
  106. package/dist/components/overlays/DropdownMenu.vue.d.ts +10 -10
  107. package/dist/components/overlays/HoverCard.vue.d.ts +16 -16
  108. package/dist/components/overlays/Modal.vue +1 -1
  109. package/dist/components/overlays/Modal.vue.d.ts +10 -11
  110. package/dist/components/overlays/OverlayHost.vue.d.ts +1 -1
  111. package/dist/components/overlays/Popover.vue.d.ts +16 -16
  112. package/dist/components/overlays/Toaster.vue +8 -4
  113. package/dist/components/overlays/Toaster.vue.d.ts +8 -10
  114. package/dist/components/overlays/Tooltip.vue.d.ts +6 -6
  115. package/dist/components/templates/AccountMenu.vue +5 -2
  116. package/dist/components/templates/AccountMenu.vue.d.ts +18 -19
  117. package/dist/components/templates/AppearanceSettings.vue +26 -12
  118. package/dist/components/templates/AppearanceSettings.vue.d.ts +7 -11
  119. package/dist/components/templates/AuthLayout.vue +11 -7
  120. package/dist/components/templates/AuthLayout.vue.d.ts +6 -9
  121. package/dist/components/templates/Brand.vue.d.ts +10 -10
  122. package/dist/components/templates/DashboardLayout.vue +25 -16
  123. package/dist/components/templates/DashboardLayout.vue.d.ts +12 -24
  124. package/dist/components/templates/DashboardPage.vue +7 -3
  125. package/dist/components/templates/DashboardPage.vue.d.ts +6 -7
  126. package/dist/components/templates/DetailPage.vue +14 -8
  127. package/dist/components/templates/DetailPage.vue.d.ts +14 -18
  128. package/dist/components/templates/EmptyPage.vue +15 -8
  129. package/dist/components/templates/EmptyPage.vue.d.ts +7 -11
  130. package/dist/components/templates/ErrorPage.vue +32 -25
  131. package/dist/components/templates/ErrorPage.vue.d.ts +6 -6
  132. package/dist/components/templates/FormPage.vue +19 -11
  133. package/dist/components/templates/FormPage.vue.d.ts +3 -3
  134. package/dist/components/templates/ListPage.vue +39 -23
  135. package/dist/components/templates/ListPage.vue.d.ts +2 -2
  136. package/dist/components/templates/NotFoundPage.vue +4 -4
  137. package/dist/components/templates/NotFoundPage.vue.d.ts +1 -1
  138. package/dist/components/templates/SaveBar.vue +20 -11
  139. package/dist/components/templates/SaveBar.vue.d.ts +16 -19
  140. package/dist/components/templates/SettingsGroup.vue.d.ts +7 -7
  141. package/dist/components/templates/SettingsModal.vue +29 -21
  142. package/dist/components/templates/SettingsModal.vue.d.ts +15 -25
  143. package/dist/components/templates/SettingsPage.vue +8 -5
  144. package/dist/components/templates/SettingsPage.vue.d.ts +18 -21
  145. package/dist/components/templates/SettingsSection.vue +7 -3
  146. package/dist/components/templates/SettingsSection.vue.d.ts +8 -9
  147. package/dist/composables/core.d.ts +1 -0
  148. package/dist/composables/core.mjs +1 -0
  149. package/dist/composables/useAlert.mjs +3 -1
  150. package/dist/composables/useConfirm.mjs +5 -3
  151. package/dist/composables/useDirtyGuard.mjs +7 -5
  152. package/dist/composables/useForm.d.ts +4 -1
  153. package/dist/composables/useForm.mjs +33 -16
  154. package/dist/composables/useIcons.d.ts +4 -0
  155. package/dist/composables/useIcons.mjs +10 -0
  156. package/dist/composables/useLocale.d.ts +11 -0
  157. package/dist/composables/useLocale.mjs +26 -0
  158. package/dist/composables/usePasswordStrength.mjs +11 -7
  159. package/dist/composables/usePrompt.mjs +3 -1
  160. package/dist/editor/RichTextEditor.vue +20 -14
  161. package/dist/editor/RichTextEditor.vue.d.ts +22 -15
  162. package/dist/editor/index.d.ts +0 -1
  163. package/dist/editor/index.mjs +0 -1
  164. package/dist/editor/types.d.ts +3 -18
  165. package/dist/grid/DataGrid.vue +11 -2
  166. package/dist/grid/GridToolbar.vue +6 -2
  167. package/dist/grid/GridToolbar.vue.d.ts +21 -20
  168. package/dist/grid/cells/BadgeCell.vue.d.ts +6 -6
  169. package/dist/grid/cells/BooleanCell.vue +5 -2
  170. package/dist/grid/cells/BooleanCell.vue.d.ts +6 -6
  171. package/dist/grid/cells/DateCell.vue +4 -1
  172. package/dist/grid/cells/DateCell.vue.d.ts +6 -6
  173. package/dist/grid/cells/ImageCell.vue.d.ts +6 -6
  174. package/dist/grid/cells/LinkCell.vue.d.ts +6 -6
  175. package/dist/grid/index.d.ts +0 -1
  176. package/dist/grid/index.mjs +0 -1
  177. package/dist/grid/types.d.ts +5 -17
  178. package/dist/icons/collections.d.ts +39 -0
  179. package/dist/icons/collections.mjs +67 -0
  180. package/dist/index.d.ts +4 -1
  181. package/dist/index.mjs +11 -1
  182. package/dist/internal/feedback/LoadingHost.vue +6 -3
  183. package/dist/internal/feedback/LoadingHost.vue.d.ts +0 -1
  184. package/dist/internal/forms/files.mjs +1 -1
  185. package/dist/internal/forms/standard-schema.d.ts +26 -0
  186. package/dist/internal/forms/standard-schema.mjs +21 -0
  187. package/dist/internal/keys.d.ts +4 -1
  188. package/dist/internal/keys.mjs +2 -0
  189. package/dist/internal/overlays/DialogFrame.vue +5 -2
  190. package/dist/internal/overlays/DialogFrame.vue.d.ts +14 -14
  191. package/dist/internal/overlays/MenuList.vue.d.ts +16 -16
  192. package/dist/internal/overlays/OverlayView.vue.d.ts +16 -16
  193. package/dist/internal/overlays/confirm.d.ts +3 -0
  194. package/dist/locale/en.d.ts +2 -0
  195. package/dist/locale/en.mjs +284 -0
  196. package/dist/locale/index.d.ts +16 -0
  197. package/dist/locale/index.mjs +50 -0
  198. package/dist/locale/it.d.ts +2 -0
  199. package/dist/locale/it.mjs +284 -0
  200. package/dist/locale/types.d.ts +292 -0
  201. package/dist/locale/types.mjs +0 -0
  202. package/dist/nuxt/module.d.ts +18 -4
  203. package/dist/nuxt/module.mjs +138 -9
  204. package/dist/nuxt/runtime/layouts/auth.vue.d.ts +16 -16
  205. package/dist/nuxt/runtime/layouts/dashboard.vue.d.ts +16 -16
  206. package/dist/nuxt/runtime/locale.d.ts +2 -0
  207. package/dist/nuxt/runtime/locale.mjs +20 -0
  208. package/dist/nuxt/runtime/theme.mjs +3 -3
  209. package/dist/styles/core/icon.css +4 -0
  210. package/dist/styles/core/textarea.css +21 -0
  211. package/package.json +1 -1
  212. package/dist/editor/messages.d.ts +0 -2
  213. package/dist/editor/messages.mjs +0 -18
  214. package/dist/grid/messages.d.ts +0 -3
  215. package/dist/grid/messages.mjs +0 -21
@@ -0,0 +1,292 @@
1
+ export type MessageParams = Record<string, string | number>;
2
+ export interface KMessages {
3
+ common: {
4
+ cancel: string;
5
+ confirm: string;
6
+ close: string;
7
+ ok: string;
8
+ clear: string;
9
+ loading: string;
10
+ areYouSure: string;
11
+ noResults: string;
12
+ remove: string;
13
+ dismiss: string;
14
+ copy: string;
15
+ copied: string;
16
+ search: string;
17
+ back: string;
18
+ save: string;
19
+ saveChanges: string;
20
+ discard: string;
21
+ retry: string;
22
+ unsavedChanges: string;
23
+ somethingWentWrong: string;
24
+ selected: string;
25
+ };
26
+ form: {
27
+ required: string;
28
+ min: string;
29
+ max: string;
30
+ minLength: string;
31
+ maxLength: string;
32
+ minItems: string;
33
+ maxItems: string;
34
+ pattern: string;
35
+ invalid: string;
36
+ };
37
+ editor: {
38
+ bold: string;
39
+ italic: string;
40
+ strike: string;
41
+ code: string;
42
+ heading: string;
43
+ bulletList: string;
44
+ orderedList: string;
45
+ blockquote: string;
46
+ link: string;
47
+ undo: string;
48
+ redo: string;
49
+ toolbar: string;
50
+ linkUrl: string;
51
+ applyLink: string;
52
+ removeLink: string;
53
+ characters: string;
54
+ };
55
+ grid: {
56
+ noRows: string;
57
+ loading: string;
58
+ search: string;
59
+ clearSearch: string;
60
+ toolbar: string;
61
+ columns: string;
62
+ resetColumns: string;
63
+ exportCsv: string;
64
+ rowsPerPage: string;
65
+ previousPage: string;
66
+ nextPage: string;
67
+ pageStatus: string;
68
+ selected: string;
69
+ copied: string;
70
+ yes: string;
71
+ no: string;
72
+ };
73
+ account: {
74
+ label: string;
75
+ };
76
+ alert: {
77
+ title: string;
78
+ };
79
+ appearance: {
80
+ theme: string;
81
+ themeDescription: string;
82
+ style: string;
83
+ styleDescription: string;
84
+ };
85
+ auth: {
86
+ aside: string;
87
+ };
88
+ avatar: {
89
+ label: string;
90
+ online: string;
91
+ away: string;
92
+ busy: string;
93
+ offline: string;
94
+ };
95
+ avatarGroup: {
96
+ more: string;
97
+ };
98
+ breadcrumbs: {
99
+ label: string;
100
+ };
101
+ calendar: {
102
+ previousMonth: string;
103
+ nextMonth: string;
104
+ };
105
+ chart: {
106
+ empty: string;
107
+ loading: string;
108
+ };
109
+ colorInput: {
110
+ pick: string;
111
+ swatches: string;
112
+ };
113
+ combobox: {
114
+ clear: string;
115
+ toggle: string;
116
+ list: string;
117
+ create: string;
118
+ results: string;
119
+ };
120
+ commandPalette: {
121
+ placeholder: string;
122
+ label: string;
123
+ recent: string;
124
+ minQuery: string;
125
+ error: string;
126
+ results: string;
127
+ move: string;
128
+ select: string;
129
+ close: string;
130
+ };
131
+ contextMenu: {
132
+ label: string;
133
+ };
134
+ dashboardLayout: {
135
+ pages: string;
136
+ searchPlaceholder: string;
137
+ };
138
+ dashboardPage: {
139
+ stats: string;
140
+ };
141
+ datePicker: {
142
+ placeholder: string;
143
+ clear: string;
144
+ dialog: string;
145
+ range: string;
146
+ };
147
+ descriptionList: {
148
+ empty: string;
149
+ };
150
+ detailPage: {
151
+ sections: string;
152
+ details: string;
153
+ error: string;
154
+ };
155
+ dirtyGuard: {
156
+ title: string;
157
+ description: string;
158
+ confirm: string;
159
+ cancel: string;
160
+ };
161
+ emptyPage: {
162
+ title: string;
163
+ steps: string;
164
+ done: string;
165
+ todo: string;
166
+ };
167
+ errorPage: {
168
+ home: string;
169
+ back: string;
170
+ retry: string;
171
+ badRequestTitle: string;
172
+ badRequestMessage: string;
173
+ signInTitle: string;
174
+ signInMessage: string;
175
+ forbiddenTitle: string;
176
+ forbiddenMessage: string;
177
+ notFoundTitle: string;
178
+ notFoundMessage: string;
179
+ serverTitle: string;
180
+ serverMessage: string;
181
+ unavailableTitle: string;
182
+ unavailableMessage: string;
183
+ };
184
+ fileInput: {
185
+ title: string;
186
+ drop: string;
187
+ list: string;
188
+ selected: string;
189
+ };
190
+ filterPills: {
191
+ label: string;
192
+ };
193
+ listPage: {
194
+ toolbar: string;
195
+ emptyTitle: string;
196
+ noResultsDescription: string;
197
+ clearFilters: string;
198
+ };
199
+ numberInput: {
200
+ increase: string;
201
+ decrease: string;
202
+ };
203
+ pagination: {
204
+ label: string;
205
+ page: string;
206
+ previous: string;
207
+ next: string;
208
+ pageSize: string;
209
+ of: string;
210
+ };
211
+ passwordInput: {
212
+ show: string;
213
+ hide: string;
214
+ generate: string;
215
+ copy: string;
216
+ strength: string;
217
+ };
218
+ passwordStrength: {
219
+ tooShort: string;
220
+ weak: string;
221
+ fair: string;
222
+ good: string;
223
+ strong: string;
224
+ };
225
+ preset: {
226
+ default: string;
227
+ defaultDescription: string;
228
+ suedtirolDescription: string;
229
+ spotfishDescription: string;
230
+ };
231
+ progress: {
232
+ label: string;
233
+ };
234
+ prompt: {
235
+ title: string;
236
+ };
237
+ saveBar: {
238
+ message: string;
239
+ };
240
+ settings: {
241
+ title: string;
242
+ close: string;
243
+ sections: string;
244
+ signOut: string;
245
+ session: string;
246
+ sessionDescription: string;
247
+ accountDescription: string;
248
+ appearance: string;
249
+ appearanceDescription: string;
250
+ };
251
+ shell: {
252
+ sidebar: string;
253
+ openNavigation: string;
254
+ skipToContent: string;
255
+ main: string;
256
+ collapse: string;
257
+ expand: string;
258
+ };
259
+ stat: {
260
+ increased: string;
261
+ decreased: string;
262
+ };
263
+ table: {
264
+ selectAll: string;
265
+ loading: string;
266
+ selectRow: string;
267
+ };
268
+ theme: {
269
+ label: string;
270
+ system: string;
271
+ light: string;
272
+ dark: string;
273
+ };
274
+ toaster: {
275
+ label: string;
276
+ dismiss: string;
277
+ };
278
+ tree: {
279
+ label: string;
280
+ };
281
+ }
282
+ export interface KLocale {
283
+ code: string;
284
+ dir: 'ltr' | 'rtl';
285
+ messages: KMessages;
286
+ }
287
+ export type DeepPartial<T> = {
288
+ [K in keyof T]?: T[K] extends string ? T[K] : DeepPartial<T[K]>;
289
+ };
290
+ export type MessageKey = {
291
+ [N in keyof KMessages & string]: `${N}.${keyof KMessages[N] & string}`;
292
+ }[keyof KMessages & string];
File without changes
@@ -1,7 +1,13 @@
1
1
  import type { KAppConfig } from '../components/templates/types';
2
2
  import type { ThemePreference } from '../composables/useTheme';
3
3
  import type { ThemePreset } from '../internal/core/preset-data';
4
+ import type { DeepPartial, KMessages } from '../locale/types';
4
5
  export type { KAppConfig } from '../components/templates/types';
6
+ export interface IconCollectionOption {
7
+ prefix: string;
8
+ include?: string[];
9
+ exclude?: string[];
10
+ }
5
11
  export interface LayoutsOption {
6
12
  dashboard?: string | false;
7
13
  auth?: string | false;
@@ -10,6 +16,7 @@ export interface ModuleOptions {
10
16
  prefix: string;
11
17
  global: boolean;
12
18
  css: boolean;
19
+ cssLayers: string | false;
13
20
  composables: boolean;
14
21
  grid: boolean;
15
22
  editor: boolean;
@@ -18,23 +25,30 @@ export interface ModuleOptions {
18
25
  cssTarget: string[] | false;
19
26
  icons: {
20
27
  dir?: string;
28
+ collections?: (string | IconCollectionOption)[];
29
+ defaultCollection?: string;
30
+ aliases?: Record<string, string>;
21
31
  };
22
32
  theme: {
23
- cookie: string;
33
+ cookie: string | false;
24
34
  default: ThemePreference;
25
35
  };
26
36
  preset: {
27
- cookie: string;
37
+ cookie: string | false;
28
38
  default: ThemePreset;
29
39
  };
30
40
  fonts: boolean | ThemePreset[];
41
+ locale: string;
42
+ messages: Record<string, DeepPartial<KMessages>>;
31
43
  }
32
44
  export interface KRuntimeConfig {
33
45
  global: boolean;
34
- themeCookie: string;
46
+ themeCookie: string | false;
35
47
  themeDefault: ThemePreference;
36
- presetCookie: string;
48
+ presetCookie: string | false;
37
49
  presetDefault: ThemePreset;
50
+ locale: string;
51
+ messages: Record<string, DeepPartial<KMessages>>;
38
52
  }
39
53
  declare module '@nuxt/schema' {
40
54
  interface PublicRuntimeConfig {
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readdirSync, readFileSync } from "node:fs";
2
2
  import { isAbsolute, join, relative } from "node:path";
3
+ import { fileURLToPath } from "node:url";
3
4
  import {
4
5
  addComponent,
5
6
  addComponentsDir,
@@ -7,6 +8,7 @@ import {
7
8
  addImportsDir,
8
9
  addPlugin,
9
10
  addPluginTemplate,
11
+ addTemplate,
10
12
  createResolver,
11
13
  defineNuxtModule,
12
14
  directoryToURL,
@@ -25,6 +27,7 @@ export default defineNuxtModule({
25
27
  prefix: "K",
26
28
  global: false,
27
29
  css: true,
30
+ cssLayers: "theme, base, k, components, utilities",
28
31
  composables: true,
29
32
  grid: false,
30
33
  editor: false,
@@ -40,7 +43,9 @@ export default defineNuxtModule({
40
43
  cookie: "k-preset",
41
44
  default: "default"
42
45
  },
43
- fonts: true
46
+ fonts: true,
47
+ locale: "en",
48
+ messages: {}
44
49
  },
45
50
  async setup(options, nuxt) {
46
51
  const resolver = createResolver(import.meta.url);
@@ -102,15 +107,19 @@ export default defineNuxtModule({
102
107
  const viteBuild = nuxt.options.vite.build ??= {};
103
108
  if (options.cssTarget && viteBuild.cssTarget === void 0)
104
109
  viteBuild.cssTarget = options.cssTarget;
105
- nuxt.options.runtimeConfig.public.k = {
110
+ const runtimeConfig = {
106
111
  global: options.global,
107
112
  themeCookie: options.theme.cookie,
108
113
  themeDefault: options.theme.default,
109
114
  presetCookie: options.preset.cookie,
110
- presetDefault
115
+ presetDefault,
116
+ locale: options.locale,
117
+ messages: options.messages
111
118
  };
119
+ Object.assign(nuxt.options.runtimeConfig.public, { k: runtimeConfig });
112
120
  addPlugin(resolver.resolve("./runtime/theme"));
113
121
  addPlugin(resolver.resolve("./runtime/storage"));
122
+ addPlugin(resolver.resolve("./runtime/locale"));
114
123
  if (options.composables)
115
124
  addImports({ name: "useDashboard", from: resolver.resolve("./runtime/dashboard") });
116
125
  const layouts = resolveLayouts(options.layouts);
@@ -139,16 +148,65 @@ export default defineNuxtModule({
139
148
  `})`
140
149
  ].join("\n")
141
150
  });
142
- if (options.icons.dir) {
143
- const aliased = resolveAlias(options.icons.dir);
144
- const iconsDir = isAbsolute(aliased) ? aliased : join(nuxt.options.srcDir, aliased);
145
- if (!existsSync(iconsDir)) console.warn(`[@xleddyl/443-components-vue] icons.dir not found: ${iconsDir}`);
151
+ const collections = [];
152
+ for (const entry of options.icons.collections ?? []) {
153
+ const collection = typeof entry === "string" ? { prefix: entry } : entry;
154
+ const file = await resolveCollectionFile(collection.prefix, searchPaths);
155
+ if (!file) {
156
+ console.warn(
157
+ `[@xleddyl/443-components-vue] icon collection "${collection.prefix}" not installed: pnpm add -D @iconify-json/${collection.prefix}`
158
+ );
159
+ continue;
160
+ }
161
+ const data = filterCollection(JSON.parse(readFileSync(file, "utf8")), collection);
162
+ collections.push(data);
163
+ addTemplate({
164
+ filename: `k-icons/${collection.prefix}.mjs`,
165
+ getContents: () => `export default ${JSON.stringify(data)}
166
+ `
167
+ });
168
+ }
169
+ if (collections.length || options.icons.defaultCollection) {
170
+ addPluginTemplate({
171
+ filename: "k-icon-collections.mjs",
172
+ getContents: () => [
173
+ `import { defineNuxtPlugin } from '#app'`,
174
+ `import { ICON_USAGE_KEY, loadIconCollection, registerIconCollection, setDefaultIconCollection } from '@xleddyl/443-components-vue'`,
175
+ ...collections.map(
176
+ (collection) => `registerIconCollection(${JSON.stringify(collection.prefix)}, () => import('#build/k-icons/${collection.prefix}.mjs'))`
177
+ ),
178
+ `setDefaultIconCollection(${JSON.stringify(options.icons.defaultCollection)})`,
179
+ `const prefixes = ${JSON.stringify(collections.map((collection) => collection.prefix))}`,
180
+ `export default defineNuxtPlugin({`,
181
+ ` name: 'k:icon-collections',`,
182
+ ` async setup(nuxtApp) {`,
183
+ ` if (import.meta.server) {`,
184
+ ` await Promise.all(prefixes.map(loadIconCollection))`,
185
+ ` const used = new Set()`,
186
+ ` nuxtApp.vueApp.provide(ICON_USAGE_KEY, used)`,
187
+ ` nuxtApp.hook('app:rendered', () => {`,
188
+ ` nuxtApp.payload.kIconCollections = [...used]`,
189
+ ` })`,
190
+ ` return`,
191
+ ` }`,
192
+ ` const used = nuxtApp.payload.kIconCollections ?? []`,
193
+ ` await Promise.all(used.map(loadIconCollection))`,
194
+ ` },`,
195
+ `})`
196
+ ].join("\n")
197
+ });
198
+ }
199
+ const aliasIcons = resolveAliasIcons(options.icons.aliases ?? {}, collections);
200
+ const iconsDir = options.icons.dir ? resolveIconsDir(options.icons.dir, nuxt.options.srcDir) : void 0;
201
+ if (iconsDir && !existsSync(iconsDir))
202
+ console.warn(`[@xleddyl/443-components-vue] icons.dir not found: ${iconsDir}`);
203
+ if (iconsDir || Object.keys(options.icons.aliases ?? {}).length) {
146
204
  addPluginTemplate({
147
205
  filename: "k-icons.mjs",
148
206
  getContents: () => [
149
207
  `import { defineNuxtPlugin } from '#app'`,
150
208
  `import { createIcons } from '@xleddyl/443-components-vue'`,
151
- `const icons = ${JSON.stringify(readIconsDir(iconsDir), null, 2)}`,
209
+ `const icons = ${JSON.stringify(withDirAliases(iconsDir ? readIconsDir(iconsDir) : {}, aliasIcons, options.icons.aliases ?? {}), null, 2)}`,
152
210
  `export default defineNuxtPlugin({`,
153
211
  ` name: 'k:icons',`,
154
212
  ` setup(nuxtApp) {`,
@@ -158,12 +216,20 @@ export default defineNuxtModule({
158
216
  ].join("\n")
159
217
  });
160
218
  nuxt.hook("builder:watch", async (_event, path) => {
161
- if (!path.endsWith(".svg")) return;
219
+ if (!iconsDir || !path.endsWith(".svg")) return;
162
220
  const candidates = isAbsolute(path) ? [path] : [join(nuxt.options.srcDir, path), join(nuxt.options.rootDir, path)];
163
221
  if (!candidates.some((candidate) => candidate.startsWith(iconsDir))) return;
164
222
  await updateTemplates({ filter: (template) => template.filename === "k-icons.mjs" });
165
223
  });
166
224
  }
225
+ if (options.css && options.cssLayers) {
226
+ const layers = addTemplate({
227
+ filename: "k-layers.css",
228
+ getContents: () => `@layer ${options.cssLayers};
229
+ `
230
+ });
231
+ nuxt.options.css.unshift(layers.dst);
232
+ }
167
233
  }
168
234
  });
169
235
  function resolveLayouts(option) {
@@ -198,6 +264,69 @@ const OPTIONAL_GROUPS = [
198
264
  dependencies: ["chart.js", "chart.js/helpers", "vue-chartjs"]
199
265
  }
200
266
  ];
267
+ function resolveIconsDir(dir, srcDir) {
268
+ const aliased = resolveAlias(dir);
269
+ return isAbsolute(aliased) ? aliased : join(srcDir, aliased);
270
+ }
271
+ async function resolveCollectionFile(prefix, searchPaths) {
272
+ for (const id of [`@iconify-json/${prefix}/icons.json`, `@iconify/json/json/${prefix}.json`]) {
273
+ const resolved = await tryResolveModule(id, searchPaths);
274
+ if (resolved) return resolved.startsWith("file:") ? fileURLToPath(resolved) : resolved;
275
+ }
276
+ return void 0;
277
+ }
278
+ function globToRegExp(pattern) {
279
+ const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
280
+ return new RegExp(`^${escaped}$`);
281
+ }
282
+ function filterCollection(data, option) {
283
+ const include = (option.include ?? []).map(globToRegExp);
284
+ const exclude = (option.exclude ?? []).map(globToRegExp);
285
+ const keep = (name) => (!include.length || include.some((pattern) => pattern.test(name))) && !exclude.some((pattern) => pattern.test(name));
286
+ const icons = Object.fromEntries(Object.entries(data.icons).filter(([name]) => keep(name)));
287
+ const aliases = Object.fromEntries(
288
+ Object.entries(data.aliases ?? {}).filter(
289
+ ([name, alias]) => keep(name) && alias.parent in icons
290
+ )
291
+ );
292
+ return { prefix: data.prefix, icons, aliases, width: data.width, height: data.height };
293
+ }
294
+ function collectionSvg(collections, name) {
295
+ const index = name.indexOf(":");
296
+ if (index <= 0) return void 0;
297
+ const collection = collections.find((entry) => entry.prefix === name.slice(0, index));
298
+ if (!collection) return void 0;
299
+ let key = name.slice(index + 1);
300
+ for (let depth = 0; depth < 5 && !collection.icons[key]; depth++) {
301
+ const parent = collection.aliases?.[key]?.parent;
302
+ if (!parent) break;
303
+ key = parent;
304
+ }
305
+ const icon = collection.icons[key];
306
+ if (!icon) return void 0;
307
+ const width = icon.width ?? collection.width ?? 16;
308
+ const height = icon.height ?? collection.height ?? 16;
309
+ return `<svg viewBox="${icon.left ?? 0} ${icon.top ?? 0} ${width} ${height}">${icon.body}</svg>`;
310
+ }
311
+ function resolveAliasIcons(aliases, collections) {
312
+ const icons = {};
313
+ for (const [name, target] of Object.entries(aliases)) {
314
+ const svg = collectionSvg(collections, target);
315
+ if (svg) icons[name] = svg;
316
+ }
317
+ return icons;
318
+ }
319
+ function withDirAliases(dirIcons, aliasIcons, aliases) {
320
+ const icons = { ...dirIcons, ...aliasIcons };
321
+ for (const [name, target] of Object.entries(aliases)) {
322
+ if (name in aliasIcons) continue;
323
+ const svg = dirIcons[target];
324
+ if (svg) icons[name] = svg;
325
+ else
326
+ console.warn(`[@xleddyl/443-components-vue] icon alias "${name}" -> "${target}" not found`);
327
+ }
328
+ return icons;
329
+ }
201
330
  function readIconsDir(dir) {
202
331
  if (!existsSync(dir)) return {};
203
332
  const icons = {};