@sveltia/ui 0.41.5 → 0.42.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.
Files changed (76) hide show
  1. package/dist/components/alert/alert.svelte +36 -30
  2. package/dist/components/alert/infobar.svelte +55 -45
  3. package/dist/components/bottom-navigation/bottom-navigation.svelte +21 -15
  4. package/dist/components/button/button-group.svelte +7 -5
  5. package/dist/components/button/button.svelte +274 -175
  6. package/dist/components/button/floating-action-button-wrapper.svelte +23 -18
  7. package/dist/components/button/select-button-group.svelte +57 -41
  8. package/dist/components/button/split-button.svelte +25 -18
  9. package/dist/components/calendar/calendar.svelte +103 -80
  10. package/dist/components/checkbox/checkbox-group.svelte +22 -19
  11. package/dist/components/checkbox/checkbox.svelte +91 -63
  12. package/dist/components/dialog/dialog.svelte +105 -87
  13. package/dist/components/dialog/prompt-dialog.svelte +5 -3
  14. package/dist/components/disclosure/disclosure.svelte +34 -21
  15. package/dist/components/divider/divider.svelte +18 -14
  16. package/dist/components/divider/spacer.svelte +13 -8
  17. package/dist/components/drawer/drawer.svelte +343 -190
  18. package/dist/components/grid/grid-body.svelte +16 -14
  19. package/dist/components/grid/grid-cell.svelte +5 -3
  20. package/dist/components/grid/grid-col-header.svelte +5 -3
  21. package/dist/components/grid/grid-foot.svelte +5 -3
  22. package/dist/components/grid/grid-head.svelte +5 -3
  23. package/dist/components/grid/grid-row-header.svelte +6 -4
  24. package/dist/components/grid/grid-row.svelte +6 -4
  25. package/dist/components/grid/grid.svelte +18 -12
  26. package/dist/components/icon/icon.svelte +7 -5
  27. package/dist/components/listbox/listbox.svelte +78 -61
  28. package/dist/components/listbox/option-group.svelte +15 -11
  29. package/dist/components/listbox/option.svelte +54 -39
  30. package/dist/components/menu/menu-item-group.svelte +5 -3
  31. package/dist/components/menu/menu-item.svelte +67 -51
  32. package/dist/components/menu/menu.svelte +21 -17
  33. package/dist/components/progressbar/progressbar.svelte +24 -15
  34. package/dist/components/radio/radio-group.svelte +40 -31
  35. package/dist/components/radio/radio.svelte +81 -63
  36. package/dist/components/resizable-pane/resizable-handle.svelte +60 -48
  37. package/dist/components/resizable-pane/resizable-pane-group.svelte +18 -14
  38. package/dist/components/select/combobox.svelte +135 -112
  39. package/dist/components/select/select-tags.svelte +73 -57
  40. package/dist/components/slider/slider.svelte +94 -74
  41. package/dist/components/switch/switch.svelte +115 -81
  42. package/dist/components/table/table-body.svelte +16 -14
  43. package/dist/components/table/table-cell.svelte +5 -3
  44. package/dist/components/table/table-col-header.svelte +5 -3
  45. package/dist/components/table/table-foot.svelte +5 -3
  46. package/dist/components/table/table-head.svelte +5 -3
  47. package/dist/components/table/table-row-header.svelte +6 -4
  48. package/dist/components/table/table-row.svelte +6 -4
  49. package/dist/components/table/table.svelte +18 -12
  50. package/dist/components/tabs/tab-box.svelte +9 -6
  51. package/dist/components/tabs/tab-list.svelte +91 -73
  52. package/dist/components/tabs/tab-panel.svelte +11 -7
  53. package/dist/components/tabs/tab-panels.svelte +19 -14
  54. package/dist/components/text-editor/code-editor.svelte +10 -7
  55. package/dist/components/text-editor/lexical-root.svelte +221 -160
  56. package/dist/components/text-editor/text-editor.svelte +25 -18
  57. package/dist/components/text-editor/toolbar/toolbar-wrapper.svelte +44 -37
  58. package/dist/components/text-field/number-input.svelte +87 -68
  59. package/dist/components/text-field/password-input.svelte +52 -42
  60. package/dist/components/text-field/search-bar.svelte +64 -53
  61. package/dist/components/text-field/secret-input.svelte +61 -46
  62. package/dist/components/text-field/text-area.svelte +80 -68
  63. package/dist/components/text-field/text-input.svelte +138 -106
  64. package/dist/components/toast/toast.svelte +104 -89
  65. package/dist/components/toolbar/toolbar.svelte +70 -54
  66. package/dist/components/typography/truncated-text.svelte +9 -7
  67. package/dist/components/util/app-shell.svelte +40 -493
  68. package/dist/components/util/empty-state.svelte +13 -11
  69. package/dist/components/util/group.svelte +5 -3
  70. package/dist/components/util/modal.svelte +59 -48
  71. package/dist/components/util/popup.svelte +87 -67
  72. package/dist/index.d.ts +1 -0
  73. package/dist/index.js +1 -4
  74. package/dist/services/i18n.d.ts +6 -0
  75. package/dist/services/i18n.js +19 -14
  76. package/package.json +20 -20
@@ -217,51 +217,62 @@
217
217
  </dialog>
218
218
  {/snippet}
219
219
 
220
- <style>dialog {
221
- position: fixed;
222
- inset: 0;
223
- z-index: 9999999;
224
- display: flex;
225
- justify-content: center;
226
- align-items: center;
227
- overflow: hidden;
228
- outline: 0;
229
- margin: 0;
230
- border: 0;
231
- padding: 0;
232
- width: 100dvw;
233
- max-width: 100dvw;
234
- height: 100dvh;
235
- max-height: 100dvh;
236
- color: var(--sui-primary-foreground-color);
237
- background: transparent;
238
- -webkit-user-select: none;
239
- user-select: none;
240
- touch-action: none;
241
- pointer-events: all;
242
- cursor: default;
243
- }
244
- dialog::backdrop {
245
- background: transparent;
246
- }
247
- dialog.backdrop {
248
- background-color: var(--sui-popup-backdrop-color);
249
- }
250
- dialog.open {
251
- transition-duration: 50ms;
252
- opacity: 1;
253
- }
254
- dialog:not(.open) {
255
- transition-duration: 400ms;
256
- opacity: 0;
257
- }
258
- dialog[hidden] {
259
- transition-duration: 1ms !important;
260
- }
261
- dialog:not(.active) {
262
- pointer-events: none !important;
263
- }
264
- dialog:not(.active) :global(*) {
265
- transition-duration: 0ms !important;
266
- pointer-events: none !important;
267
- }</style>
220
+ <style lang="scss">
221
+ dialog {
222
+ position: fixed;
223
+ inset: 0;
224
+ z-index: 9999999;
225
+ display: flex;
226
+ justify-content: center;
227
+ align-items: center;
228
+ overflow: hidden;
229
+ outline: 0;
230
+ margin: 0;
231
+ border: 0;
232
+ padding: 0;
233
+ width: 100dvw;
234
+ max-width: 100dvw;
235
+ height: 100dvh;
236
+ max-height: 100dvh;
237
+ color: var(--sui-primary-foreground-color);
238
+ background: transparent;
239
+ -webkit-user-select: none;
240
+ user-select: none;
241
+ touch-action: none;
242
+ pointer-events: all;
243
+ cursor: default;
244
+
245
+ &::backdrop {
246
+ background: transparent;
247
+ }
248
+
249
+ &.backdrop {
250
+ background-color: var(--sui-popup-backdrop-color);
251
+ }
252
+
253
+ &.open {
254
+ transition-duration: 50ms;
255
+ opacity: 1;
256
+ }
257
+
258
+ &:not(.open) {
259
+ transition-duration: 400ms;
260
+ opacity: 0;
261
+ }
262
+
263
+ &[hidden] {
264
+ transition-duration: 1ms !important;
265
+ }
266
+
267
+ &:not(.active) {
268
+ pointer-events: none !important;
269
+
270
+ :global {
271
+ * {
272
+ transition-duration: 0ms !important;
273
+ pointer-events: none !important;
274
+ }
275
+ }
276
+ }
277
+ }
278
+ </style>
@@ -201,70 +201,90 @@
201
201
  </Modal>
202
202
  {/if}
203
203
 
204
- <style>.content {
205
- position: absolute;
206
- overflow-y: auto;
207
- outline-width: 0 !important;
208
- width: auto;
209
- color: var(--sui-primary-foreground-color);
210
- background-color: var(--sui-secondary-background-color-translucent);
211
- box-shadow: 0 8px 16px var(--sui-popup-shadow-color);
212
- -webkit-backdrop-filter: blur(16px);
213
- backdrop-filter: blur(16px);
214
- transition-property: opacity, transform;
215
- }
216
- .content.menu {
217
- border-width: var(--sui-menu-border-width, 1px);
218
- border-style: var(--sui-menu-border-style, solid);
219
- border-color: var(--sui-menu-border-width, var(--sui-secondary-border-color));
220
- border-radius: var(--sui-menu-border-radius, 4px);
221
- padding: var(--sui-menu-padding, 4px);
222
- }
223
- .content.menu :global(.sui.menu) {
224
- border-width: 0;
225
- border-radius: 0;
226
- padding: 0;
227
- background-color: transparent;
228
- }
229
- .content.listbox {
230
- border-width: var(--sui-listbox-border-width, 1px);
231
- border-style: var(--sui-listbox-border-style, solid);
232
- border-color: var(--sui-listbox-border-width, var(--sui-secondary-border-color));
233
- border-radius: var(--sui-listbox-border-radius, 4px);
234
- padding: var(--sui-listbox-padding, 4px);
235
- }
236
- .content.listbox :global(.sui.listbox) {
237
- border-width: 0;
238
- border-radius: 0;
239
- padding: 0;
240
- background-color: transparent;
241
- }
242
- .content.touch {
243
- position: static;
244
- border-width: 0 !important;
245
- border-radius: 4px !important;
246
- padding: 8px;
247
- min-width: 320px !important;
248
- max-width: calc(100dvw - 32px) !important;
249
- max-height: calc(100dvh - 32px) !important;
250
- }
251
- :global(dialog.open) .content.touch {
252
- transform: scale(100%) !important;
253
- }
254
- :global(dialog:not(.open)) .content.touch {
255
- transform: scale(90%);
256
- }
257
- .content.touch.combobox :global(.sui.listbox) {
258
- gap: 4px;
259
- padding: 8px 4px !important;
260
- }
261
- :global(dialog.open) .content {
262
- transition-duration: 50ms;
263
- opacity: 1;
264
- transform: translateY(2px);
265
- }
266
- :global(dialog:not(.open)) .content {
267
- transition-duration: 300ms;
268
- opacity: 0;
269
- transform: translateY(-8px);
270
- }</style>
204
+ <style lang="scss">
205
+ .content {
206
+ position: absolute;
207
+ overflow-y: auto;
208
+ outline-width: 0 !important;
209
+ width: auto;
210
+ color: var(--sui-primary-foreground-color);
211
+ background-color: var(--sui-secondary-background-color-translucent);
212
+ box-shadow: 0 8px 16px var(--sui-popup-shadow-color);
213
+ -webkit-backdrop-filter: blur(16px);
214
+ backdrop-filter: blur(16px);
215
+ transition-property: opacity, transform;
216
+
217
+ &.menu {
218
+ border-width: var(--sui-menu-border-width, 1px);
219
+ border-style: var(--sui-menu-border-style, solid);
220
+ border-color: var(--sui-menu-border-width, var(--sui-secondary-border-color));
221
+ border-radius: var(--sui-menu-border-radius, 4px);
222
+ padding: var(--sui-menu-padding, 4px);
223
+
224
+ :global {
225
+ .sui.menu {
226
+ border-width: 0;
227
+ border-radius: 0;
228
+ padding: 0;
229
+ background-color: transparent;
230
+ }
231
+ }
232
+ }
233
+
234
+ &.listbox {
235
+ border-width: var(--sui-listbox-border-width, 1px);
236
+ border-style: var(--sui-listbox-border-style, solid);
237
+ border-color: var(--sui-listbox-border-width, var(--sui-secondary-border-color));
238
+ border-radius: var(--sui-listbox-border-radius, 4px);
239
+ padding: var(--sui-listbox-padding, 4px);
240
+
241
+ :global {
242
+ .sui.listbox {
243
+ border-width: 0;
244
+ border-radius: 0;
245
+ padding: 0;
246
+ background-color: transparent;
247
+ }
248
+ }
249
+ }
250
+
251
+ &.touch {
252
+ position: static;
253
+ border-width: 0 !important;
254
+ border-radius: 4px !important;
255
+ padding: 8px;
256
+ min-width: 320px !important;
257
+ max-width: calc(100dvw - 32px) !important;
258
+ max-height: calc(100dvh - 32px) !important;
259
+
260
+ :global(dialog.open) & {
261
+ transform: scale(100%) !important;
262
+ }
263
+
264
+ :global(dialog:not(.open)) & {
265
+ transform: scale(90%);
266
+ }
267
+
268
+ &.combobox {
269
+ :global {
270
+ .sui.listbox {
271
+ gap: 4px;
272
+ padding: 8px 4px !important;
273
+ }
274
+ }
275
+ }
276
+ }
277
+
278
+ :global(dialog.open) & {
279
+ transition-duration: 50ms;
280
+ opacity: 1;
281
+ transform: translateY(2px);
282
+ }
283
+
284
+ :global(dialog:not(.open)) & {
285
+ transition-duration: 300ms;
286
+ opacity: 0;
287
+ transform: translateY(-8px);
288
+ }
289
+ }
290
+ </style>
package/dist/index.d.ts CHANGED
@@ -78,3 +78,4 @@ export { default as EmptyState } from "./components/util/empty-state.svelte";
78
78
  export { default as Group } from "./components/util/group.svelte";
79
79
  export { default as Modal } from "./components/util/modal.svelte";
80
80
  export * from "./typedefs.js";
81
+ export { initLocales, resources } from "./services/i18n.js";
package/dist/index.js CHANGED
@@ -1,7 +1,3 @@
1
- import { initLocales } from './services/i18n.js';
2
-
3
- initLocales();
4
-
5
1
  export { default as Alert } from './components/alert/alert.svelte';
6
2
  export { default as Infobar } from './components/alert/infobar.svelte';
7
3
  export { default as BottomNavigation } from './components/bottom-navigation/bottom-navigation.svelte';
@@ -81,6 +77,7 @@ export { default as AppShell } from './components/util/app-shell.svelte';
81
77
  export { default as EmptyState } from './components/util/empty-state.svelte';
82
78
  export { default as Group } from './components/util/group.svelte';
83
79
  export { default as Modal } from './components/util/modal.svelte';
80
+ export { initLocales, resources } from './services/i18n.js';
84
81
 
85
82
  // eslint-disable-next-line import/export
86
83
  export * from './typedefs.js';
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Object containing all the locale resources, with the locale names as keys and the corresponding
3
+ * strings as values.
4
+ * @type {Record<string, Record<string, string>>}
5
+ */
6
+ export const resources: Record<string, Record<string, string>>;
1
7
  export function initLocales({ fallbackLocale, initialLocale }?: {
2
8
  fallbackLocale?: string | undefined;
3
9
  initialLocale?: string | undefined;
@@ -1,8 +1,22 @@
1
1
  import { addMessages, init } from '@sveltia/i18n';
2
- import { parse as parseYaml } from 'yaml';
2
+
3
+ const rawResources = import.meta.glob('../locales/*.yaml', { eager: true, import: 'default' });
4
+
5
+ /**
6
+ * Object containing all the locale resources, with the locale names as keys and the corresponding
7
+ * strings as values.
8
+ * @type {Record<string, Record<string, string>>}
9
+ */
10
+ export const resources = Object.fromEntries(
11
+ Object.entries(rawResources).map(([path, resource]) => [
12
+ /** @type {string} */ (path.match(/.+\/(?<locale>.+?)\.yaml$/)?.groups?.locale),
13
+ /** @type {Record<string, string>} */ (resource),
14
+ ]),
15
+ );
3
16
 
4
17
  /**
5
- * Load strings and initialize the locales.
18
+ * Load strings and initialize the locales. Consumers can use this function to load the localized
19
+ * strings for their application. If `<AppShell>` is used, this function is called automatically.
6
20
  * @param {object} [init] Initialize options.
7
21
  * @param {string} [init.fallbackLocale] Fallback locale.
8
22
  * @param {string} [init.initialLocale] Initial locale.
@@ -10,18 +24,9 @@ import { parse as parseYaml } from 'yaml';
10
24
  * @see https://vitejs.dev/guide/features.html#glob-import
11
25
  */
12
26
  export const initLocales = ({ fallbackLocale = 'en', initialLocale = 'en' } = {}) => {
13
- const resources = import.meta.glob('../locales/*.yaml', {
14
- eager: true,
15
- query: '?raw',
16
- import: 'default',
17
- });
18
-
19
- Object.entries(resources).forEach(([path, resource]) => {
20
- addMessages(
21
- /** @type {string} */ (path.match(/.+\/(?<locale>.+?)\.yaml$/)?.groups?.locale),
22
- // Add `_sui` suffix to avoid collision with app localization
23
- { _sui: parseYaml(/** @type {string} */ (resource)) },
24
- );
27
+ Object.entries(resources).forEach(([locale, resource]) => {
28
+ // Add `_sui` suffix to avoid collision with app localization
29
+ addMessages(locale, { _sui: resource });
25
30
  });
26
31
 
27
32
  init({ fallbackLocale, initialLocale });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.41.5",
3
+ "version": "0.42.0",
4
4
  "description": "A collection of Svelte components and utilities for building user interfaces.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,36 +33,36 @@
33
33
  "!dist/**/*.test.*"
34
34
  ],
35
35
  "dependencies": {
36
- "@lexical/code": "^0.46.0",
37
- "@lexical/code-prism": "^0.46.0",
38
- "@lexical/dragon": "^0.46.0",
39
- "@lexical/extension": "^0.46.0",
40
- "@lexical/history": "^0.46.0",
41
- "@lexical/link": "^0.46.0",
42
- "@lexical/list": "^0.46.0",
43
- "@lexical/markdown": "^0.46.0",
44
- "@lexical/rich-text": "^0.46.0",
45
- "@lexical/selection": "^0.46.0",
46
- "@lexical/table": "^0.46.0",
47
- "@lexical/utils": "^0.46.0",
36
+ "@lexical/code": "^0.47.0",
37
+ "@lexical/code-prism": "^0.47.0",
38
+ "@lexical/dragon": "^0.47.0",
39
+ "@lexical/extension": "^0.47.0",
40
+ "@lexical/history": "^0.47.0",
41
+ "@lexical/link": "^0.47.0",
42
+ "@lexical/list": "^0.47.0",
43
+ "@lexical/markdown": "^0.47.0",
44
+ "@lexical/rich-text": "^0.47.0",
45
+ "@lexical/selection": "^0.47.0",
46
+ "@lexical/table": "^0.47.0",
47
+ "@lexical/utils": "^0.47.0",
48
48
  "@sveltia/i18n": "^1.1.2",
49
49
  "@sveltia/utils": "^0.10.7",
50
- "lexical": "^0.46.0",
51
- "prismjs": "^1.30.0",
52
- "yaml": "^2.9.0"
50
+ "lexical": "^0.47.0",
51
+ "prismjs": "^1.30.0"
53
52
  },
54
53
  "devDependencies": {
54
+ "@rollup/plugin-yaml": "^5.0.0",
55
55
  "@sveltejs/adapter-auto": "^7.0.1",
56
56
  "@sveltejs/kit": "^2.69.2",
57
57
  "@sveltejs/package": "^2.5.8",
58
58
  "@sveltejs/vite-plugin-svelte": "^7.2.0",
59
59
  "@vitest/coverage-v8": "^4.1.10",
60
60
  "cspell": "^10.0.1",
61
- "eslint": "^9.39.4",
61
+ "eslint": "^9.39.5",
62
62
  "eslint-config-airbnb-extended": "^3.1.0",
63
63
  "eslint-config-prettier": "^10.1.8",
64
64
  "eslint-plugin-import": "^2.32.0",
65
- "eslint-plugin-jsdoc": "^63.0.12",
65
+ "eslint-plugin-jsdoc": "^63.0.13",
66
66
  "eslint-plugin-package-json": "^1.5.0",
67
67
  "eslint-plugin-svelte": "^3.20.0",
68
68
  "globals": "^17.7.0",
@@ -70,7 +70,7 @@
70
70
  "oxlint": "^1.73.0",
71
71
  "postcss": "^8.5.16",
72
72
  "postcss-html": "^1.8.1",
73
- "prettier": "^3.9.4",
73
+ "prettier": "^3.9.5",
74
74
  "prettier-plugin-svelte": "^4.1.1",
75
75
  "sass": "^1.101.0",
76
76
  "stylelint": "^17.14.0",
@@ -80,7 +80,7 @@
80
80
  "svelte-check": "^4.7.2",
81
81
  "svelte-preprocess": "^6.0.5",
82
82
  "tslib": "^2.8.1",
83
- "vite": "^8.1.3",
83
+ "vite": "^8.1.4",
84
84
  "vitest": "^4.1.10"
85
85
  },
86
86
  "peerDependencies": {