@sveltia/ui 0.15.16 → 0.17.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 (157) hide show
  1. package/package/components/alert/alert.svelte +22 -7
  2. package/package/components/alert/alert.svelte.d.ts +47 -31
  3. package/package/components/button/button-group.svelte +16 -6
  4. package/package/components/button/button-group.svelte.d.ts +38 -28
  5. package/package/components/button/button.svelte +41 -136
  6. package/package/components/button/button.svelte.d.ts +20 -162
  7. package/package/components/button/select-button-group.svelte +31 -37
  8. package/package/components/button/select-button-group.svelte.d.ts +91 -39
  9. package/package/components/button/select-button.svelte +19 -62
  10. package/package/components/button/select-button.svelte.d.ts +31 -65
  11. package/package/components/button/split-button.svelte +37 -47
  12. package/package/components/button/split-button.svelte.d.ts +54 -60
  13. package/package/components/calendar/calendar.svelte +80 -55
  14. package/package/components/calendar/calendar.svelte.d.ts +30 -26
  15. package/package/components/checkbox/checkbox-group.svelte +23 -20
  16. package/package/components/checkbox/checkbox-group.svelte.d.ts +64 -32
  17. package/package/components/checkbox/checkbox.svelte +57 -67
  18. package/package/components/checkbox/checkbox.svelte.d.ts +81 -53
  19. package/package/components/dialog/alert-dialog.svelte +9 -36
  20. package/package/components/dialog/alert-dialog.svelte.d.ts +20 -49
  21. package/package/components/dialog/confirmation-dialog.svelte +9 -41
  22. package/package/components/dialog/confirmation-dialog.svelte.d.ts +20 -51
  23. package/package/components/dialog/dialog.svelte +60 -105
  24. package/package/components/dialog/dialog.svelte.d.ts +19 -86
  25. package/package/components/dialog/prompt-dialog.svelte +32 -61
  26. package/package/components/dialog/prompt-dialog.svelte.d.ts +53 -65
  27. package/package/components/disclosure/disclosure.svelte +39 -34
  28. package/package/components/disclosure/disclosure.svelte.d.ts +88 -57
  29. package/package/components/divider/divider.svelte +18 -14
  30. package/package/components/divider/divider.svelte.d.ts +48 -26
  31. package/package/components/divider/spacer.svelte +13 -8
  32. package/package/components/divider/spacer.svelte.d.ts +37 -25
  33. package/package/components/drawer/drawer.svelte +63 -76
  34. package/package/components/drawer/drawer.svelte.d.ts +116 -70
  35. package/package/components/grid/grid-body.svelte +15 -10
  36. package/package/components/grid/grid-body.svelte.d.ts +45 -29
  37. package/package/components/grid/grid-cell.svelte +16 -6
  38. package/package/components/grid/grid-cell.svelte.d.ts +38 -28
  39. package/package/components/grid/grid-col-header.svelte +16 -6
  40. package/package/components/grid/grid-col-header.svelte.d.ts +38 -28
  41. package/package/components/grid/grid-foot.svelte +16 -6
  42. package/package/components/grid/grid-foot.svelte.d.ts +38 -28
  43. package/package/components/grid/grid-head.svelte +16 -6
  44. package/package/components/grid/grid-head.svelte.d.ts +38 -28
  45. package/package/components/grid/grid-row-header.svelte +16 -6
  46. package/package/components/grid/grid-row-header.svelte.d.ts +38 -28
  47. package/package/components/grid/grid-row.svelte +19 -23
  48. package/package/components/grid/grid-row.svelte.d.ts +63 -43
  49. package/package/components/grid/grid.svelte +26 -25
  50. package/package/components/grid/grid.svelte.d.ts +71 -37
  51. package/package/components/icon/icon.svelte +14 -9
  52. package/package/components/icon/icon.svelte.d.ts +37 -25
  53. package/package/components/listbox/listbox.svelte +46 -52
  54. package/package/components/listbox/listbox.svelte.d.ts +117 -45
  55. package/package/components/listbox/option-group.svelte +23 -19
  56. package/package/components/listbox/option-group.svelte.d.ts +64 -32
  57. package/package/components/listbox/option.svelte +44 -57
  58. package/package/components/listbox/option.svelte.d.ts +68 -74
  59. package/package/components/menu/menu-button.svelte +42 -63
  60. package/package/components/menu/menu-button.svelte.d.ts +35 -62
  61. package/package/components/menu/menu-item-checkbox.svelte +29 -41
  62. package/package/components/menu/menu-item-checkbox.svelte.d.ts +20 -49
  63. package/package/components/menu/menu-item-group.svelte +22 -19
  64. package/package/components/menu/menu-item-group.svelte.d.ts +56 -32
  65. package/package/components/menu/menu-item-radio.svelte +29 -41
  66. package/package/components/menu/menu-item-radio.svelte.d.ts +20 -49
  67. package/package/components/menu/menu-item.svelte +66 -75
  68. package/package/components/menu/menu-item.svelte.d.ts +19 -68
  69. package/package/components/menu/menu.svelte +25 -22
  70. package/package/components/menu/menu.svelte.d.ts +65 -35
  71. package/package/components/radio/radio-group.svelte +36 -42
  72. package/package/components/radio/radio-group.svelte.d.ts +100 -40
  73. package/package/components/radio/radio.svelte +45 -48
  74. package/package/components/radio/radio.svelte.d.ts +111 -47
  75. package/package/components/select/combobox.svelte +76 -101
  76. package/package/components/select/combobox.svelte.d.ts +19 -54
  77. package/package/components/select/select-tags.svelte +48 -59
  78. package/package/components/select/select-tags.svelte.d.ts +127 -45
  79. package/package/components/select/select.svelte +18 -37
  80. package/package/components/select/select.svelte.d.ts +20 -45
  81. package/package/components/slider/slider.svelte +71 -68
  82. package/package/components/slider/slider.svelte.d.ts +159 -47
  83. package/package/components/switch/switch.svelte +36 -46
  84. package/package/components/switch/switch.svelte.d.ts +98 -42
  85. package/package/components/table/table-body.svelte +15 -11
  86. package/package/components/table/table-body.svelte.d.ts +45 -29
  87. package/package/components/table/table-cell.svelte +16 -6
  88. package/package/components/table/table-cell.svelte.d.ts +38 -28
  89. package/package/components/table/table-col-header.svelte +16 -6
  90. package/package/components/table/table-col-header.svelte.d.ts +38 -28
  91. package/package/components/table/table-foot.svelte +16 -6
  92. package/package/components/table/table-foot.svelte.d.ts +38 -28
  93. package/package/components/table/table-head.svelte +16 -6
  94. package/package/components/table/table-head.svelte.d.ts +38 -28
  95. package/package/components/table/table-row-header.svelte +16 -6
  96. package/package/components/table/table-row-header.svelte.d.ts +38 -28
  97. package/package/components/table/table-row.svelte +16 -6
  98. package/package/components/table/table-row.svelte.d.ts +38 -28
  99. package/package/components/table/table.svelte +16 -6
  100. package/package/components/table/table.svelte.d.ts +38 -28
  101. package/package/components/tabs/tab-box.svelte +16 -9
  102. package/package/components/tabs/tab-box.svelte.d.ts +47 -27
  103. package/package/components/tabs/tab-list.svelte +36 -35
  104. package/package/components/tabs/tab-list.svelte.d.ts +80 -38
  105. package/package/components/tabs/tab-panel.svelte +16 -6
  106. package/package/components/tabs/tab-panel.svelte.d.ts +38 -28
  107. package/package/components/tabs/tab-panels.svelte +16 -6
  108. package/package/components/tabs/tab-panels.svelte.d.ts +38 -26
  109. package/package/components/tabs/tab.svelte +28 -25
  110. package/package/components/tabs/tab.svelte.d.ts +31 -55
  111. package/package/components/text-editor/lexical-root.svelte +38 -32
  112. package/package/components/text-editor/lexical-root.svelte.d.ts +91 -29
  113. package/package/components/text-editor/text-editor.svelte +63 -79
  114. package/package/components/text-editor/text-editor.svelte.d.ts +114 -36
  115. package/package/components/text-editor/toolbar/editor-toolbar.svelte +41 -24
  116. package/package/components/text-editor/toolbar/editor-toolbar.svelte.d.ts +49 -23
  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 +30 -22
  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 +20 -23
  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 +30 -22
  123. package/package/components/text-field/number-input.svelte +63 -81
  124. package/package/components/text-field/number-input.svelte.d.ts +62 -68
  125. package/package/components/text-field/password-input.svelte +38 -57
  126. package/package/components/text-field/password-input.svelte.d.ts +30 -58
  127. package/package/components/text-field/search-bar.svelte +45 -62
  128. package/package/components/text-field/search-bar.svelte.d.ts +42 -87
  129. package/package/components/text-field/text-area.svelte +38 -54
  130. package/package/components/text-field/text-area.svelte.d.ts +116 -50
  131. package/package/components/text-field/text-input.svelte +30 -86
  132. package/package/components/text-field/text-input.svelte.d.ts +20 -105
  133. package/package/components/toast/toast.svelte +36 -30
  134. package/package/components/toast/toast.svelte.d.ts +65 -33
  135. package/package/components/toolbar/toolbar.svelte +25 -25
  136. package/package/components/toolbar/toolbar.svelte.d.ts +72 -34
  137. package/package/components/util/app-shell.svelte +22 -10
  138. package/package/components/util/app-shell.svelte.d.ts +40 -34
  139. package/package/components/util/group.svelte +20 -15
  140. package/package/components/util/group.svelte.d.ts +55 -31
  141. package/package/components/util/modal.svelte +89 -105
  142. package/package/components/util/modal.svelte.d.ts +24 -82
  143. package/package/components/util/placeholder.svelte +21 -0
  144. package/package/components/util/placeholder.svelte.d.ts +34 -0
  145. package/package/components/util/popup.svelte +65 -62
  146. package/package/components/util/popup.svelte.d.ts +104 -82
  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 +16 -23
  152. package/package/components/util/portal.svelte +0 -36
  153. package/package/components/util/portal.svelte.d.ts +0 -32
  154. /package/package/services/{events.d.ts → events.svelte.d.ts} +0 -0
  155. /package/package/services/{events.js → events.svelte.js} +0 -0
  156. /package/package/services/{group.d.ts → group.svelte.d.ts} +0 -0
  157. /package/package/services/{popup.d.ts → popup.svelte.d.ts} +0 -0
@@ -1,44 +1,122 @@
1
- /** @typedef {typeof __propDef.props} TextEditorProps */
2
- /** @typedef {typeof __propDef.events} TextEditorEvents */
3
- /** @typedef {typeof __propDef.slots} TextEditorSlots */
1
+ export default TextEditor;
2
+ type TextEditor = SvelteComponent<Props & Record<string, any>, {
3
+ [evt: string]: CustomEvent<any>;
4
+ }, {}> & {
5
+ $$bindings?: "value" | undefined;
6
+ };
4
7
  /** A rich text editor based on Lexical. */
5
- export default class TextEditor extends SvelteComponent<{
6
- [x: string]: any;
7
- disabled?: boolean | undefined;
8
- invalid?: boolean | undefined;
9
- required?: boolean | undefined;
8
+ declare const TextEditor: $$__sveltets_2_IsomorphicComponent<{
9
+ /**
10
+ * - Input value.
11
+ */
10
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
+ */
11
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
+ */
12
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
+ */
13
68
  flex?: boolean | undefined;
69
+ /**
70
+ * - Enabled modes.
71
+ */
14
72
  modes?: import("../../typedefs").TextEditorMode[] | undefined;
73
+ /**
74
+ * - Enabled buttons.
75
+ */
15
76
  buttons?: (import("../../typedefs").TextEditorBlockType | import("../../typedefs").TextEditorInlineType)[] | undefined;
16
- }, {
17
- [evt: string]: CustomEvent<any>;
18
- }, {}> {
19
- }
20
- export type TextEditorProps = typeof __propDef.props;
21
- export type TextEditorEvents = typeof __propDef.events;
22
- export type TextEditorSlots = typeof __propDef.slots;
23
- import { SvelteComponent } from "svelte";
24
- declare const __propDef: {
25
- props: {
26
- [x: string]: any;
27
- disabled?: boolean | undefined;
28
- invalid?: boolean | undefined;
29
- required?: boolean | undefined;
30
- value?: string | undefined;
31
- hidden?: boolean | undefined;
32
- readonly?: boolean | undefined;
33
- flex?: boolean | undefined;
34
- modes?: import("../../typedefs").TextEditorMode[] | undefined;
35
- buttons?: (import("../../typedefs").TextEditorBlockType | import("../../typedefs").TextEditorInlineType)[] | undefined;
36
- };
37
- events: {
38
- [evt: string]: CustomEvent<any>;
39
- };
40
- slots: {};
41
- exports?: undefined;
42
- bindings?: undefined;
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;
43
109
  };
44
- export {};
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> {
111
+ new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
112
+ $$bindings?: Bindings;
113
+ } & Exports;
114
+ (internal: unknown, props: Props & {
115
+ $$events?: Events;
116
+ $$slots?: Slots;
117
+ }): Exports & {
118
+ $set?: any;
119
+ $on?: any;
120
+ };
121
+ z_$$bindings?: Bindings;
122
+ }
@@ -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,27 +1,53 @@
1
- /** @typedef {typeof __propDef.props} EditorToolbarProps */
2
- /** @typedef {typeof __propDef.events} EditorToolbarEvents */
3
- /** @typedef {typeof __propDef.slots} EditorToolbarSlots */
4
- export default class EditorToolbar extends SvelteComponent<{
1
+ export default EditorToolbar;
2
+ type EditorToolbar = SvelteComponent<Props & Record<string, any>, {
3
+ [evt: string]: CustomEvent<any>;
4
+ }, {}> & {
5
+ $$bindings?: "" | undefined;
6
+ };
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
+ */
5
16
  disabled?: boolean | undefined;
17
+ /**
18
+ * - Whether to make the widget read-only. An alias of the
19
+ * `aria-readonly` attribute.
20
+ */
6
21
  readonly?: boolean | undefined;
7
- }, {
22
+ } & Record<string, any>, {
8
23
  [evt: string]: CustomEvent<any>;
9
- }, {}> {
10
- }
11
- export type EditorToolbarProps = typeof __propDef.props;
12
- export type EditorToolbarEvents = typeof __propDef.events;
13
- export type EditorToolbarSlots = typeof __propDef.slots;
14
- import { SvelteComponent } from "svelte";
15
- declare const __propDef: {
16
- props: {
17
- disabled?: boolean | undefined;
18
- readonly?: boolean | undefined;
19
- };
20
- events: {
21
- [evt: string]: CustomEvent<any>;
22
- };
23
- slots: {};
24
- exports?: undefined;
25
- bindings?: undefined;
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;
26
40
  };
27
- export {};
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> {
42
+ new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
43
+ $$bindings?: Bindings;
44
+ } & Exports;
45
+ (internal: unknown, props: Props & {
46
+ $$events?: Events;
47
+ $$slots?: Slots;
48
+ }): Exports & {
49
+ $set?: any;
50
+ $on?: any;
51
+ };
52
+ z_$$bindings?: Bindings;
53
+ }
@@ -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,25 +1,33 @@
1
- /** @typedef {typeof __propDef.props} FormatTextButtonProps */
2
- /** @typedef {typeof __propDef.events} FormatTextButtonEvents */
3
- /** @typedef {typeof __propDef.slots} FormatTextButtonSlots */
4
- export default class FormatTextButton extends SvelteComponent<{
1
+ export default FormatTextButton;
2
+ type FormatTextButton = SvelteComponent<Props & Record<string, any>, {
3
+ [evt: string]: CustomEvent<any>;
4
+ }, {}> & {
5
+ $$bindings?: "" | undefined;
6
+ };
7
+ declare const FormatTextButton: $$__sveltets_2_IsomorphicComponent<{
8
+ /**
9
+ * - Button type.
10
+ */
5
11
  type: import("../../../typedefs").TextEditorFormatType;
6
- }, {
12
+ } & Record<string, any>, {
7
13
  [evt: string]: CustomEvent<any>;
8
- }, {}> {
9
- }
10
- export type FormatTextButtonProps = typeof __propDef.props;
11
- export type FormatTextButtonEvents = typeof __propDef.events;
12
- export type FormatTextButtonSlots = typeof __propDef.slots;
13
- import { SvelteComponent } from "svelte";
14
- declare const __propDef: {
15
- props: {
16
- type: import("../../../typedefs").TextEditorFormatType;
17
- };
18
- events: {
19
- [evt: string]: CustomEvent<any>;
20
- };
21
- slots: {};
22
- exports?: undefined;
23
- bindings?: undefined;
14
+ }, {}, {}, "">;
15
+ type Props = {
16
+ /**
17
+ * - Button type.
18
+ */
19
+ type: import("../../../typedefs").TextEditorFormatType;
24
20
  };
25
- export {};
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> {
22
+ new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
23
+ $$bindings?: Bindings;
24
+ } & Exports;
25
+ (internal: unknown, props: Props & {
26
+ $$events?: Events;
27
+ $$slots?: Slots;
28
+ }): Exports & {
29
+ $set?: any;
30
+ $on?: any;
31
+ };
32
+ z_$$bindings?: Bindings;
33
+ }
@@ -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,25 +1,22 @@
1
- /** @typedef {typeof __propDef.props} InsertLinkButtonProps */
2
- /** @typedef {typeof __propDef.events} InsertLinkButtonEvents */
3
- /** @typedef {typeof __propDef.slots} InsertLinkButtonSlots */
4
- export default class InsertLinkButton extends SvelteComponent<{
5
- [x: string]: never;
6
- }, {
1
+ export default InsertLinkButton;
2
+ type InsertLinkButton = SvelteComponent<Record<string, never>, {
7
3
  [evt: string]: CustomEvent<any>;
8
- }, {}> {
9
- }
10
- export type InsertLinkButtonProps = typeof __propDef.props;
11
- export type InsertLinkButtonEvents = typeof __propDef.events;
12
- export type InsertLinkButtonSlots = typeof __propDef.slots;
13
- import { SvelteComponent } from "svelte";
14
- declare const __propDef: {
15
- props: {
16
- [x: string]: never;
17
- };
18
- events: {
19
- [evt: string]: CustomEvent<any>;
20
- };
21
- slots: {};
22
- exports?: undefined;
23
- bindings?: undefined;
4
+ }, {}> & {
5
+ $$bindings?: "" | undefined;
24
6
  };
25
- export {};
7
+ declare const InsertLinkButton: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
8
+ [evt: string]: CustomEvent<any>;
9
+ }, {}, {}, "">;
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> {
11
+ new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
12
+ $$bindings?: Bindings;
13
+ } & Exports;
14
+ (internal: unknown, props: {
15
+ $$events?: Events;
16
+ $$slots?: Slots;
17
+ }): Exports & {
18
+ $set?: any;
19
+ $on?: any;
20
+ };
21
+ z_$$bindings?: Bindings;
22
+ }
@@ -12,13 +12,22 @@
12
12
  import { getContext } from 'svelte';
13
13
  import { _ } from 'svelte-i18n';
14
14
  import { availableButtons } from '..';
15
+ import Icon from '../../icon/icon.svelte';
15
16
  import MenuItemCheckbox from '../../menu/menu-item-checkbox.svelte';
16
17
 
17
18
  /**
18
- * Button type.
19
- * @type {import('../../../typedefs').TextEditorBlockType}
19
+ * @typedef {object} Props
20
+ * @property {import('../../../typedefs').TextEditorBlockType} type - Button type.
20
21
  */
21
- export let type;
22
+
23
+ /**
24
+ * @type {Props & Record<string, any>}
25
+ */
26
+ let {
27
+ /* eslint-disable prefer-const */
28
+ type,
29
+ /* eslint-enable prefer-const */
30
+ } = $props();
22
31
 
23
32
  /**
24
33
  * Text editor state.
@@ -29,7 +38,7 @@
29
38
  /**
30
39
  * Whether the current selection matches the button {@link type}.
31
40
  */
32
- $: selectionTypeMatches = $selectionBlockType === type;
41
+ const selectionTypeMatches = $derived($selectionBlockType === type);
33
42
 
34
43
  /**
35
44
  * Change the current selection’s type to {@link type}.
@@ -76,13 +85,16 @@
76
85
 
77
86
  {#key selectionTypeMatches}
78
87
  <MenuItemCheckbox
79
- iconName={availableButtons[type].icon}
80
88
  label={$_(`_sui.text_editor.${availableButtons[type].labelKey}`)}
81
89
  checked={selectionTypeMatches}
82
- on:click={() => {
90
+ onclick={() => {
83
91
  if (!selectionTypeMatches) {
84
92
  changeBlockType();
85
93
  }
86
94
  }}
87
- />
95
+ >
96
+ {#snippet startIcon()}
97
+ <Icon name={availableButtons[type].icon} />
98
+ {/snippet}
99
+ </MenuItemCheckbox>
88
100
  {/key}