@sveltia/ui 0.16.0 → 0.17.1

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 (156) hide show
  1. package/package/components/alert/alert.svelte +22 -7
  2. package/package/components/alert/alert.svelte.d.ts +32 -28
  3. package/package/components/button/button-group.svelte +16 -6
  4. package/package/components/button/button-group.svelte.d.ts +23 -23
  5. package/package/components/button/button.svelte +41 -136
  6. package/package/components/button/button.svelte.d.ts +5 -146
  7. package/package/components/button/select-button-group.svelte +31 -37
  8. package/package/components/button/select-button-group.svelte.d.ts +76 -34
  9. package/package/components/button/select-button.svelte +19 -62
  10. package/package/components/button/select-button.svelte.d.ts +17 -73
  11. package/package/components/button/split-button.svelte +37 -47
  12. package/package/components/button/split-button.svelte.d.ts +40 -47
  13. package/package/components/calendar/calendar.svelte +80 -55
  14. package/package/components/calendar/calendar.svelte.d.ts +13 -10
  15. package/package/components/checkbox/checkbox-group.svelte +23 -20
  16. package/package/components/checkbox/checkbox-group.svelte.d.ts +49 -27
  17. package/package/components/checkbox/checkbox.svelte +57 -67
  18. package/package/components/checkbox/checkbox.svelte.d.ts +67 -55
  19. package/package/components/dialog/alert-dialog.svelte +9 -36
  20. package/package/components/dialog/alert-dialog.svelte.d.ts +5 -44
  21. package/package/components/dialog/confirmation-dialog.svelte +9 -41
  22. package/package/components/dialog/confirmation-dialog.svelte.d.ts +5 -46
  23. package/package/components/dialog/dialog.svelte +60 -105
  24. package/package/components/dialog/dialog.svelte.d.ts +5 -102
  25. package/package/components/dialog/prompt-dialog.svelte +32 -61
  26. package/package/components/dialog/prompt-dialog.svelte.d.ts +38 -62
  27. package/package/components/disclosure/disclosure.svelte +39 -34
  28. package/package/components/disclosure/disclosure.svelte.d.ts +74 -56
  29. package/package/components/divider/divider.svelte +18 -14
  30. package/package/components/divider/divider.svelte.d.ts +31 -10
  31. package/package/components/divider/spacer.svelte +13 -8
  32. package/package/components/divider/spacer.svelte.d.ts +20 -9
  33. package/package/components/drawer/drawer.svelte +63 -76
  34. package/package/components/drawer/drawer.svelte.d.ts +102 -84
  35. package/package/components/grid/grid-body.svelte +15 -10
  36. package/package/components/grid/grid-body.svelte.d.ts +30 -24
  37. package/package/components/grid/grid-cell.svelte +16 -6
  38. package/package/components/grid/grid-cell.svelte.d.ts +23 -23
  39. package/package/components/grid/grid-col-header.svelte +16 -6
  40. package/package/components/grid/grid-col-header.svelte.d.ts +23 -23
  41. package/package/components/grid/grid-foot.svelte +16 -6
  42. package/package/components/grid/grid-foot.svelte.d.ts +23 -23
  43. package/package/components/grid/grid-head.svelte +16 -6
  44. package/package/components/grid/grid-head.svelte.d.ts +23 -23
  45. package/package/components/grid/grid-row-header.svelte +16 -6
  46. package/package/components/grid/grid-row-header.svelte.d.ts +23 -23
  47. package/package/components/grid/grid-row.svelte +19 -23
  48. package/package/components/grid/grid-row.svelte.d.ts +48 -38
  49. package/package/components/grid/grid.svelte +28 -25
  50. package/package/components/grid/grid.svelte.d.ts +56 -32
  51. package/package/components/icon/icon.svelte +14 -9
  52. package/package/components/icon/icon.svelte.d.ts +20 -9
  53. package/package/components/listbox/listbox.svelte +46 -52
  54. package/package/components/listbox/listbox.svelte.d.ts +102 -40
  55. package/package/components/listbox/option-group.svelte +23 -19
  56. package/package/components/listbox/option-group.svelte.d.ts +49 -27
  57. package/package/components/listbox/option.svelte +44 -57
  58. package/package/components/listbox/option.svelte.d.ts +54 -84
  59. package/package/components/menu/menu-button.svelte +42 -63
  60. package/package/components/menu/menu-button.svelte.d.ts +18 -72
  61. package/package/components/menu/menu-item-checkbox.svelte +29 -41
  62. package/package/components/menu/menu-item-checkbox.svelte.d.ts +5 -44
  63. package/package/components/menu/menu-item-group.svelte +22 -19
  64. package/package/components/menu/menu-item-group.svelte.d.ts +41 -27
  65. package/package/components/menu/menu-item-radio.svelte +29 -41
  66. package/package/components/menu/menu-item-radio.svelte.d.ts +5 -44
  67. package/package/components/menu/menu-item.svelte +66 -75
  68. package/package/components/menu/menu-item.svelte.d.ts +5 -80
  69. package/package/components/menu/menu.svelte +27 -22
  70. package/package/components/menu/menu.svelte.d.ts +50 -30
  71. package/package/components/radio/radio-group.svelte +38 -42
  72. package/package/components/radio/radio-group.svelte.d.ts +85 -35
  73. package/package/components/radio/radio.svelte +45 -48
  74. package/package/components/radio/radio.svelte.d.ts +96 -42
  75. package/package/components/select/combobox.svelte +76 -101
  76. package/package/components/select/combobox.svelte.d.ts +5 -56
  77. package/package/components/select/select-tags.svelte +48 -59
  78. package/package/components/select/select-tags.svelte.d.ts +109 -28
  79. package/package/components/select/select.svelte +18 -37
  80. package/package/components/select/select.svelte.d.ts +5 -40
  81. package/package/components/slider/slider.svelte +71 -68
  82. package/package/components/slider/slider.svelte.d.ts +142 -31
  83. package/package/components/switch/switch.svelte +36 -46
  84. package/package/components/switch/switch.svelte.d.ts +83 -37
  85. package/package/components/table/table-body.svelte +15 -11
  86. package/package/components/table/table-body.svelte.d.ts +30 -24
  87. package/package/components/table/table-cell.svelte +16 -6
  88. package/package/components/table/table-cell.svelte.d.ts +23 -23
  89. package/package/components/table/table-col-header.svelte +16 -6
  90. package/package/components/table/table-col-header.svelte.d.ts +23 -23
  91. package/package/components/table/table-foot.svelte +16 -6
  92. package/package/components/table/table-foot.svelte.d.ts +23 -23
  93. package/package/components/table/table-head.svelte +16 -6
  94. package/package/components/table/table-head.svelte.d.ts +23 -23
  95. package/package/components/table/table-row-header.svelte +16 -6
  96. package/package/components/table/table-row-header.svelte.d.ts +23 -23
  97. package/package/components/table/table-row.svelte +16 -6
  98. package/package/components/table/table-row.svelte.d.ts +23 -23
  99. package/package/components/table/table.svelte +16 -6
  100. package/package/components/table/table.svelte.d.ts +23 -23
  101. package/package/components/tabs/tab-box.svelte +16 -9
  102. package/package/components/tabs/tab-box.svelte.d.ts +32 -22
  103. package/package/components/tabs/tab-list.svelte +36 -35
  104. package/package/components/tabs/tab-list.svelte.d.ts +65 -33
  105. package/package/components/tabs/tab-panel.svelte +16 -6
  106. package/package/components/tabs/tab-panel.svelte.d.ts +23 -23
  107. package/package/components/tabs/tab-panels.svelte +16 -6
  108. package/package/components/tabs/tab-panels.svelte.d.ts +23 -21
  109. package/package/components/tabs/tab.svelte +28 -25
  110. package/package/components/tabs/tab.svelte.d.ts +17 -63
  111. package/package/components/text-editor/lexical-root.svelte +38 -32
  112. package/package/components/text-editor/lexical-root.svelte.d.ts +74 -13
  113. package/package/components/text-editor/text-editor.svelte +63 -79
  114. package/package/components/text-editor/text-editor.svelte.d.ts +97 -20
  115. package/package/components/text-editor/toolbar/editor-toolbar.svelte +41 -24
  116. package/package/components/text-editor/toolbar/editor-toolbar.svelte.d.ts +32 -7
  117. package/package/components/text-editor/toolbar/format-text-button.svelte +15 -5
  118. package/package/components/text-editor/toolbar/format-text-button.svelte.d.ts +13 -6
  119. package/package/components/text-editor/toolbar/insert-link-button.svelte +18 -16
  120. package/package/components/text-editor/toolbar/insert-link-button.svelte.d.ts +4 -8
  121. package/package/components/text-editor/toolbar/toggle-block-menu-item.svelte +19 -7
  122. package/package/components/text-editor/toolbar/toggle-block-menu-item.svelte.d.ts +13 -6
  123. package/package/components/text-field/number-input.svelte +63 -81
  124. package/package/components/text-field/number-input.svelte.d.ts +48 -55
  125. package/package/components/text-field/password-input.svelte +38 -57
  126. package/package/components/text-field/password-input.svelte.d.ts +16 -45
  127. package/package/components/text-field/search-bar.svelte +45 -62
  128. package/package/components/text-field/search-bar.svelte.d.ts +25 -66
  129. package/package/components/text-field/text-area.svelte +38 -54
  130. package/package/components/text-field/text-area.svelte.d.ts +100 -35
  131. package/package/components/text-field/text-input.svelte +28 -86
  132. package/package/components/text-field/text-input.svelte.d.ts +4 -78
  133. package/package/components/toast/toast.svelte +36 -30
  134. package/package/components/toast/toast.svelte.d.ts +50 -28
  135. package/package/components/toolbar/toolbar.svelte +25 -25
  136. package/package/components/toolbar/toolbar.svelte.d.ts +57 -29
  137. package/package/components/util/app-shell.svelte +22 -10
  138. package/package/components/util/app-shell.svelte.d.ts +25 -29
  139. package/package/components/util/group.svelte +20 -15
  140. package/package/components/util/group.svelte.d.ts +40 -26
  141. package/package/components/util/modal.svelte +89 -105
  142. package/package/components/util/modal.svelte.d.ts +6 -71
  143. package/package/components/util/placeholder.svelte +21 -0
  144. package/package/components/util/{portal.svelte.d.ts → placeholder.svelte.d.ts} +17 -25
  145. package/package/components/util/popup.svelte +65 -62
  146. package/package/components/util/popup.svelte.d.ts +89 -77
  147. package/package/services/{group.js → group.svelte.js} +11 -12
  148. package/package/services/{popup.js → popup.svelte.js} +6 -5
  149. package/package/typedefs.d.ts +545 -0
  150. package/package/typedefs.js +202 -0
  151. package/package.json +12 -19
  152. package/package/components/util/portal.svelte +0 -36
  153. /package/package/services/{events.d.ts → events.svelte.d.ts} +0 -0
  154. /package/package/services/{events.js → events.svelte.js} +0 -0
  155. /package/package/services/{group.d.ts → group.svelte.d.ts} +0 -0
  156. /package/package/services/{popup.d.ts → popup.svelte.d.ts} +0 -0
@@ -4,7 +4,7 @@
4
4
  -->
5
5
  <script>
6
6
  import { generateElementId } from '@sveltia/utils/element';
7
- import { onMount, setContext } from 'svelte';
7
+ import { onMount, setContext, untrack } from 'svelte';
8
8
  import { _ } from 'svelte-i18n';
9
9
  import { writable } from 'svelte/store';
10
10
  import { blockButtonTypes, inlineButtonTypes } from '.';
@@ -16,51 +16,43 @@
16
16
  import EditorToolbar from './toolbar/editor-toolbar.svelte';
17
17
 
18
18
  /**
19
- * Make the text input container flexible.
20
- * @type {boolean}
19
+ * @typedef {object} Props
20
+ * @property {string | undefined} [value] - Input value.
21
+ * @property {boolean} [flex] - Make the text input container flexible.
22
+ * @property {import('../../typedefs').TextEditorMode[]} [modes] - Enabled modes.
23
+ * @property {(import('../../typedefs').TextEditorBlockType |
24
+ * import('../../typedefs').TextEditorInlineType)[]} [buttons] - Enabled buttons.
25
+ * @property {string} [class] - The `class` attribute on the wrapper element.
26
+ * @property {boolean} [hidden] - Whether to hide the widget.
27
+ * @property {boolean} [disabled] - Whether to disable the widget. An alias of the `aria-disabled`
28
+ * attribute.
29
+ * @property {boolean} [readonly] - Whether to make the widget read-only. An alias of the
30
+ * `aria-readonly` attribute.
31
+ * @property {boolean} [required] - Whether to mark the widget required. An alias of the
32
+ * `aria-required` attribute.
33
+ * @property {boolean} [invalid] - Whether to mark the widget invalid. An alias of the
34
+ * `aria-invalid` attribute.
35
+ * @property {import('svelte').Snippet} [children] - Primary slot content.
21
36
  */
22
- export let flex = false;
23
- /**
24
- * Whether to hide the widget. An alias of the `aria-hidden` attribute.
25
- * @type {boolean | undefined}
26
- */
27
- export let hidden = undefined;
28
- /**
29
- * Whether to disable the widget. An alias of the `aria-disabled` attribute.
30
- * @type {boolean}
31
- */
32
- export let disabled = false;
33
- /**
34
- * Whether to disable the widget. An alias of `aria-readonly` attribute.
35
- * @type {boolean}
36
- */
37
- export let readonly = false;
38
- /**
39
- * Whether to mark the widget required. An alias of the `aria-required` attribute.
40
- * @type {boolean}
41
- */
42
- export let required = false;
43
- /**
44
- * Whether to mark the widget invalid. An alias of the `aria-invalid` attribute.
45
- * @type {boolean}
46
- */
47
- export let invalid = false;
48
- /**
49
- * Input value.
50
- * @type {string | undefined}
51
- */
52
- export let value = undefined;
53
- /**
54
- * Enabled modes.
55
- * @type {import('../../typedefs').TextEditorMode[]}
56
- */
57
- export let modes = ['rich-text', 'plain-text'];
37
+
58
38
  /**
59
- * Enabled buttons.
60
- * @type {(import('../../typedefs').TextEditorBlockType |
61
- * import('../../typedefs').TextEditorInlineType)[]}
39
+ * @type {Props & Record<string, any>}
62
40
  */
63
- export let buttons = [...inlineButtonTypes, ...blockButtonTypes];
41
+ let {
42
+ /* eslint-disable prefer-const */
43
+ value = $bindable(''),
44
+ flex = false,
45
+ modes = ['rich-text', 'plain-text'],
46
+ buttons = [...inlineButtonTypes, ...blockButtonTypes],
47
+ hidden = false,
48
+ disabled = false,
49
+ readonly = false,
50
+ required = false,
51
+ invalid = false,
52
+ children,
53
+ ...restProps
54
+ /* eslint-enable prefer-const */
55
+ } = $props();
64
56
 
65
57
  /** @type {import('svelte/store').Writable<import('lexical').LexicalEditor | undefined>} */
66
58
  const editor = writable();
@@ -69,8 +61,8 @@
69
61
  const editorId = writable(generateElementId('editor'));
70
62
  const useRichText = writable(modes[0] === 'rich-text');
71
63
  const hasConverterError = writable(false);
72
- let inputValue = '';
73
- let showConverterError = false;
64
+ let inputValue = $state('');
65
+ let showConverterError = $state(false);
74
66
 
75
67
  /**
76
68
  * Convert the Markdown {@link inputValue} to Lexical nodes. Disable the rich text mode and
@@ -94,54 +86,46 @@
94
86
  }
95
87
  };
96
88
 
97
- /**
98
- * Update {@link inputValue} based on {@link value}.
99
- */
100
- const setInputValue = () => {
89
+ $effect(() => {
90
+ if (!$editor) {
91
+ return;
92
+ }
93
+
101
94
  const newValue = value;
102
95
 
103
96
  // Avoid a cycle dependency & infinite loop
104
- if (inputValue !== newValue) {
105
- inputValue = newValue ?? '';
97
+ untrack(() => {
98
+ if (inputValue !== newValue) {
99
+ inputValue = newValue ?? '';
106
100
 
107
- if ($useRichText) {
108
- convertMarkdown();
101
+ if ($useRichText) {
102
+ convertMarkdown();
103
+ }
109
104
  }
105
+ });
106
+ });
107
+
108
+ $effect(() => {
109
+ if (!$editor) {
110
+ return;
110
111
  }
111
- };
112
112
 
113
- /**
114
- * Update {@link value} based on {@link inputValue}.
115
- */
116
- const setCurrentValue = () => {
117
113
  const newValue = inputValue;
118
114
 
119
115
  // Avoid a cycle dependency & infinite loop
120
- if (value !== newValue) {
121
- value = newValue;
122
- }
123
- };
124
-
125
- $: {
126
- if ($editor) {
127
- void value;
128
- setInputValue();
129
- }
130
- }
131
-
132
- $: {
133
- if ($editor) {
134
- void inputValue;
135
- setCurrentValue();
136
- }
137
- }
116
+ untrack(() => {
117
+ if (value !== newValue) {
118
+ value = newValue;
119
+ }
120
+ });
121
+ });
138
122
 
139
- $: {
123
+ $effect(() => {
140
124
  if ($hasConverterError) {
141
125
  $useRichText = false;
142
126
  showConverterError = true;
143
127
  }
144
- }
128
+ });
145
129
 
146
130
  // The editor has to be initialized in the browser
147
131
  onMount(() => {
@@ -164,7 +148,7 @@
164
148
  );
165
149
  </script>
166
150
 
167
- <div role="none" class="sui text-editor" hidden={hidden || undefined} {...$$restProps}>
151
+ <div {...restProps} role="none" class="sui text-editor" {hidden}>
168
152
  <EditorToolbar {disabled} {readonly} />
169
153
  <LexicalRoot
170
154
  bind:value={inputValue}
@@ -1,35 +1,112 @@
1
1
  export default TextEditor;
2
- type TextEditor = SvelteComponent<{
3
- [x: string]: any;
4
- disabled?: boolean | undefined;
5
- invalid?: boolean | undefined;
6
- required?: boolean | undefined;
7
- value?: string | undefined;
8
- hidden?: boolean | undefined;
9
- readonly?: boolean | undefined;
10
- flex?: boolean | undefined;
11
- modes?: TextEditorMode[] | undefined;
12
- buttons?: (TextEditorBlockType | TextEditorInlineType)[] | undefined;
13
- }, {
2
+ type TextEditor = SvelteComponent<Props & Record<string, any>, {
14
3
  [evt: string]: CustomEvent<any>;
15
4
  }, {}> & {
16
- $$bindings?: string | undefined;
5
+ $$bindings?: "value" | undefined;
17
6
  };
18
7
  /** A rich text editor based on Lexical. */
19
8
  declare const TextEditor: $$__sveltets_2_IsomorphicComponent<{
20
- [x: string]: any;
21
- disabled?: boolean | undefined;
22
- invalid?: boolean | undefined;
23
- required?: boolean | undefined;
9
+ /**
10
+ * - Input value.
11
+ */
24
12
  value?: string | undefined;
13
+ /**
14
+ * - Make the text input container flexible.
15
+ */
16
+ flex?: boolean | undefined;
17
+ /**
18
+ * - Enabled modes.
19
+ */
20
+ modes?: import("../../typedefs").TextEditorMode[] | undefined;
21
+ /**
22
+ * - Enabled buttons.
23
+ */
24
+ buttons?: (import("../../typedefs").TextEditorBlockType | import("../../typedefs").TextEditorInlineType)[] | undefined;
25
+ /**
26
+ * - The `class` attribute on the wrapper element.
27
+ */
28
+ class?: string | undefined;
29
+ /**
30
+ * - Whether to hide the widget.
31
+ */
25
32
  hidden?: boolean | undefined;
33
+ /**
34
+ * - Whether to disable the widget. An alias of the `aria-disabled`
35
+ * attribute.
36
+ */
37
+ disabled?: boolean | undefined;
38
+ /**
39
+ * - Whether to make the widget read-only. An alias of the
40
+ * `aria-readonly` attribute.
41
+ */
26
42
  readonly?: boolean | undefined;
43
+ /**
44
+ * - Whether to mark the widget required. An alias of the
45
+ * `aria-required` attribute.
46
+ */
47
+ required?: boolean | undefined;
48
+ /**
49
+ * - Whether to mark the widget invalid. An alias of the
50
+ * `aria-invalid` attribute.
51
+ */
52
+ invalid?: boolean | undefined;
53
+ /**
54
+ * - Primary slot content.
55
+ */
56
+ children?: import("svelte").Snippet<[]> | undefined;
57
+ } & Record<string, any>, {
58
+ [evt: string]: CustomEvent<any>;
59
+ }, {}, {}, "value">;
60
+ type Props = {
61
+ /**
62
+ * - Input value.
63
+ */
64
+ value?: string | undefined;
65
+ /**
66
+ * - Make the text input container flexible.
67
+ */
27
68
  flex?: boolean | undefined;
69
+ /**
70
+ * - Enabled modes.
71
+ */
28
72
  modes?: import("../../typedefs").TextEditorMode[] | undefined;
73
+ /**
74
+ * - Enabled buttons.
75
+ */
29
76
  buttons?: (import("../../typedefs").TextEditorBlockType | import("../../typedefs").TextEditorInlineType)[] | undefined;
30
- }, {
31
- [evt: string]: CustomEvent<any>;
32
- }, {}, {}, string>;
77
+ /**
78
+ * - The `class` attribute on the wrapper element.
79
+ */
80
+ class?: string | undefined;
81
+ /**
82
+ * - Whether to hide the widget.
83
+ */
84
+ hidden?: boolean | undefined;
85
+ /**
86
+ * - Whether to disable the widget. An alias of the `aria-disabled`
87
+ * attribute.
88
+ */
89
+ disabled?: boolean | undefined;
90
+ /**
91
+ * - Whether to make the widget read-only. An alias of the
92
+ * `aria-readonly` attribute.
93
+ */
94
+ readonly?: boolean | undefined;
95
+ /**
96
+ * - Whether to mark the widget required. An alias of the
97
+ * `aria-required` attribute.
98
+ */
99
+ required?: boolean | undefined;
100
+ /**
101
+ * - Whether to mark the widget invalid. An alias of the
102
+ * `aria-invalid` attribute.
103
+ */
104
+ invalid?: boolean | undefined;
105
+ /**
106
+ * - Primary slot content.
107
+ */
108
+ children?: import("svelte").Snippet<[]> | undefined;
109
+ };
33
110
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
34
111
  new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
35
112
  $$bindings?: Bindings;
@@ -16,15 +16,23 @@
16
16
  import ToggleBlockMenuItem from './toggle-block-menu-item.svelte';
17
17
 
18
18
  /**
19
- * Whether to disable the widget. An alias of the `aria-disabled` attribute.
20
- * @type {boolean}
19
+ * @typedef {object} Props
20
+ * @property {boolean} [hidden] - Whether to hide the widget.
21
+ * @property {boolean} [disabled] - Whether to disable the widget. An alias of the `aria-disabled`
22
+ * attribute.
23
+ * @property {boolean} [readonly] - Whether to make the widget read-only. An alias of the
24
+ * `aria-readonly` attribute.
21
25
  */
22
- export let disabled = false;
26
+
23
27
  /**
24
- * Whether to disable the widget. An alias of `aria-readonly` attribute.
25
- * @type {boolean}
28
+ * @type {Props & Record<string, any>}
26
29
  */
27
- export let readonly = false;
30
+ let {
31
+ /* eslint-disable prefer-const */
32
+ disabled = false,
33
+ readonly = false,
34
+ /* eslint-enable prefer-const */
35
+ } = $props();
28
36
 
29
37
  /**
30
38
  * Text editor state.
@@ -44,17 +52,21 @@
44
52
  * Enabled block level buttons.
45
53
  * @type {import('../../../typedefs').TextEditorBlockType[]}
46
54
  */
47
- $: blockLevelButtons = unique([
48
- 'paragraph', // Always needed
49
- ...enabledButtons.filter((type) => blockButtonTypes.includes(/** @type {any} */ (type))),
50
- ]);
55
+ const blockLevelButtons = $derived(
56
+ unique([
57
+ 'paragraph', // Always needed
58
+ ...enabledButtons.filter((type) => blockButtonTypes.includes(/** @type {any} */ (type))),
59
+ ]),
60
+ );
51
61
 
52
62
  /**
53
63
  * Enabled inline level buttons.
54
64
  * @type {import('../../../typedefs').TextEditorInlineType[]}
55
65
  */
56
- $: inlineLevelButtons = unique(
57
- enabledButtons.filter((type) => inlineButtonTypes.includes(/** @type {any} */ (type))),
66
+ const inlineLevelButtons = $derived(
67
+ unique([
68
+ ...enabledButtons.filter((type) => inlineButtonTypes.includes(/** @type {any} */ (type))),
69
+ ]),
58
70
  );
59
71
  </script>
60
72
 
@@ -65,16 +77,19 @@
65
77
  aria-label={$_('_sui.text_editor.show_text_style_options')}
66
78
  aria-controls="{$editorId}-lexical-root"
67
79
  >
68
- <Icon
69
- slot="start-icon"
70
- name={availableButtons[$selectionBlockType]?.icon ?? 'format_paragraph'}
71
- />
72
- <Icon slot="end-icon" name="arrow_drop_down" class="small-arrow" />
73
- <Menu slot="popup" aria-label={$_('_sui.text_editor.text_style_options')}>
74
- {#each blockLevelButtons as type (type)}
75
- <ToggleBlockMenuItem {type} />
76
- {/each}
77
- </Menu>
80
+ {#snippet startIcon()}
81
+ <Icon name={availableButtons[$selectionBlockType]?.icon ?? 'format_paragraph'} />
82
+ {/snippet}
83
+ {#snippet endIcon()}
84
+ <Icon name="arrow_drop_down" class="small-arrow" />
85
+ {/snippet}
86
+ {#snippet popup()}
87
+ <Menu aria-label={$_('_sui.text_editor.text_style_options')}>
88
+ {#each blockLevelButtons as type (type)}
89
+ <ToggleBlockMenuItem {type} />
90
+ {/each}
91
+ </Menu>
92
+ {/snippet}
78
93
  </MenuButton>
79
94
  {#if inlineLevelButtons.length}
80
95
  <Divider orientation="vertical" />
@@ -95,7 +110,7 @@
95
110
  disabled={$hasConverterError}
96
111
  pressed={!$useRichText}
97
112
  aria-label={$_('_sui.text_editor.edit_in_markdown')}
98
- on:click={() => {
113
+ onclick={() => {
99
114
  $useRichText = !$useRichText;
100
115
 
101
116
  if ($useRichText) {
@@ -103,7 +118,9 @@
103
118
  }
104
119
  }}
105
120
  >
106
- <Icon slot="start-icon" name="markdown" />
121
+ {#snippet startIcon()}
122
+ <Icon name="markdown" />
123
+ {/snippet}
107
124
  </Button>
108
125
  {/if}
109
126
  </Toolbar>
@@ -1,18 +1,43 @@
1
1
  export default EditorToolbar;
2
- type EditorToolbar = SvelteComponent<{
3
- disabled?: boolean | undefined;
4
- readonly?: boolean | undefined;
5
- }, {
2
+ type EditorToolbar = SvelteComponent<Props & Record<string, any>, {
6
3
  [evt: string]: CustomEvent<any>;
7
4
  }, {}> & {
8
- $$bindings?: string | undefined;
5
+ $$bindings?: "" | undefined;
9
6
  };
10
7
  declare const EditorToolbar: $$__sveltets_2_IsomorphicComponent<{
8
+ /**
9
+ * - Whether to hide the widget.
10
+ */
11
+ hidden?: boolean | undefined;
12
+ /**
13
+ * - Whether to disable the widget. An alias of the `aria-disabled`
14
+ * attribute.
15
+ */
11
16
  disabled?: boolean | undefined;
17
+ /**
18
+ * - Whether to make the widget read-only. An alias of the
19
+ * `aria-readonly` attribute.
20
+ */
12
21
  readonly?: boolean | undefined;
13
- }, {
22
+ } & Record<string, any>, {
14
23
  [evt: string]: CustomEvent<any>;
15
- }, {}, {}, string>;
24
+ }, {}, {}, "">;
25
+ type Props = {
26
+ /**
27
+ * - Whether to hide the widget.
28
+ */
29
+ hidden?: boolean | undefined;
30
+ /**
31
+ * - Whether to disable the widget. An alias of the `aria-disabled`
32
+ * attribute.
33
+ */
34
+ disabled?: boolean | undefined;
35
+ /**
36
+ * - Whether to make the widget read-only. An alias of the
37
+ * `aria-readonly` attribute.
38
+ */
39
+ readonly?: boolean | undefined;
40
+ };
16
41
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
17
42
  new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
18
43
  $$bindings?: Bindings;
@@ -7,10 +7,18 @@
7
7
  import Icon from '../../icon/icon.svelte';
8
8
 
9
9
  /**
10
- * Button type.
11
- * @type {import('../../../typedefs').TextEditorFormatType}
10
+ * @typedef {object} Props
11
+ * @property {import('../../../typedefs').TextEditorFormatType} type - Button type.
12
12
  */
13
- export let type;
13
+
14
+ /**
15
+ * @type {Props & Record<string, any>}
16
+ */
17
+ let {
18
+ /* eslint-disable prefer-const */
19
+ type,
20
+ /* eslint-enable prefer-const */
21
+ } = $props();
14
22
 
15
23
  /**
16
24
  * Text editor state.
@@ -25,9 +33,11 @@
25
33
  aria-controls="{$editorId}-lexical-root"
26
34
  disabled={!$useRichText}
27
35
  pressed={$selectionInlineTypes.includes(type)}
28
- on:click={() => {
36
+ onclick={() => {
29
37
  $editor.dispatchCommand(FORMAT_TEXT_COMMAND, type);
30
38
  }}
31
39
  >
32
- <Icon slot="start-icon" name={availableButtons[type].icon} />
40
+ {#snippet startIcon()}
41
+ <Icon name={availableButtons[type].icon} />
42
+ {/snippet}
33
43
  </Button>
@@ -1,16 +1,23 @@
1
1
  export default FormatTextButton;
2
- type FormatTextButton = SvelteComponent<{
3
- type: TextEditorFormatType;
4
- }, {
2
+ type FormatTextButton = SvelteComponent<Props & Record<string, any>, {
5
3
  [evt: string]: CustomEvent<any>;
6
4
  }, {}> & {
7
- $$bindings?: string | undefined;
5
+ $$bindings?: "" | undefined;
8
6
  };
9
7
  declare const FormatTextButton: $$__sveltets_2_IsomorphicComponent<{
8
+ /**
9
+ * - Button type.
10
+ */
10
11
  type: import("../../../typedefs").TextEditorFormatType;
11
- }, {
12
+ } & Record<string, any>, {
12
13
  [evt: string]: CustomEvent<any>;
13
- }, {}, {}, string>;
14
+ }, {}, {}, "">;
15
+ type Props = {
16
+ /**
17
+ * - Button type.
18
+ */
19
+ type: import("../../../typedefs").TextEditorFormatType;
20
+ };
14
21
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
22
  new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
16
23
  $$bindings?: Bindings;
@@ -14,7 +14,7 @@
14
14
  import { getContext } from 'svelte';
15
15
  import { _ } from 'svelte-i18n';
16
16
  import { availableButtons } from '..';
17
- import { isMac, matchShortcuts } from '../../../services/events';
17
+ import { isMac, matchShortcuts } from '../../../services/events.svelte';
18
18
  import Button from '../../button/button.svelte';
19
19
  import Dialog from '../../dialog/dialog.svelte';
20
20
  import Icon from '../../icon/icon.svelte';
@@ -33,12 +33,12 @@
33
33
  */
34
34
  const { editor, editorId, selectionInlineTypes, useRichText } = getContext('state');
35
35
 
36
- let openDialog = false;
36
+ let openDialog = $state(false);
37
37
  /** @type {'create' | 'update' | 'remove'} */
38
- let dialogMode = 'create';
39
- let hasAnchor = false;
40
- let anchorURL = '';
41
- let anchorText = '';
38
+ let dialogMode = $state('create');
39
+ let hasAnchor = $state(false);
40
+ let anchorURL = $state('');
41
+ let anchorText = $state('');
42
42
 
43
43
  /**
44
44
  * Create a new link by showing a dialog to accept a URL and optionally text.
@@ -163,11 +163,11 @@
163
163
  );
164
164
  };
165
165
 
166
- $: {
166
+ $effect(() => {
167
167
  if ($editor) {
168
168
  _registerCommand();
169
169
  }
170
- }
170
+ });
171
171
  </script>
172
172
 
173
173
  <Button
@@ -176,11 +176,13 @@
176
176
  aria-controls="{$editorId}-lexical-root"
177
177
  disabled={!$useRichText}
178
178
  pressed={$selectionInlineTypes.includes(type)}
179
- on:click={() => {
179
+ onclick={() => {
180
180
  onButtonClick();
181
181
  }}
182
182
  >
183
- <Icon slot="start-icon" name={availableButtons[type].icon} />
183
+ {#snippet startIcon()}
184
+ <Icon name={availableButtons[type].icon} />
185
+ {/snippet}
184
186
  </Button>
185
187
 
186
188
  <Dialog
@@ -191,7 +193,7 @@
191
193
  bind:value={anchorURL}
192
194
  okDisabled={!isURL(anchorURL)}
193
195
  okLabel={dialogMode === 'create' ? $_('_sui.insert') : $_('_sui.update')}
194
- on:close={(event) => {
196
+ onClose={(event) => {
195
197
  onDialogClose(event);
196
198
  }}
197
199
  >
@@ -203,7 +205,7 @@
203
205
  autofocus
204
206
  bind:value={anchorText}
205
207
  flex
206
- on:keydown={(event) => {
208
+ onkeydown={(event) => {
207
209
  onInputKeyDown(event);
208
210
  }}
209
211
  />
@@ -217,22 +219,22 @@
217
219
  bind:value={anchorURL}
218
220
  flex
219
221
  aria-label="URL"
220
- on:keydown={(event) => {
222
+ onkeydown={(event) => {
221
223
  onInputKeyDown(event);
222
224
  }}
223
225
  />
224
226
  </div>
225
- <svelte:fragment slot="footer-extra">
227
+ {#snippet footerExtra()}
226
228
  {#if dialogMode !== 'create'}
227
229
  <Button
228
230
  variant="secondary"
229
231
  label={$_('_sui.remove')}
230
- on:click={() => {
232
+ onclick={() => {
231
233
  removeLink();
232
234
  dialogMode = 'remove';
233
235
  openDialog = false;
234
236
  }}
235
237
  />
236
238
  {/if}
237
- </svelte:fragment>
239
+ {/snippet}
238
240
  </Dialog>
@@ -1,16 +1,12 @@
1
1
  export default InsertLinkButton;
2
- type InsertLinkButton = SvelteComponent<{
3
- [x: string]: never;
4
- }, {
2
+ type InsertLinkButton = SvelteComponent<Record<string, never>, {
5
3
  [evt: string]: CustomEvent<any>;
6
4
  }, {}> & {
7
- $$bindings?: string | undefined;
5
+ $$bindings?: "" | undefined;
8
6
  };
9
- declare const InsertLinkButton: $$__sveltets_2_IsomorphicComponent<{
10
- [x: string]: never;
11
- }, {
7
+ declare const InsertLinkButton: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
12
8
  [evt: string]: CustomEvent<any>;
13
- }, {}, {}, string>;
9
+ }, {}, {}, "">;
14
10
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
11
  new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
16
12
  $$bindings?: Bindings;