@reshape-biotech/design-system 0.0.54 → 1.1.2

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 (181) hide show
  1. package/dist/components/activity/Activity.stories.svelte +21 -8
  2. package/dist/components/activity/Activity.svelte +44 -6
  3. package/dist/components/activity/Activity.svelte.d.ts +1 -1
  4. package/dist/components/avatar/Avatar.stories.svelte +7 -17
  5. package/dist/components/avatar/Avatar.svelte +2 -2
  6. package/dist/components/avatar/Avatar.svelte.d.ts +2 -2
  7. package/dist/components/banner/Banner.stories.svelte +5 -5
  8. package/dist/components/banner/Banner.svelte +1 -1
  9. package/dist/components/button/Button.stories.svelte +54 -21
  10. package/dist/components/button/Button.svelte +58 -11
  11. package/dist/components/button/Button.svelte.d.ts +4 -3
  12. package/dist/components/card/Card.stories.svelte +130 -0
  13. package/dist/components/card/Card.stories.svelte.d.ts +19 -0
  14. package/dist/components/card/Card.svelte +25 -0
  15. package/dist/components/card/Card.svelte.d.ts +10 -0
  16. package/dist/components/card/index.d.ts +1 -0
  17. package/dist/components/card/index.js +1 -0
  18. package/dist/components/checkbox/Checkbox.stories.svelte +7 -15
  19. package/dist/components/checkbox/Checkbox.svelte +7 -7
  20. package/dist/components/checkbox/Checkbox.svelte.d.ts +3 -5
  21. package/dist/components/collapsible/Collapsible.stories.svelte +5 -4
  22. package/dist/components/combobox/Combobox.stories.svelte +7 -5
  23. package/dist/components/datepicker/DatePicker.stories.svelte +13 -18
  24. package/dist/components/datepicker/DatePicker.svelte +1 -0
  25. package/dist/components/divider/Divider.stories.svelte +1 -3
  26. package/dist/components/divider/Divider.svelte +8 -2
  27. package/dist/components/divider/Divider.svelte.d.ts +2 -0
  28. package/dist/components/drawer/Drawer.stories.svelte +3 -3
  29. package/dist/components/dropdown/Dropdown.stories.svelte +8 -8
  30. package/dist/components/empty-content/EmptyContent.stories.svelte +2 -2
  31. package/dist/components/graphs/bar-chart/BarChart.stories.svelte +81 -0
  32. package/dist/components/graphs/bar-chart/BarChart.stories.svelte.d.ts +19 -0
  33. package/dist/components/graphs/bar-chart/BarChart.svelte +136 -0
  34. package/dist/components/graphs/bar-chart/BarChart.svelte.d.ts +15 -0
  35. package/dist/components/graphs/bar-chart/StackedBarChart.stories.svelte +42 -0
  36. package/dist/components/graphs/bar-chart/StackedBarChart.stories.svelte.d.ts +19 -0
  37. package/dist/components/graphs/bar-chart/StackedBarChart.svelte +177 -0
  38. package/dist/components/graphs/bar-chart/StackedBarChart.svelte.d.ts +16 -0
  39. package/dist/components/graphs/chart/Chart.stories.svelte +30 -25
  40. package/dist/components/graphs/chart/Chart.svelte +104 -32
  41. package/dist/components/graphs/chart/Chart.svelte.d.ts +15 -5
  42. package/dist/components/graphs/index.d.ts +3 -0
  43. package/dist/components/graphs/index.js +3 -0
  44. package/dist/components/graphs/line/LineChart.stories.svelte +97 -17
  45. package/dist/components/graphs/line/LineChart.svelte +90 -51
  46. package/dist/components/graphs/line/LineChart.svelte.d.ts +6 -13
  47. package/dist/components/graphs/matrix/Matrix.stories.svelte +142 -0
  48. package/dist/components/graphs/matrix/Matrix.stories.svelte.d.ts +19 -0
  49. package/dist/components/graphs/matrix/Matrix.svelte +149 -0
  50. package/dist/components/graphs/matrix/Matrix.svelte.d.ts +24 -0
  51. package/dist/components/graphs/matrix/index.d.ts +3 -0
  52. package/dist/components/graphs/matrix/index.js +3 -0
  53. package/dist/components/graphs/multiline/MultiLineChart.stories.svelte +115 -28
  54. package/dist/components/graphs/multiline/MultiLineChart.svelte +187 -50
  55. package/dist/components/graphs/multiline/MultiLineChart.svelte.d.ts +9 -12
  56. package/dist/components/graphs/scatterplot/Scatterplot.stories.svelte +68 -41
  57. package/dist/components/graphs/scatterplot/Scatterplot.svelte +312 -45
  58. package/dist/components/graphs/scatterplot/Scatterplot.svelte.d.ts +23 -13
  59. package/dist/components/graphs/utils/tooltipFormatter.d.ts +10 -0
  60. package/dist/components/graphs/utils/tooltipFormatter.js +52 -0
  61. package/dist/components/icon-button/IconButton.stories.svelte +6 -6
  62. package/dist/components/icon-button/IconButton.svelte +50 -9
  63. package/dist/components/icon-button/IconButton.svelte.d.ts +3 -5
  64. package/dist/components/icons/AnalysisIcon.stories.svelte +15 -21
  65. package/dist/components/icons/AnalysisIcon.svelte +63 -44
  66. package/dist/components/icons/AnalysisIcon.svelte.d.ts +1 -0
  67. package/dist/components/icons/Icon.stories.svelte +4 -4
  68. package/dist/components/icons/Icon.svelte +1 -1
  69. package/dist/components/icons/PrincipalIcon.svelte +96 -0
  70. package/dist/components/icons/PrincipalIcon.svelte.d.ts +10 -0
  71. package/dist/components/icons/custom/Halo.svelte +14 -8
  72. package/dist/components/icons/custom/Halo.svelte.d.ts +7 -25
  73. package/dist/components/icons/custom/Well.svelte +14 -6
  74. package/dist/components/icons/custom/Well.svelte.d.ts +7 -25
  75. package/dist/components/icons/index.d.ts +3 -2
  76. package/dist/components/icons/index.js +34 -0
  77. package/dist/components/input/Input.stories.svelte +16 -22
  78. package/dist/components/input/Input.svelte +140 -134
  79. package/dist/components/input/Input.svelte.d.ts +12 -13
  80. package/dist/components/label/Label.stories.svelte +28 -0
  81. package/dist/components/label/Label.stories.svelte.d.ts +19 -0
  82. package/dist/components/label/Label.svelte +17 -0
  83. package/dist/components/label/Label.svelte.d.ts +9 -0
  84. package/dist/components/list/List.stories.svelte +3 -3
  85. package/dist/components/logo/Logo.stories.svelte +1 -1
  86. package/dist/components/manual-cfu-counter/ManualCFUCounter.stories.svelte +125 -0
  87. package/dist/components/manual-cfu-counter/ManualCFUCounter.stories.svelte.d.ts +3 -0
  88. package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte +577 -0
  89. package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte.d.ts +16 -0
  90. package/dist/components/manual-cfu-counter/index.d.ts +1 -0
  91. package/dist/components/manual-cfu-counter/index.js +1 -0
  92. package/dist/components/manual-cfu-counter/test/ManualCFUCounterTestWrapper.svelte +22 -0
  93. package/dist/components/manual-cfu-counter/test/ManualCFUCounterTestWrapper.svelte.d.ts +19 -0
  94. package/dist/components/markdown/Markdown.stories.svelte +1 -1
  95. package/dist/components/markdown/Markdown.svelte +1 -1
  96. package/dist/components/modal/Modal.stories.svelte +2 -2
  97. package/dist/components/modal/Modal.svelte +27 -22
  98. package/dist/components/modal/Modal.svelte.d.ts +4 -1
  99. package/dist/components/notification-popup/NotificationPopup.stories.svelte +1 -1
  100. package/dist/components/pill/Pill.stories.svelte +13 -0
  101. package/dist/components/pill/Pill.stories.svelte.d.ts +19 -0
  102. package/dist/components/progress-circle/ProgressCircle.stories.svelte +15 -0
  103. package/dist/components/progress-circle/ProgressCircle.stories.svelte.d.ts +19 -0
  104. package/dist/components/required-status-indicator/RequiredStatusIndicator.stories.svelte +28 -0
  105. package/dist/components/required-status-indicator/RequiredStatusIndicator.stories.svelte.d.ts +19 -0
  106. package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte +22 -0
  107. package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte.d.ts +8 -0
  108. package/dist/components/required-status-indicator/index.d.ts +1 -0
  109. package/dist/components/required-status-indicator/index.js +1 -0
  110. package/dist/components/segmented-control-buttons/SegmentedControlButtons.stories.svelte +3 -3
  111. package/dist/components/select/Select.stories.svelte +12 -12
  112. package/dist/components/select/Select.svelte +0 -2
  113. package/dist/components/select-new/Select.stories.svelte +219 -0
  114. package/dist/components/select-new/Select.stories.svelte.d.ts +19 -0
  115. package/dist/components/select-new/components/Group.svelte +24 -0
  116. package/dist/components/select-new/components/Group.svelte.d.ts +11 -0
  117. package/dist/components/select-new/components/MultiSelectTrigger.svelte +66 -0
  118. package/dist/components/select-new/components/MultiSelectTrigger.svelte.d.ts +17 -0
  119. package/dist/components/select-new/components/SelectContent.svelte +33 -0
  120. package/dist/components/select-new/components/SelectContent.svelte.d.ts +10 -0
  121. package/dist/components/select-new/components/SelectGroupHeading.svelte +19 -0
  122. package/dist/components/select-new/components/SelectGroupHeading.svelte.d.ts +9 -0
  123. package/dist/components/select-new/components/SelectItem.svelte +41 -0
  124. package/dist/components/select-new/components/SelectItem.svelte.d.ts +9 -0
  125. package/dist/components/select-new/components/SelectTrigger.svelte +48 -0
  126. package/dist/components/select-new/components/SelectTrigger.svelte.d.ts +12 -0
  127. package/dist/components/select-new/index.d.ts +10 -0
  128. package/dist/components/select-new/index.js +12 -0
  129. package/dist/components/select-new/types.d.ts +25 -0
  130. package/dist/components/select-new/types.js +1 -0
  131. package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte +92 -0
  132. package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte.d.ts +3 -0
  133. package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte +65 -0
  134. package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte.d.ts +3 -0
  135. package/dist/components/sjsf-wrappers/index.d.ts +2 -0
  136. package/dist/components/sjsf-wrappers/index.js +2 -0
  137. package/dist/components/sjsf-wrappers/sjsfCustomTheme.d.ts +2 -0
  138. package/dist/components/sjsf-wrappers/sjsfCustomTheme.js +8 -0
  139. package/dist/components/skeleton-loader/SkeletonLoader.stories.svelte +4 -4
  140. package/dist/components/slider/Slider.stories.svelte +4 -4
  141. package/dist/components/spinner/Spinner.stories.svelte +13 -0
  142. package/dist/components/spinner/Spinner.stories.svelte.d.ts +19 -0
  143. package/dist/components/stat-card/StatCard.stories.svelte +27 -19
  144. package/dist/components/stat-card/StatCard.svelte +100 -6
  145. package/dist/components/stat-card/StatCard.svelte.d.ts +3 -0
  146. package/dist/components/status-badge/StatusBadge.stories.svelte +6 -6
  147. package/dist/components/status-badge/StatusBadge.svelte +5 -3
  148. package/dist/components/stepper/Stepper.stories.svelte +243 -0
  149. package/dist/components/stepper/Stepper.stories.svelte.d.ts +19 -0
  150. package/dist/components/stepper/components/stepper-root.svelte +20 -0
  151. package/dist/components/stepper/components/stepper-root.svelte.d.ts +9 -0
  152. package/dist/components/stepper/components/stepper-step.svelte +100 -0
  153. package/dist/components/stepper/components/stepper-step.svelte.d.ts +11 -0
  154. package/dist/components/stepper/index.d.ts +15 -0
  155. package/dist/components/stepper/index.js +2 -0
  156. package/dist/components/table/Table.stories.svelte +1 -1
  157. package/dist/components/table/components/Td.svelte +3 -2
  158. package/dist/components/table/components/Td.svelte.d.ts +1 -0
  159. package/dist/components/table/components/Tr.svelte +3 -2
  160. package/dist/components/table/components/Tr.svelte.d.ts +1 -0
  161. package/dist/components/tabs/Tabs.stories.svelte +1 -1
  162. package/dist/components/tag/Tag.stories.svelte +9 -9
  163. package/dist/components/tag/Tag.svelte +0 -18
  164. package/dist/components/textarea/Textarea.stories.svelte +97 -0
  165. package/dist/components/textarea/Textarea.stories.svelte.d.ts +19 -0
  166. package/dist/components/textarea/Textarea.svelte +94 -0
  167. package/dist/components/textarea/Textarea.svelte.d.ts +17 -0
  168. package/dist/components/textarea/index.d.ts +1 -0
  169. package/dist/components/textarea/index.js +1 -0
  170. package/dist/components/toggle/Toggle.stories.svelte +1 -1
  171. package/dist/components/toggle/Toggle.svelte +3 -2
  172. package/dist/components/toggle/Toggle.svelte.d.ts +1 -0
  173. package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte +6 -6
  174. package/dist/components/tooltip/Tooltip.stories.svelte +6 -6
  175. package/dist/components/tooltip/Tooltip.svelte +1 -1
  176. package/dist/index.d.ts +7 -0
  177. package/dist/index.js +7 -0
  178. package/dist/tailwind.preset.d.ts +5 -0
  179. package/dist/tokens.d.ts +10 -0
  180. package/dist/tokens.js +6 -4
  181. package/package.json +1 -2
@@ -1,14 +1,19 @@
1
1
  import Aperture from 'phosphor-svelte/lib/Aperture';
2
2
  import ArrowFatLineRight from 'phosphor-svelte/lib/ArrowFatLineRight';
3
+ import ArrowCounterClockwise from 'phosphor-svelte/lib/ArrowCounterClockwise';
3
4
  import ArrowRight from 'phosphor-svelte/lib/ArrowRight';
4
5
  import ArrowUpRight from 'phosphor-svelte/lib/ArrowUpRight';
6
+ import ArrowUpLeft from 'phosphor-svelte/lib/ArrowUpLeft';
7
+ import ArrowUUpLeft from 'phosphor-svelte/lib/ArrowUUpLeft';
5
8
  import Barcode from 'phosphor-svelte/lib/Barcode';
6
9
  import Bell from 'phosphor-svelte/lib/Bell';
7
10
  import BookOpen from 'phosphor-svelte/lib/BookOpen';
8
11
  import BookOpenText from 'phosphor-svelte/lib/BookOpenText';
9
12
  import BowlingBall from 'phosphor-svelte/lib/BowlingBall';
13
+ import BugBeetle from 'phosphor-svelte/lib/BugBeetle';
10
14
  import Calendar from 'phosphor-svelte/lib/Calendar';
11
15
  import CalendarBlank from 'phosphor-svelte/lib/CalendarBlank';
16
+ import Camera from 'phosphor-svelte/lib/CameraSlash';
12
17
  import CameraSlash from 'phosphor-svelte/lib/CameraSlash';
13
18
  import CaretDown from 'phosphor-svelte/lib/CaretDown';
14
19
  import CaretLeft from 'phosphor-svelte/lib/CaretLeft';
@@ -30,6 +35,7 @@ import Copy from 'phosphor-svelte/lib/Copy';
30
35
  import Crop from 'phosphor-svelte/lib/Crop';
31
36
  import Cube from 'phosphor-svelte/lib/Cube';
32
37
  import Database from 'phosphor-svelte/lib/Database';
38
+ import Dna from 'phosphor-svelte/lib/Dna';
33
39
  import DotsThree from 'phosphor-svelte/lib/DotsThree';
34
40
  import DotsThreeOutlineVertical from 'phosphor-svelte/lib/DotsThreeOutlineVertical';
35
41
  import DownloadSimple from 'phosphor-svelte/lib/DownloadSimple';
@@ -53,13 +59,18 @@ import House from 'phosphor-svelte/lib/House';
53
59
  import ImageSquare from 'phosphor-svelte/lib/ImageSquare';
54
60
  import ImagesSquare from 'phosphor-svelte/lib/ImagesSquare';
55
61
  import Info from 'phosphor-svelte/lib/Info';
62
+ import Link from 'phosphor-svelte/lib/Link';
56
63
  import Lock from 'phosphor-svelte/lib/Lock';
57
64
  import LineSegments from 'phosphor-svelte/lib/LineSegments';
58
65
  import List from 'phosphor-svelte/lib/List';
66
+ import ListMagnifyingGlass from 'phosphor-svelte/lib/ListMagnifyingGlass';
59
67
  import MagnifyingGlass from 'phosphor-svelte/lib/MagnifyingGlass';
60
68
  import MegaphoneSimple from 'phosphor-svelte/lib/MegaphoneSimple';
69
+ import MicrosoftExcelLogo from 'phosphor-svelte/lib/MicrosoftExcelLogo';
61
70
  import Moon from 'phosphor-svelte/lib/Moon';
71
+ import Minus from 'phosphor-svelte/lib/Minus';
62
72
  import Pause from 'phosphor-svelte/lib/Pause';
73
+ import Palette from 'phosphor-svelte/lib/Palette';
63
74
  import Pencil from 'phosphor-svelte/lib/Pencil';
64
75
  import PencilSimple from 'phosphor-svelte/lib/PencilSimple';
65
76
  import Percent from 'phosphor-svelte/lib/Percent';
@@ -69,11 +80,15 @@ import Play from 'phosphor-svelte/lib/Play';
69
80
  import Plus from 'phosphor-svelte/lib/Plus';
70
81
  import PlusMinus from 'phosphor-svelte/lib/PlusMinus';
71
82
  import Question from 'phosphor-svelte/lib/Question';
83
+ import SealCheck from 'phosphor-svelte/lib/SealCheck';
72
84
  import RadioButton from 'phosphor-svelte/lib/RadioButton';
73
85
  import SealQuestion from 'phosphor-svelte/lib/SealQuestion';
86
+ import SealWarning from 'phosphor-svelte/lib/SealWarning';
74
87
  import SelectionAll from 'phosphor-svelte/lib/SelectionAll';
75
88
  import Share from 'phosphor-svelte/lib/Share';
76
89
  import SidebarSimple from 'phosphor-svelte/lib/SidebarSimple';
90
+ import SignIn from 'phosphor-svelte/lib/SignIn';
91
+ import SignOut from 'phosphor-svelte/lib/SignOut';
77
92
  import SkipBack from 'phosphor-svelte/lib/SkipBack';
78
93
  import SkipForward from 'phosphor-svelte/lib/SkipForward';
79
94
  import SortAscending from 'phosphor-svelte/lib/SortAscending';
@@ -86,9 +101,11 @@ import StopCircle from 'phosphor-svelte/lib/StopCircle';
86
101
  import Sun from 'phosphor-svelte/lib/Sun';
87
102
  import Table from 'phosphor-svelte/lib/Table';
88
103
  import Tag from 'phosphor-svelte/lib/Tag';
104
+ import Target from 'phosphor-svelte/lib/Target';
89
105
  import TestTube from 'phosphor-svelte/lib/TestTube';
90
106
  import Trash from 'phosphor-svelte/lib/Trash';
91
107
  import TrashSimple from 'phosphor-svelte/lib/TrashSimple';
108
+ import TreeStructure from 'phosphor-svelte/lib/TreeStructure';
92
109
  import UserCircle from 'phosphor-svelte/lib/UserCircle';
93
110
  import UserPlus from 'phosphor-svelte/lib/UserPlus';
94
111
  import Video from 'phosphor-svelte/lib/Video';
@@ -99,15 +116,20 @@ import X from 'phosphor-svelte/lib/X';
99
116
  export const iconMap = {
100
117
  Aperture,
101
118
  ArrowFatLineRight,
119
+ ArrowCounterClockwise,
102
120
  ArrowRight,
103
121
  ArrowUpRight,
122
+ ArrowUpLeft,
123
+ ArrowUUpLeft,
104
124
  Barcode,
105
125
  Bell,
106
126
  BookOpen,
107
127
  BookOpenText,
108
128
  BowlingBall,
129
+ BugBeetle,
109
130
  Calendar,
110
131
  CalendarBlank,
132
+ Camera,
111
133
  CameraSlash,
112
134
  CaretDown,
113
135
  CaretLeft,
@@ -129,6 +151,7 @@ export const iconMap = {
129
151
  Crop,
130
152
  Cube,
131
153
  Database,
154
+ Dna,
132
155
  DotsThree,
133
156
  DotsThreeOutlineVertical,
134
157
  DownloadSimple,
@@ -155,9 +178,14 @@ export const iconMap = {
155
178
  Lock,
156
179
  LineSegments,
157
180
  List,
181
+ Link,
182
+ ListMagnifyingGlass,
158
183
  MagnifyingGlass,
159
184
  MegaphoneSimple,
185
+ MicrosoftExcelLogo,
160
186
  Moon,
187
+ Minus,
188
+ Palette,
161
189
  Pause,
162
190
  Pencil,
163
191
  PencilSimple,
@@ -169,10 +197,14 @@ export const iconMap = {
169
197
  PlusMinus,
170
198
  RadioButton,
171
199
  Question,
200
+ SealCheck,
172
201
  SealQuestion,
202
+ SealWarning,
173
203
  SelectionAll,
174
204
  Share,
175
205
  SidebarSimple,
206
+ SignIn,
207
+ SignOut,
176
208
  SkipBack,
177
209
  SkipForward,
178
210
  SortAscending,
@@ -185,9 +217,11 @@ export const iconMap = {
185
217
  Sun,
186
218
  Table,
187
219
  Tag,
220
+ Target,
188
221
  TestTube,
189
222
  Trash,
190
223
  TrashSimple,
224
+ TreeStructure,
191
225
  UserCircle,
192
226
  UserPlus,
193
227
  Video,
@@ -22,33 +22,25 @@
22
22
  let textareaValue = '';
23
23
  </script>
24
24
 
25
- <Story name="Base">
26
- <Input bind:value autofocus />
27
- </Story>
28
- <Story name="XSmall">
29
- <Input bind:value autofocus size="xs" />
30
- </Story>
31
- <Story name="Small">
32
- <Input bind:value autofocus size="sm" />
33
- </Story>
25
+ <Story name="Base" args={{ autofocus: true, value: 'Hello' }} />
26
+
27
+ <Story name="XSmall" args={{ size: 'xs' }} />
34
28
 
35
- <Story name="Login">
29
+ <Story name="Small" args={{ size: 'sm' }} />
30
+
31
+ <Story name="Login" asChild>
36
32
  <div class="flex flex-col gap-2">
37
33
  <Input bind:value={email} label="Email" type="text" required id="email-select" autofocus />
38
34
  <Input bind:value={password} label="Password" id="password-select" type="password" required />
39
35
  </div>
40
36
  </Story>
41
37
 
42
- <Story name="Textarea">
43
- <Input
44
- bind:value={textareaValue}
45
- label="Description"
46
- type="textarea"
47
- placeholder="Add a description..."
48
- />
49
- </Story>
38
+ <Story
39
+ name="Textarea"
40
+ args={{ label: 'Description', type: 'textarea', placeholder: 'Add a description...' }}
41
+ />
50
42
 
51
- <Story name="Prefix">
43
+ <Story name="Prefix" asChild>
52
44
  <Input value="Bob">
53
45
  {#snippet prefix()}
54
46
  <div>Mr.</div>
@@ -56,7 +48,7 @@
56
48
  </Input>
57
49
  </Story>
58
50
 
59
- <Story name="Suffix">
51
+ <Story name="Suffix" asChild>
60
52
  <Input value="30">
61
53
  {#snippet suffix()}
62
54
  <div>± 1°C</div>
@@ -64,7 +56,7 @@
64
56
  </Input>
65
57
  </Story>
66
58
 
67
- <Story name="Prefix & Suffix">
59
+ <Story name="Prefix & Suffix" asChild>
68
60
  <Input value="9001">
69
61
  {#snippet prefix()}
70
62
  <div>$</div>
@@ -75,7 +67,7 @@
75
67
  </Input>
76
68
  </Story>
77
69
 
78
- <Story name="Validation">
70
+ <Story name="Validation" asChild>
79
71
  <Input value="Focus me, then click away" validator={(val) => val.toString().length < 10}>
80
72
  {#snippet prefix({ valid })}
81
73
  <div>
@@ -91,3 +83,5 @@
91
83
  {/snippet}
92
84
  </Input>
93
85
  </Story>
86
+
87
+ <Story name="Clearable" args={{ clearable: true, value: 'Focus me, then click away' }} />
@@ -1,204 +1,210 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
+ import { IconButton } from '../icon-button';
4
+ import { Icon } from '../icons';
5
+ import type { HTMLInputAttributes } from 'svelte/elements';
3
6
 
4
- interface Props {
7
+ interface InputProps extends Omit<HTMLInputAttributes, 'size' | 'prefix' | 'suffix'> {
5
8
  label?: string | null;
6
- value: string | number;
7
- type?: 'text' | 'password' | 'textarea' | 'number';
8
- name?: string;
9
- required?: boolean;
10
- autofocus?: boolean;
11
- placeholder?: string;
12
9
  id?: string | undefined;
13
10
  validator?: (a: string | number) => boolean;
14
- onBlur?: (e: Event) => void;
15
- onkeydown?: (e: KeyboardEvent) => void;
16
11
  prefix?: Snippet<[any]>;
17
12
  suffix?: Snippet;
18
13
  error?: Snippet;
19
- input?: HTMLInputElement | HTMLTextAreaElement;
20
- maxlength?: number | null;
14
+ input?: HTMLInputElement;
21
15
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'dynamic';
22
- readonly?: boolean;
16
+ transparent?: boolean;
17
+ clearable?: boolean;
18
+ onclear?: () => void;
19
+ class?: string;
20
+ oninput?: (event: Event) => void;
21
+ onblur?: (event: FocusEvent) => void;
23
22
  }
24
23
 
25
24
  let {
26
25
  label = null,
27
26
  value = $bindable(),
28
27
  type = 'text',
29
- required = false,
30
- autofocus = false,
31
- placeholder = '',
32
- id = undefined,
33
- name,
34
28
  validator = (_) => {
35
29
  return true;
36
30
  },
37
- onBlur = () => {},
38
- onkeydown = () => {},
39
31
  prefix,
40
32
  suffix,
41
33
  error,
42
34
  input = $bindable(),
43
- maxlength = null,
44
35
  size = 'md',
45
- readonly = false
46
- }: Props = $props();
36
+ transparent = false,
37
+ clearable = false,
38
+ onclear = () => {},
39
+ class: className,
40
+ oninput,
41
+ onblur,
42
+ ...rest
43
+ }: InputProps = $props();
44
+
45
+ export function focus() {
46
+ input?.focus();
47
+ }
47
48
 
48
49
  let valid = $state(true);
49
50
 
50
- const inputId = Math.random().toString(36).substring(7); // used for A11y
51
-
51
+ const inputId = crypto.randomUUID();
52
+ const id = $derived(rest.id ?? inputId);
52
53
  function handleInput(event: Event) {
53
- if (readonly) return;
54
- const target = event.target as HTMLTextAreaElement | HTMLInputElement;
54
+ if (rest.readonly) return;
55
+ const target = event.target as HTMLInputElement;
55
56
  value = target.value;
56
-
57
- if (type === 'textarea') {
58
- autoResizeTextarea(target as HTMLTextAreaElement);
59
- }
60
- }
61
- function autoResizeTextarea(textarea: HTMLTextAreaElement) {
62
- // Set a maximum height for the textarea (e.g., 200px)
63
- const maxHeight = 200;
64
-
65
- // Reset height to auto to get the correct scrollHeight
66
- textarea.style.height = 'auto';
67
-
68
- // If scrollHeight is less than maxHeight, set height to scrollHeight
69
- // Otherwise, set height to maxHeight and enable scrolling
70
- if (textarea.scrollHeight < maxHeight) {
71
- textarea.style.height = `${textarea.scrollHeight}px`;
72
- textarea.style.overflowY = 'hidden';
73
- } else {
74
- textarea.style.height = `${maxHeight}px`;
75
- textarea.style.overflowY = 'auto';
76
- }
57
+ oninput?.(event);
77
58
  }
78
59
 
79
- function handleBlur(event: Event) {
60
+ function handleBlur(event: FocusEvent & { currentTarget: EventTarget & HTMLInputElement }) {
80
61
  valid = validator(value);
81
- onBlur(event);
62
+ onblur?.(event);
82
63
  }
83
64
  </script>
84
65
 
85
66
  <div class="w-full">
86
67
  {#if label}
87
- <label for={id ?? inputId} class="block px-1 py-2 text-sm text-secondary">{label}</label>
68
+ <label for={id ?? inputId} class="block px-1 py-2 text-sm text-secondary">
69
+ {label}
70
+ {#if rest.required}
71
+ <span class="ml-0.5 text-danger">*</span>
72
+ {/if}
73
+ </label>
88
74
  {/if}
75
+
89
76
  <div
90
77
  class="flex w-full items-center gap-1 rounded-lg border border-input bg-surface shadow-input size-{size}"
78
+ class:border-transparent={transparent}
79
+ class:shadow-input={!transparent}
91
80
  class:!border-error={!valid}
92
81
  >
93
- {#if type === 'textarea'}
94
- <textarea
95
- id={id ?? inputId}
96
- rows="3"
97
- class:has-text={value}
98
- class:has-placeholder={placeholder}
99
- aria-label={label}
100
- oninput={handleInput}
101
- onblur={handleBlur}
102
- {onkeydown}
103
- bind:this={input}
104
- {value}
105
- {required}
106
- {autofocus}
107
- {placeholder}
108
- {maxlength}
109
- {name}
110
- {readonly}
111
- ></textarea>
112
- {:else}
113
- <div class="whitespace-nowrap text-secondary">
114
- {@render prefix?.({ valid })}
115
- </div>
116
- <input
117
- id={id ?? inputId}
118
- class="inline leading-none"
119
- class:has-text={value}
120
- class:has-placeholder={placeholder}
121
- aria-label={label}
122
- {type}
123
- {name}
124
- {required}
125
- oninput={handleInput}
126
- onblur={handleBlur}
127
- {onkeydown}
128
- bind:this={input}
129
- {value}
130
- {autofocus}
131
- {placeholder}
132
- {maxlength}
133
- {readonly}
134
- />
135
- <div class="whitespace-nowrap text-secondary">
136
- {@render suffix?.()}
137
- </div>
82
+ <div class="whitespace-nowrap text-secondary">
83
+ {@render prefix?.({ valid })}
84
+ </div>
85
+ <input
86
+ {id}
87
+ class="inline leading-none"
88
+ class:has-text={value}
89
+ class:has-placeholder={rest.placeholder}
90
+ aria-label={label}
91
+ {type}
92
+ oninput={handleInput}
93
+ onblur={handleBlur}
94
+ bind:this={input}
95
+ bind:value
96
+ {...rest}
97
+ />
98
+ <div class="whitespace-nowrap text-secondary">
99
+ {@render suffix?.()}
100
+ </div>
101
+
102
+ {#if clearable && value}
103
+ <IconButton
104
+ variant="transparent"
105
+ size="xs"
106
+ onclick={() => {
107
+ value = '';
108
+ input?.focus();
109
+ onclear();
110
+ }}
111
+ >
112
+ <Icon iconName="X" />
113
+ </IconButton>
138
114
  {/if}
139
115
  </div>
140
- {#if !valid}
141
- {@render error?.()}
142
- {/if}
116
+
117
+ {@render error?.()}
143
118
  </div>
144
119
 
145
120
  <style>
146
- input,
147
- textarea {
148
- width: 100%;
149
- outline: 2px solid transparent;
150
- outline-offset: 2px;
151
- /* Remove the resize-none class to allow scrolling */
152
- resize: none
121
+ input {
122
+
123
+ width: 100%;
124
+
125
+ resize: none;
126
+
127
+ outline: 2px solid transparent;
128
+
129
+ outline-offset: 2px
153
130
  }
154
131
 
155
132
  div:not(:focus-within):hover {
156
- border-color: #5750ee40
133
+
134
+ border-color: #5750ee40
157
135
  }
158
136
 
159
137
  div:focus-within {
160
- --tw-border-opacity: 1;
161
- border-color: rgb(87 80 238 / var(--tw-border-opacity, 1))
138
+
139
+ --tw-border-opacity: 1;
140
+
141
+ border-color: rgb(87 80 238 / var(--tw-border-opacity, 1))
162
142
  }
163
143
 
164
144
  .size-xs {
165
- height: 1.5rem;
166
- padding: 0.5rem;
167
- font-size: 0.75rem;
168
- line-height: 1rem
145
+
146
+ height: 1.5rem;
147
+
148
+ padding: 0.5rem;
149
+
150
+ font-size: 0.75rem;
151
+
152
+ line-height: 1rem
169
153
  }
170
154
 
171
155
  .size-sm {
172
- height: 2rem;
173
- padding-left: 0.75rem;
174
- padding-right: 0.75rem;
175
- padding-top: 0.5rem;
176
- padding-bottom: 0.5rem
156
+
157
+ height: 2rem;
158
+
159
+ padding-left: 0.75rem;
160
+
161
+ padding-right: 0.75rem;
162
+
163
+ padding-top: 0.5rem;
164
+
165
+ padding-bottom: 0.5rem
177
166
  }
178
167
 
179
168
  .size-md {
180
- height: 2.5rem;
181
- padding-left: 0.75rem;
182
- padding-right: 0.75rem;
183
- padding-top: 0.5rem;
184
- padding-bottom: 0.5rem
169
+
170
+ height: 2.5rem;
171
+
172
+ padding-left: 0.75rem;
173
+
174
+ padding-right: 0.75rem;
175
+
176
+ padding-top: 0.5rem;
177
+
178
+ padding-bottom: 0.5rem
185
179
  }
186
180
 
187
181
  .size-lg {
188
- height: 3rem;
189
- padding-left: 0.75rem;
190
- padding-right: 0.75rem;
191
- padding-top: 0.75rem;
192
- padding-bottom: 0.75rem;
193
- font-size: 1rem;
194
- line-height: 1.5rem
182
+
183
+ height: 3rem;
184
+
185
+ padding-left: 0.75rem;
186
+
187
+ padding-right: 0.75rem;
188
+
189
+ padding-top: 0.75rem;
190
+
191
+ padding-bottom: 0.75rem;
192
+
193
+ font-size: 1rem;
194
+
195
+ line-height: 1.5rem
195
196
  }
196
197
 
197
198
  .size-dynamic {
198
- height: auto;
199
- padding-left: 0.75rem;
200
- padding-right: 0.75rem;
201
- padding-top: 0.5rem;
202
- padding-bottom: 0.5rem
199
+
200
+ height: auto;
201
+
202
+ padding-left: 0.75rem;
203
+
204
+ padding-right: 0.75rem;
205
+
206
+ padding-top: 0.5rem;
207
+
208
+ padding-bottom: 0.5rem
203
209
  }
204
210
  </style>
@@ -1,24 +1,23 @@
1
1
  import type { Snippet } from 'svelte';
2
- interface Props {
2
+ import type { HTMLInputAttributes } from 'svelte/elements';
3
+ interface InputProps extends Omit<HTMLInputAttributes, 'size' | 'prefix' | 'suffix'> {
3
4
  label?: string | null;
4
- value: string | number;
5
- type?: 'text' | 'password' | 'textarea' | 'number';
6
- name?: string;
7
- required?: boolean;
8
- autofocus?: boolean;
9
- placeholder?: string;
10
5
  id?: string | undefined;
11
6
  validator?: (a: string | number) => boolean;
12
- onBlur?: (e: Event) => void;
13
- onkeydown?: (e: KeyboardEvent) => void;
14
7
  prefix?: Snippet<[any]>;
15
8
  suffix?: Snippet;
16
9
  error?: Snippet;
17
- input?: HTMLInputElement | HTMLTextAreaElement;
18
- maxlength?: number | null;
10
+ input?: HTMLInputElement;
19
11
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'dynamic';
20
- readonly?: boolean;
12
+ transparent?: boolean;
13
+ clearable?: boolean;
14
+ onclear?: () => void;
15
+ class?: string;
16
+ oninput?: (event: Event) => void;
17
+ onblur?: (event: FocusEvent) => void;
21
18
  }
22
- declare const Input: import("svelte").Component<Props, {}, "value" | "input">;
19
+ declare const Input: import("svelte").Component<InputProps, {
20
+ focus: () => void;
21
+ }, "value" | "input">;
23
22
  type Input = ReturnType<typeof Input>;
24
23
  export default Input;
@@ -0,0 +1,28 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Label from './Label.svelte';
4
+
5
+ const { Story } = defineMeta({
6
+ title: 'Design System/Label',
7
+ component: Label,
8
+ argTypes: {
9
+ text: { control: 'text' },
10
+ forId: { control: 'text' },
11
+ required: { control: 'boolean' },
12
+ class: { control: 'text' }
13
+ }
14
+ });
15
+ </script>
16
+
17
+ <Story name="Default" args={{ text: 'Email Address', forId: 'email' }} />
18
+
19
+ <Story name="Required" args={{ text: 'Password', forId: 'password', required: true }} />
20
+
21
+ <Story
22
+ name="With Custom Class"
23
+ args={{
24
+ text: 'Custom Styled Label',
25
+ forId: 'custom',
26
+ class: 'text-lg text-primary font-bold'
27
+ }}
28
+ />
@@ -0,0 +1,19 @@
1
+ import Label from './Label.svelte';
2
+ 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> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const Label: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
16
+ [evt: string]: CustomEvent<any>;
17
+ }, {}, {}, string>;
18
+ type Label = InstanceType<typeof Label>;
19
+ export default Label;
@@ -0,0 +1,17 @@
1
+ <script lang="ts">
2
+ interface Props {
3
+ forId: string;
4
+ text: string;
5
+ required?: boolean;
6
+ class?: string;
7
+ }
8
+
9
+ const { forId, text, required = false, class: className }: Props = $props();
10
+ </script>
11
+
12
+ <label for={forId} class="block text-sm text-secondary {className ?? ''}">
13
+ {text}
14
+ {#if required}
15
+ <span class="ml-0.5 text-danger">*</span>
16
+ {/if}
17
+ </label>
@@ -0,0 +1,9 @@
1
+ interface Props {
2
+ forId: string;
3
+ text: string;
4
+ required?: boolean;
5
+ class?: string;
6
+ }
7
+ declare const Label: import("svelte").Component<Props, {}, "">;
8
+ type Label = ReturnType<typeof Label>;
9
+ export default Label;