@axel669/zephyr 0.1.17 → 0.2.0-beta.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 (115) hide show
  1. package/LICENSE +21 -21
  2. package/package.json +10 -7
  3. package/readme.md +55 -44
  4. package/src/async/button.svelte +31 -0
  5. package/src/async/load-zone.svelte +17 -0
  6. package/src/composed/data-table/th.svelte +60 -0
  7. package/src/composed/data-table.md +83 -0
  8. package/src/composed/data-table.svelte +136 -150
  9. package/src/composed/entry-button.md +34 -0
  10. package/src/composed/entry-button.svelte +29 -68
  11. package/src/composed/table-functions.js +13 -0
  12. package/src/composed/toast/message.svelte +56 -44
  13. package/src/composed/toast.md +36 -0
  14. package/src/composed/toast.svelte +68 -108
  15. package/src/control/button.md +37 -0
  16. package/src/control/button.svelte +25 -0
  17. package/src/control/input.svelte +107 -0
  18. package/src/control/label.md +45 -0
  19. package/src/control/label.svelte +36 -0
  20. package/src/control/link.md +46 -0
  21. package/src/control/link.svelte +28 -0
  22. package/src/control/radio.md +56 -0
  23. package/src/control/radio.svelte +26 -0
  24. package/src/control/select.md +68 -0
  25. package/src/control/select.svelte +62 -0
  26. package/src/control/tabs.md +45 -0
  27. package/src/control/tabs.svelte +39 -0
  28. package/src/control/toggle.md +55 -0
  29. package/src/control/toggle.svelte +47 -0
  30. package/src/data-display/avatar.md +32 -0
  31. package/src/data-display/avatar.svelte +23 -0
  32. package/src/data-display/badge.md +24 -0
  33. package/src/data-display/badge.svelte +12 -0
  34. package/src/data-display/chip.md +32 -0
  35. package/src/data-display/chip.svelte +26 -0
  36. package/src/data-display/details.md +3 -0
  37. package/src/{details.svelte → data-display/details.svelte} +3 -3
  38. package/src/data-display/popover.md +28 -0
  39. package/src/data-display/popover.svelte +23 -0
  40. package/src/data-display/progress.md +42 -0
  41. package/src/data-display/progress.svelte +25 -0
  42. package/src/data-display/table.md +7 -0
  43. package/src/data-display/table.svelte +36 -0
  44. package/src/data-display/tooltip.md +25 -0
  45. package/src/data-display/tooltip.svelte +15 -0
  46. package/src/dialogs/alert.md +3 -0
  47. package/src/dialogs/alert.svelte +4 -4
  48. package/src/dialogs/confirm.md +3 -0
  49. package/src/dialogs/confirm.svelte +5 -5
  50. package/src/functions.md +77 -0
  51. package/src/handler$.mjs +20 -68
  52. package/src/index.mjs +58 -92
  53. package/src/info/icon.md +17 -0
  54. package/src/info/icon.svelte +9 -0
  55. package/src/info/notification.md +32 -0
  56. package/src/info/notification.svelte +16 -0
  57. package/src/info/titlebar.md +49 -0
  58. package/src/info/titlebar.svelte +18 -0
  59. package/src/info/toaster.md +22 -0
  60. package/src/info/toaster.svelte +14 -0
  61. package/src/inline-dialog.svelte +23 -23
  62. package/src/layout/dialog.md +34 -0
  63. package/src/layout/dialog.svelte +24 -0
  64. package/src/layout/drawer.md +61 -0
  65. package/src/layout/drawer.svelte +47 -0
  66. package/src/layout/flex.md +39 -0
  67. package/src/layout/flex.svelte +22 -0
  68. package/src/layout/grid.md +57 -0
  69. package/src/layout/grid.svelte +26 -0
  70. package/src/layout/modal.md +47 -0
  71. package/src/layout/modal.svelte +58 -0
  72. package/src/layout/paper.md +90 -0
  73. package/src/layout/paper.svelte +45 -0
  74. package/src/layout/screen.md +28 -0
  75. package/src/layout/screen.svelte +32 -0
  76. package/src/{circle-spinner.svelte → spinner/circle-spinner.svelte} +2 -2
  77. package/src/{hexagon-spinner.svelte → spinner/hexagon-spinner.svelte} +2 -2
  78. package/src/spinner/spinners.md +3 -0
  79. package/src/text.md +34 -0
  80. package/src/text.svelte +20 -49
  81. package/src/variant.mjs +12 -12
  82. package/src/wsx.mjs +24 -45
  83. package/src/avatar.svelte +0 -54
  84. package/src/badge.svelte +0 -40
  85. package/src/button.svelte +0 -86
  86. package/src/chip.svelte +0 -56
  87. package/src/dialog.svelte +0 -54
  88. package/src/drawer.svelte +0 -121
  89. package/src/flex.svelte +0 -57
  90. package/src/grid.svelte +0 -66
  91. package/src/icon.svelte +0 -34
  92. package/src/input/area.svelte +0 -98
  93. package/src/input/elems.mjs +0 -7
  94. package/src/input/email.svelte +0 -104
  95. package/src/input/file.svelte +0 -82
  96. package/src/input/number.svelte +0 -104
  97. package/src/input/password.svelte +0 -101
  98. package/src/input/search.svelte +0 -104
  99. package/src/input/text.svelte +0 -104
  100. package/src/link.svelte +0 -67
  101. package/src/modal.svelte +0 -73
  102. package/src/notification.svelte +0 -57
  103. package/src/paper.svelte +0 -127
  104. package/src/popover.svelte +0 -60
  105. package/src/progress.svelte +0 -60
  106. package/src/radio.svelte +0 -82
  107. package/src/screen.svelte +0 -69
  108. package/src/select.svelte +0 -122
  109. package/src/table.svelte +0 -69
  110. package/src/tabs.svelte +0 -78
  111. package/src/titlebar.svelte +0 -69
  112. package/src/toaster.svelte +0 -42
  113. package/src/toggle.svelte +0 -94
  114. package/src/tooltip.svelte +0 -45
  115. package/src/vars.mjs +0 -61
@@ -1,98 +0,0 @@
1
- <script>
2
- /*md
3
- [@] Components/Input/Area
4
-
5
- # Input.Area
6
-
7
- A multiline text input component.
8
-
9
- ## Base
10
- [Windstorm Labled Control](https://axel669.github.io/lib.windstorm/#components-labeled-control)
11
- using a `<textarea>`
12
-
13
- ## Props
14
- All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
15
- are supported.
16
-
17
- - ### color `string`
18
- Sets `$color`
19
- - ### error `string`
20
- Shows an error message under the input
21
- - ### flat `bool`
22
- Sets `@flat`
23
- - ### hint `string`
24
- Shows a hint under the label. If no label is provided, the hint will not
25
- be shown either
26
- - ### label `string`
27
- The label for the input
28
- - ### transform `function`
29
- If given, it will transform the text value from the input and set the
30
- `tvalue` to the result
31
- - ### tvalue
32
- Value that can be bound to as the output of the transform function.
33
- Setting has no effect
34
- - ### validate `function`
35
- If given, will check the transformed output against a validation
36
- criteria and store the result in `valid`
37
- - ### valid `bool`
38
- Value that can be bound to as the output of the validation function.
39
- Setting has no effect
40
- - ### value `string`
41
- The value of the textarea, can be bound to
42
-
43
- ## Functions
44
- - focus()\\
45
- Focuses the textarea
46
-
47
- ## Usage
48
- ```js
49
- import { Input } from "@axel669/svelte-wind"
50
- ```
51
- ```svelte
52
- <Input.Area bind:value />
53
- <Input.Area bind:value color="primary" />
54
- <Input.Area bind:value label="Wat" hint="Blep"/>
55
- <Input.Area bind:value bind:tvalue transform={txt => txt.toLowerCase()} />
56
- <Input.Area bind:value bind:valid validate={txt => txt.indexOf("a") > 0} />
57
- ```
58
- */
59
-
60
- import wsx from "../wsx.mjs"
61
-
62
- export let flat = false
63
- export let label
64
- export let color = "default"
65
- export let error = null
66
- export let hint = null
67
- export let disabled
68
-
69
- export let value = ""
70
-
71
- export let transform = i => i
72
- export let tvalue
73
- export let validate = () => true
74
- export let valid
75
-
76
- let area = null
77
- export const focus = () => area.focus()
78
-
79
- $: wind = {
80
- "@flat": flat,
81
- "@control": true,
82
- $color: color,
83
- ...$$restProps,
84
- }
85
-
86
- $: tvalue = transform(value ?? "")
87
- $: valid = validate(tvalue)
88
- </script>
89
-
90
- <label use:wsx={wind} ws-error={error}>
91
- {#if label}
92
- <span ws-x="$text" ws-hint={hint}>{label}</span>
93
- {/if}
94
- <textarea {disabled} {...$$restProps} bind:value on:focus on:blur bind:this={area} />
95
-
96
- <slot name="start" />
97
- <slot name="end" />
98
- </label>
@@ -1,7 +0,0 @@
1
- export { default as Area } from "./area.svelte"
2
- export { default as Email } from "./email.svelte"
3
- export { default as File } from "./file.svelte"
4
- export { default as Number } from "./number.svelte"
5
- export { default as Password } from "./password.svelte"
6
- export { default as Search } from "./search.svelte"
7
- export { default as Text } from "./text.svelte"
@@ -1,104 +0,0 @@
1
- <script>
2
- /*md
3
- [@] Components/Input/Email
4
-
5
- # Input.Email
6
-
7
- A multiline text input component.
8
-
9
- ## Base
10
- [Windstorm Labled Control](https://axel669.github.io/lib.windstorm/#components-labeled-control)
11
- using an input with type="email"
12
-
13
- ## Props
14
- All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
15
- are supported.
16
-
17
- - ### color `string`
18
- Sets `$color`
19
- - ### error `string`
20
- Shows an error message under the input
21
- - ### flat `bool`
22
- Sets `@flat`
23
- - ### hint `string`
24
- Shows a hint under the label. If no label is provided, the hint will not
25
- be shown either
26
- - ### label `string`
27
- The label for the input
28
- - ### transform `function`
29
- If given, it will transform the text value from the input and set the
30
- `tvalue` to the result
31
- - ### tvalue
32
- Value that can be bound to as the output of the transform function.
33
- Setting has no effect
34
- - ### validate `function`
35
- If given, will check the transformed output against a validation
36
- criteria and store the result in `valid`
37
- - ### valid `bool`
38
- Value that can be bound to as the output of the validation function.
39
- Setting has no effect
40
- - ### value `string`
41
- The value of the textarea, can be bound to
42
-
43
- ## Functions
44
- - focus()\\
45
- Focuses the input
46
-
47
- ## Usage
48
- ```js
49
- import { Input } from "@axel669/svelte-wind"
50
- ```svelte
51
- <Input.Email bind:value />
52
- <Input.Email bind:value color="primary" />
53
- <Input.Email bind:value label="Wat" hint="Blep"/>
54
- <Input.Email bind:value bind:tvalue transform={txt => txt.toLowerCase()} />
55
- <Input.Email bind:value bind:valid validate={txt => txt.indexOf("a") > 0} />
56
- ```
57
- */
58
-
59
- import wsx from "../wsx.mjs"
60
-
61
- export let flat = false
62
- export let label
63
- export let color = "default"
64
- export let error = null
65
- export let hint = null
66
- export let disabled
67
-
68
- export let value = ""
69
-
70
- export let transform = i => i
71
- export let tvalue
72
- export let validate = () => true
73
- export let valid
74
-
75
- let input = null
76
- export const focus = () => input.focus()
77
-
78
- $: wind = {
79
- "@flat": flat,
80
- "@control": true,
81
- $color: color,
82
- ...$$restProps,
83
- }
84
-
85
- $: tvalue = transform(value ?? "")
86
- $: valid = validate(tvalue)
87
- </script>
88
-
89
- <label use:wsx={wind} ws-error={error}>
90
- {#if label}
91
- <span ws-x="$text" ws-hint={hint}>{label}</span>
92
- {/if}
93
- <input {...$$restProps}
94
- type="email"
95
- {disabled}
96
- bind:value
97
- on:focus
98
- on:blur
99
- bind:this={input}
100
- />
101
-
102
- <slot name="start" />
103
- <slot name="end" />
104
- </label>
@@ -1,82 +0,0 @@
1
- <script>
2
- /*md
3
- [@] Components/Input/File
4
-
5
- # Input.File
6
-
7
- A multiline text input component.
8
-
9
- ## Base
10
- [Windstorm Labled Control](https://axel669.github.io/lib.windstorm/#components-labeled-control)
11
- using an input with type="file"
12
-
13
- ## Props
14
- All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
15
- are supported.
16
-
17
- - ### color `string`
18
- Sets `$color`
19
- - ### error `string`
20
- Shows an error message under the input
21
- - ### flat `bool`
22
- Sets `@flat`
23
- - ### hint `string`
24
- Shows a hint under the label. If no label is provided, the hint will not
25
- be shown either
26
- - ### label `string`
27
- The label for the input
28
- - ### validate `function`
29
- If given, will check the transformed output against a validation
30
- criteria and store the result in `valid`
31
- - ### valid `bool`
32
- Value that can be bound to as the output of the validation function.
33
- Setting has no effect
34
- - ### value `string`
35
- The value of the textarea, can be bound to
36
-
37
- ## Usage
38
- ```js
39
- import { Input } from "@axel669/svelte-wind"
40
- ```svelte
41
- <Input.File bind:value />
42
- <Input.File bind:value color="primary" />
43
- <Input.File bind:value label="Wat" hint="Blep"/>
44
- <Input.File bind:value bind:valid validate={file => file[0].type !== "text"} />
45
- ```
46
- */
47
-
48
- import wsx from "../wsx.mjs"
49
-
50
- export let flat = false
51
- export let label
52
- export let color = "default"
53
- export let error = null
54
- export let hint = null
55
- export let disabled
56
-
57
- export let value
58
-
59
- export let validate = () => true
60
- export let valid
61
-
62
- const handler = (evt) => value = [...evt.target.files]
63
-
64
- $: wind = {
65
- "@flat": flat,
66
- "@control": true,
67
- $color: color,
68
- ...$$restProps,
69
- }
70
-
71
- $: valid = validate(value)
72
- </script>
73
-
74
- <label use:wsx={wind} ws-error={error}>
75
- {#if label}
76
- <span ws-x="$text" ws-hint={hint}>{label}</span>
77
- {/if}
78
- <input {disabled} {...$$restProps} type="file" on:input={handler} />
79
-
80
- <slot name="start" />
81
- <slot name="end" />
82
- </label>
@@ -1,104 +0,0 @@
1
- <script>
2
- /*md
3
- [@] Components/Input/Number
4
-
5
- # Input.Number
6
-
7
- A multiline text input component.
8
-
9
- ## Base
10
- [Windstorm Labled Control](https://axel669.github.io/lib.windstorm/#components-labeled-control)
11
- using an input with type="number"
12
-
13
- ## Props
14
- All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
15
- are supported.
16
-
17
- - ### color `string`
18
- Sets `$color`
19
- - ### error `string`
20
- Shows an error message under the input
21
- - ### flat `bool`
22
- Sets `@flat`
23
- - ### hint `string`
24
- Shows a hint under the label. If no label is provided, the hint will not
25
- be shown either
26
- - ### label `string`
27
- The label for the input
28
- - ### transform `function`
29
- If given, it will transform the text value from the input and set the
30
- `tvalue` to the result
31
- - ### tvalue
32
- Value that can be bound to as the output of the transform function.
33
- Setting has no effect
34
- - ### validate `function`
35
- If given, will check the transformed output against a validation
36
- criteria and store the result in `valid`
37
- - ### valid `bool`
38
- Value that can be bound to as the output of the validation function.
39
- Setting has no effect
40
- - ### value `string`
41
- The value of the textarea, can be bound to
42
-
43
- ## Functions
44
- - focus()\\
45
- Focuses the input
46
-
47
- ## Usage
48
- ```js
49
- import { Input } from "@axel669/svelte-wind"
50
- ```svelte
51
- <Input.Number bind:value />
52
- <Input.Number bind:value color="primary" />
53
- <Input.Number bind:value label="Wat" hint="Blep"/>
54
- <Input.Number bind:value bind:tvalue transform={parseInt} />
55
- <Input.Number bind:value transform={parseInt} bind:valid validate={value => value > 0} />
56
- ```
57
- */
58
-
59
- import wsx from "../wsx.mjs"
60
-
61
- export let flat = false
62
- export let label
63
- export let color = "default"
64
- export let error = null
65
- export let hint = null
66
- export let disabled
67
-
68
- export let value = ""
69
-
70
- export let transform = i => i
71
- export let tvalue
72
- export let validate = () => true
73
- export let valid
74
-
75
- let input = null
76
- export const focus = () => input.focus()
77
-
78
- $: wind = {
79
- "@flat": flat,
80
- "@control": true,
81
- $color: color,
82
- ...$$restProps,
83
- }
84
-
85
- $: tvalue = transform(value ?? "")
86
- $: valid = validate(tvalue)
87
- </script>
88
-
89
- <label use:wsx={wind} ws-error={error}>
90
- {#if label}
91
- <span ws-x="$text" ws-hint={hint}>{label}</span>
92
- {/if}
93
- <input {...$$restProps}
94
- type="number"
95
- {disabled}
96
- bind:value
97
- on:focus
98
- on:blur
99
- bind:this={input}
100
- />
101
-
102
- <slot name="start" />
103
- <slot name="end" />
104
- </label>
@@ -1,101 +0,0 @@
1
- <script>
2
- /*md
3
- [@] Components/Input/Password
4
-
5
- # Input.Password
6
-
7
- A multiline text input component.
8
-
9
- ## Base
10
- [Windstorm Labled Control](https://axel669.github.io/lib.windstorm/#components-labeled-control)
11
- using an input with type="password"
12
-
13
- ## Props
14
- All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
15
- are supported.
16
-
17
- - ### color `string`
18
- Sets `$color`
19
- - ### error `string`
20
- Shows an error message under the input
21
- - ### flat `bool`
22
- Sets `@flat`
23
- - ### hint `string`
24
- Shows a hint under the label. If no label is provided, the hint will not
25
- be shown either
26
- - ### label `string`
27
- The label for the input
28
- - ### transform `function`
29
- If given, it will transform the text value from the input and set the
30
- `tvalue` to the result
31
- - ### tvalue
32
- Value that can be bound to as the output of the transform function.
33
- Setting has no effect
34
- - ### validate `function`
35
- If given, will check the transformed output against a validation
36
- criteria and store the result in `valid`
37
- - ### valid `bool`
38
- Value that can be bound to as the output of the validation function.
39
- Setting has no effect
40
- - ### value `string`
41
- The value of the textarea, can be bound to
42
-
43
- ## Functions
44
- - focus()\\
45
- Focuses the textarea
46
-
47
- ## Usage
48
- ```js
49
- import { Input } from "@axel669/svelte-wind"
50
- ```
51
- ```svelte
52
- <Input.Password bind:value />
53
- <Input.Password bind:value color="primary" />
54
- <Input.Password bind:value label="Wat" hint="Blep"/>
55
- <Input.Password bind:value bind:valid validate={txt => txt.indexOf("a") > 0} />
56
- ```
57
- */
58
-
59
- import wsx from "../wsx.mjs"
60
-
61
- export let flat = false
62
- export let label
63
- export let color = "default"
64
- export let error = null
65
- export let hint = null
66
- export let disabled
67
-
68
- export let value = ""
69
-
70
- export let validate = () => true
71
- export let valid
72
-
73
- let input = null
74
- export const focus = () => input.focus()
75
-
76
- $: wind = {
77
- "@flat": flat,
78
- "@control": true,
79
- $color: color,
80
- ...$$restProps,
81
- }
82
-
83
- $: valid = validate(value)
84
- </script>
85
-
86
- <label use:wsx={wind} ws-error={error}>
87
- {#if label}
88
- <span ws-x="$text" ws-hint={hint}>{label}</span>
89
- {/if}
90
- <input {...$$restProps}
91
- type="password"
92
- {disabled}
93
- bind:value
94
- on:focus
95
- on:blur
96
- bind:this={input}
97
- />
98
-
99
- <slot name="start" />
100
- <slot name="end" />
101
- </label>
@@ -1,104 +0,0 @@
1
- <script>
2
- /*md
3
- [@] Components/Input/Search
4
-
5
- # Input.Search
6
-
7
- A multiline text input component.
8
-
9
- ## Base
10
- [Windstorm Labled Control](https://axel669.github.io/lib.windstorm/#components-labeled-control)
11
- using an input with type="search"
12
-
13
- ## Props
14
- All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
15
- are supported.
16
-
17
- - ### color `string`
18
- Sets `$color`
19
- - ### error `string`
20
- Shows an error message under the input
21
- - ### flat `bool`
22
- Sets `@flat`
23
- - ### hint `string`
24
- Shows a hint under the label. If no label is provided, the hint will not
25
- be shown either
26
- - ### label `string`
27
- The label for the input
28
- - ### transform `function`
29
- If given, it will transform the text value from the input and set the
30
- `tvalue` to the result
31
- - ### tvalue
32
- Value that can be bound to as the output of the transform function.
33
- Setting has no effect
34
- - ### validate `function`
35
- If given, will check the transformed output against a validation
36
- criteria and store the result in `valid`
37
- - ### valid `bool`
38
- Value that can be bound to as the output of the validation function.
39
- Setting has no effect
40
- - ### value `string`
41
- The value of the textarea, can be bound to
42
-
43
- ## Functions
44
- - focus()\\
45
- Focuses the input
46
-
47
- ## Usage
48
- ```js
49
- import { Input } from "@axel669/svelte-wind"
50
- ```svelte
51
- <Input.Search bind:value />
52
- <Input.Search bind:value color="primary" />
53
- <Input.Search bind:value label="Wat" hint="Blep"/>
54
- <Input.Search bind:value bind:tvalue transform={txt => txt.toLowerCase()} />
55
- <Input.Search bind:value bind:valid validate={txt => txt.indexOf("a") > 0} />
56
- ```
57
- */
58
-
59
- import wsx from "../wsx.mjs"
60
-
61
- export let flat = false
62
- export let label
63
- export let color = "default"
64
- export let error = null
65
- export let hint = null
66
- export let disabled
67
-
68
- export let value = ""
69
-
70
- export let transform = i => i
71
- export let tvalue
72
- export let validate = () => true
73
- export let valid
74
-
75
- let input = null
76
- export const focus = () => input.focus()
77
-
78
- $: wind = {
79
- "@flat": flat,
80
- "@control": true,
81
- $color: color,
82
- ...$$restProps,
83
- }
84
-
85
- $: tvalue = transform(value ?? "")
86
- $: valid = validate(tvalue)
87
- </script>
88
-
89
- <label use:wsx={wind} ws-error={error}>
90
- {#if label}
91
- <span ws-x="$text" ws-hint={hint}>{label}</span>
92
- {/if}
93
- <input {...$$restProps}
94
- {disabled}
95
- type="search"
96
- bind:value
97
- on:focus
98
- on:blur
99
- bind:this={input}
100
- />
101
-
102
- <slot name="start" />
103
- <slot name="end" />
104
- </label>
@@ -1,104 +0,0 @@
1
- <script>
2
- /*md
3
- [@] Components/Input/Text
4
-
5
- # Input.Text
6
-
7
- A multiline text input component.
8
-
9
- ## Base
10
- [Windstorm Labled Control](https://axel669.github.io/lib.windstorm/#components-labeled-control)
11
- using an input with type="text"
12
-
13
- ## Props
14
- All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
15
- are supported.
16
-
17
- - ### color `string`
18
- Sets `$color`
19
- - ### error `string`
20
- Shows an error message under the input
21
- - ### flat `bool`
22
- Sets `@flat`
23
- - ### hint `string`
24
- Shows a hint under the label. If no label is provided, the hint will not
25
- be shown either
26
- - ### label `string`
27
- The label for the input
28
- - ### transform `function`
29
- If given, it will transform the text value from the input and set the
30
- `tvalue` to the result
31
- - ### tvalue
32
- Value that can be bound to as the output of the transform function.
33
- Setting has no effect
34
- - ### validate `function`
35
- If given, will check the transformed output against a validation
36
- criteria and store the result in `valid`
37
- - ### valid `bool`
38
- Value that can be bound to as the output of the validation function.
39
- Setting has no effect
40
- - ### value `string`
41
- The value of the textarea, can be bound to
42
-
43
- ## Functions
44
- - focus()\\
45
- Focuses the input
46
-
47
- ## Usage
48
- ```js
49
- import { Input } from "@axel669/svelte-wind"
50
- ```svelte
51
- <Input.Text bind:value />
52
- <Input.Text bind:value color="primary" />
53
- <Input.Text bind:value label="Wat" hint="Blep"/>
54
- <Input.Text bind:value bind:tvalue transform={txt => txt.toLowerCase()} />
55
- <Input.Text bind:value bind:valid validate={txt => txt.indexOf("a") > 0} />
56
- ```
57
- */
58
-
59
- import wsx from "../wsx.mjs"
60
-
61
- export let flat = false
62
- export let label
63
- export let color = "default"
64
- export let error = null
65
- export let hint = null
66
- export let disabled
67
-
68
- export let value = ""
69
-
70
- export let transform = i => i
71
- export let tvalue
72
- export let validate = () => true
73
- export let valid
74
-
75
- let input = null
76
- export const focus = () => input.focus()
77
-
78
- $: wind = {
79
- "@flat": flat,
80
- "@control": true,
81
- $color: color,
82
- ...$$restProps,
83
- }
84
-
85
- $: tvalue = transform(value ?? "")
86
- $: valid = validate(tvalue)
87
- </script>
88
-
89
- <label use:wsx={wind} ws-error={error}>
90
- {#if label}
91
- <span ws-x="$text" ws-hint={hint}>{label}</span>
92
- {/if}
93
- <input {...$$restProps}
94
- type="text"
95
- {disabled}
96
- bind:value
97
- on:focus
98
- on:blur
99
- bind:this={input}
100
- />
101
-
102
- <slot name="start" />
103
- <slot name="end" />
104
- </label>