@sveltia/ui 0.12.3 → 0.12.4

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.
@@ -1,6 +1,11 @@
1
1
  <script>
2
2
  import { getContext, onMount } from 'svelte';
3
3
 
4
+ /**
5
+ * Whether to hide the widget. An alias of the `aria-hidden` attribute.
6
+ * @type {boolean | undefined}
7
+ */
8
+ export let hidden = undefined;
4
9
  /**
5
10
  * Whether to disable the widget. An alias of the `aria-disabled` attribute.
6
11
  * @type {boolean}
@@ -11,6 +16,16 @@
11
16
  * @type {boolean}
12
17
  */
13
18
  export let readonly = false;
19
+ /**
20
+ * Whether to mark the widget required. An alias of the `aria-required` attribute.
21
+ * @type {boolean}
22
+ */
23
+ export let required = false;
24
+ /**
25
+ * Whether to mark the widget invalid. An alias of the `aria-invalid` attribute.
26
+ * @type {boolean}
27
+ */
28
+ export let invalid = false;
14
29
  /**
15
30
  * Input value.
16
31
  * @type {string | undefined}
@@ -21,14 +36,8 @@
21
36
  * Text editor state.
22
37
  * @type {TextEditorState}
23
38
  */
24
- const {
25
- editor,
26
- editorId,
27
- selectionBlockType,
28
- selectionInlineTypes,
29
- useRichText,
30
- hasConverterError,
31
- } = getContext('state');
39
+ const { editor, editorId, selectionBlockType, selectionInlineTypes, hasConverterError } =
40
+ getContext('state');
32
41
 
33
42
  /**
34
43
  * Reference to the Lexical editor root element.
@@ -86,19 +95,22 @@
86
95
  <div
87
96
  role="textbox"
88
97
  aria-multiline="true"
98
+ aria-hidden={hidden}
89
99
  aria-disabled={disabled}
90
100
  aria-readonly={readonly}
101
+ aria-required={required}
102
+ aria-invalid={invalid}
91
103
  class="lexical-root"
92
104
  id="{$editorId}-lexical-root"
93
105
  contenteditable={editable}
106
+ {hidden}
94
107
  bind:this={lexicalRoot}
95
- hidden={!$useRichText}
96
108
  ></div>
97
109
 
98
110
  <style>.lexical-root {
99
111
  border: 1px solid var(--sui-textbox-border-color);
100
112
  border-radius: 0 0 var(--sui-textbox-border-radius) var(--sui-textbox-border-radius) !important;
101
- padding: 16px;
113
+ padding: var(--sui-textbox-multiline-padding);
102
114
  min-height: 8em;
103
115
  color: var(--sui-textbox-foreground-color);
104
116
  background-color: var(--sui-textbox-background-color);
@@ -109,6 +121,9 @@
109
121
  .lexical-root:focus-visible {
110
122
  outline: 0;
111
123
  }
124
+ .lexical-root[aria-invalid=true] {
125
+ border-color: var(--sui-error-foreground-color);
126
+ }
112
127
  .lexical-root > :global(:first-child) {
113
128
  margin-top: 0;
114
129
  }
@@ -2,9 +2,12 @@
2
2
  /** @typedef {typeof __propDef.events} LexicalRootEvents */
3
3
  /** @typedef {typeof __propDef.slots} LexicalRootSlots */
4
4
  export default class LexicalRoot extends SvelteComponent<{
5
+ invalid?: boolean | undefined;
5
6
  disabled?: boolean | undefined;
6
7
  value?: string | undefined;
8
+ hidden?: boolean | undefined;
7
9
  readonly?: boolean | undefined;
10
+ required?: boolean | undefined;
8
11
  }, {
9
12
  [evt: string]: CustomEvent<any>;
10
13
  }, {}> {
@@ -15,9 +18,12 @@ export type LexicalRootSlots = typeof __propDef.slots;
15
18
  import { SvelteComponent } from "svelte";
16
19
  declare const __propDef: {
17
20
  props: {
21
+ invalid?: boolean | undefined;
18
22
  disabled?: boolean | undefined;
19
23
  value?: string | undefined;
24
+ hidden?: boolean | undefined;
20
25
  readonly?: boolean | undefined;
26
+ required?: boolean | undefined;
21
27
  };
22
28
  events: {
23
29
  [evt: string]: CustomEvent<any>;
@@ -121,7 +121,14 @@
121
121
 
122
122
  <div role="none" class="sui text-editor" hidden={hidden || undefined} {...$$restProps}>
123
123
  <EditorToolbar {disabled} {readonly} />
124
- <LexicalRoot {disabled} {readonly} bind:value />
124
+ <LexicalRoot
125
+ bind:value
126
+ hidden={!$useRichText || hidden}
127
+ {disabled}
128
+ {readonly}
129
+ {required}
130
+ {invalid}
131
+ />
125
132
  <TextArea
126
133
  autoResize={true}
127
134
  bind:value
@@ -163,7 +163,7 @@
163
163
  height: var(--sui-button-medium-height);
164
164
  }
165
165
  .search-bar :global(.label) {
166
- --sui-textbox-padding: 0 36px;
166
+ --sui-textbox-singleline-padding: 0 36px;
167
167
  }
168
168
  .search-bar :global(.text-input) {
169
169
  flex: auto;
@@ -113,7 +113,7 @@ textarea,
113
113
  border-width: var(--sui-textbox-border-width, 1px);
114
114
  border-color: var(--sui-textbox-border-color);
115
115
  border-radius: var(--sui-textbox-border-radius);
116
- padding: 8px;
116
+ padding: var(--sui-textbox-multiline-padding);
117
117
  width: 100%;
118
118
  min-height: 8em;
119
119
  color: var(--sui-textbox-foreground-color);
@@ -153,7 +153,7 @@ input {
153
153
  border-width: var(--sui-textbox-border-width, 1px);
154
154
  border-color: var(--sui-textbox-border-color);
155
155
  border-radius: var(--sui-textbox-border-radius);
156
- padding: var(--sui-textbox-padding, 0 8px);
156
+ padding: var(--sui-textbox-singleline-padding);
157
157
  min-width: 0;
158
158
  height: var(--sui-textbox-height);
159
159
  color: var(--sui-textbox-foreground-color);
@@ -200,7 +200,7 @@ input ~ :global(button) :global(.icon) {
200
200
 
201
201
  .label {
202
202
  position: absolute;
203
- inset: var(--sui-textbox-padding, 0 8px);
203
+ inset: var(--sui-textbox-singleline-padding);
204
204
  z-index: 2;
205
205
  display: flex;
206
206
  align-items: center;
@@ -224,8 +224,10 @@
224
224
  --sui-textbox-background-color: hsl(var(--sui-background-color-1-hsl));
225
225
  --sui-textbox-font-family: var(--sui-font-family-default);
226
226
  --sui-textbox-font-size: var(--sui-font-size-default);
227
+ --sui-textbox-singleline-padding: 0 8px;
227
228
  --sui-textbox-singleline-min-width: 240px;
228
229
  --sui-textbox-singleline-line-height: var(--sui-line-height-compact);
230
+ --sui-textbox-multiline-padding: 12px;
229
231
  --sui-textbox-multiline-min-width: 480px;
230
232
  --sui-textbox-multiline-line-height: var(--sui-line-height-comfortable);
231
233
  --sui-tab-height: var(--sui-control-medium-height);
@@ -493,6 +495,11 @@
493
495
  line-height: var(--sui-line-height-comfortable);
494
496
  }
495
497
 
498
+ :global(ul),
499
+ :global(ol) {
500
+ padding-left: 2em;
501
+ }
502
+
496
503
  :global(code),
497
504
  :global(pre) {
498
505
  border-radius: 4px;
@@ -102,6 +102,11 @@ li {
102
102
  line-height: var(--sui-line-height-comfortable);
103
103
  }
104
104
 
105
+ ul,
106
+ ol {
107
+ padding-left: 2em;
108
+ }
109
+
105
110
  code,
106
111
  pre {
107
112
  border-radius: 4px;
@@ -219,8 +219,10 @@
219
219
  --sui-textbox-background-color: hsl(var(--sui-background-color-1-hsl));
220
220
  --sui-textbox-font-family: var(--sui-font-family-default);
221
221
  --sui-textbox-font-size: var(--sui-font-size-default);
222
+ --sui-textbox-singleline-padding: 0 8px;
222
223
  --sui-textbox-singleline-min-width: 240px;
223
224
  --sui-textbox-singleline-line-height: var(--sui-line-height-compact);
225
+ --sui-textbox-multiline-padding: 12px;
224
226
  --sui-textbox-multiline-min-width: 480px;
225
227
  --sui-textbox-multiline-line-height: var(--sui-line-height-comfortable);
226
228
  // Tab
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.12.3",
3
+ "version": "0.12.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {