@charcoal-ui/react 3.6.0 → 3.8.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 (127) hide show
  1. package/dist/_lib/compat.d.ts +1 -0
  2. package/dist/_lib/compat.d.ts.map +1 -1
  3. package/dist/components/Button/StyledButton.d.ts +13 -0
  4. package/dist/components/Button/StyledButton.d.ts.map +1 -0
  5. package/dist/components/Button/index.d.ts +3 -2
  6. package/dist/components/Button/index.d.ts.map +1 -1
  7. package/dist/components/Button/index.story.d.ts +16 -32
  8. package/dist/components/Button/index.story.d.ts.map +1 -1
  9. package/dist/components/Button/lib/variantToBackground.d.ts +3 -0
  10. package/dist/components/Button/lib/variantToBackground.d.ts.map +1 -0
  11. package/dist/components/Button/lib/variantToFont.d.ts +3 -0
  12. package/dist/components/Button/lib/variantToFont.d.ts.map +1 -0
  13. package/dist/components/Checkbox/index.d.ts.map +1 -1
  14. package/dist/components/Checkbox/index.story.d.ts +6 -16
  15. package/dist/components/Checkbox/index.story.d.ts.map +1 -1
  16. package/dist/components/Clickable/index.story.d.ts +4 -6
  17. package/dist/components/Clickable/index.story.d.ts.map +1 -1
  18. package/dist/components/DropdownSelector/ListItem/index.story.d.ts +7 -7
  19. package/dist/components/DropdownSelector/ListItem/index.story.d.ts.map +1 -1
  20. package/dist/components/DropdownSelector/MenuList/index.story.d.ts +6 -9
  21. package/dist/components/DropdownSelector/MenuList/index.story.d.ts.map +1 -1
  22. package/dist/components/DropdownSelector/Popover/index.story.d.ts +3 -7
  23. package/dist/components/DropdownSelector/Popover/index.story.d.ts.map +1 -1
  24. package/dist/components/DropdownSelector/index.d.ts.map +1 -1
  25. package/dist/components/DropdownSelector/index.story.d.ts +9 -11
  26. package/dist/components/DropdownSelector/index.story.d.ts.map +1 -1
  27. package/dist/components/Icon/index.story.d.ts +4 -26
  28. package/dist/components/Icon/index.story.d.ts.map +1 -1
  29. package/dist/components/IconButton/index.d.ts +1 -0
  30. package/dist/components/IconButton/index.d.ts.map +1 -1
  31. package/dist/components/IconButton/index.story.d.ts +6 -25
  32. package/dist/components/IconButton/index.story.d.ts.map +1 -1
  33. package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts +8 -0
  34. package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts.map +1 -0
  35. package/dist/components/LoadingSpinner/index.d.ts +2 -2
  36. package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
  37. package/dist/components/LoadingSpinner/index.story.d.ts +4 -7
  38. package/dist/components/LoadingSpinner/index.story.d.ts.map +1 -1
  39. package/dist/components/Modal/index.story.d.ts +16 -41
  40. package/dist/components/Modal/index.story.d.ts.map +1 -1
  41. package/dist/components/MultiSelect/index.d.ts.map +1 -1
  42. package/dist/components/Radio/index.d.ts +0 -2
  43. package/dist/components/Radio/index.d.ts.map +1 -1
  44. package/dist/components/Radio/index.story.d.ts +12 -23
  45. package/dist/components/Radio/index.story.d.ts.map +1 -1
  46. package/dist/components/SegmentedControl/RadioGroupContext.d.ts +1 -1
  47. package/dist/components/SegmentedControl/RadioGroupContext.d.ts.map +1 -1
  48. package/dist/components/SegmentedControl/index.story.d.ts +5 -8
  49. package/dist/components/SegmentedControl/index.story.d.ts.map +1 -1
  50. package/dist/components/Switch/index.d.ts.map +1 -1
  51. package/dist/components/Switch/index.story.d.ts +7 -12
  52. package/dist/components/Switch/index.story.d.ts.map +1 -1
  53. package/dist/components/TagItem/index.d.ts.map +1 -1
  54. package/dist/components/TagItem/index.story.d.ts +14 -24
  55. package/dist/components/TagItem/index.story.d.ts.map +1 -1
  56. package/dist/components/TextArea/TextArea.story.d.ts +7 -25
  57. package/dist/components/TextArea/TextArea.story.d.ts.map +1 -1
  58. package/dist/components/TextField/TextField.story.d.ts +13 -20
  59. package/dist/components/TextField/TextField.story.d.ts.map +1 -1
  60. package/dist/components/TextField/index.d.ts.map +1 -1
  61. package/dist/index.cjs.js +418 -206
  62. package/dist/index.cjs.js.map +1 -1
  63. package/dist/index.esm.js +387 -175
  64. package/dist/index.esm.js.map +1 -1
  65. package/dist/styled.d.ts +4 -4
  66. package/package.json +17 -20
  67. package/src/_lib/compat.ts +8 -0
  68. package/src/components/Button/StyledButton.tsx +71 -0
  69. package/src/components/Button/__snapshots__/index.story.storyshot +314 -118
  70. package/src/components/Button/index.story.tsx +141 -138
  71. package/src/components/Button/index.tsx +15 -104
  72. package/src/components/Button/lib/variantToBackground.tsx +19 -0
  73. package/src/components/Button/lib/variantToFont.tsx +19 -0
  74. package/src/components/Checkbox/__snapshots__/index.story.storyshot +12 -27
  75. package/src/components/Checkbox/index.story.tsx +82 -88
  76. package/src/components/Checkbox/index.tsx +2 -12
  77. package/src/components/Clickable/__snapshots__/index.story.storyshot +2 -2
  78. package/src/components/Clickable/index.story.tsx +12 -9
  79. package/src/components/DropdownSelector/DropdownMenuItem.tsx +1 -14
  80. package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +42 -37
  81. package/src/components/DropdownSelector/ListItem/index.story.tsx +8 -4
  82. package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +38 -38
  83. package/src/components/DropdownSelector/MenuList/index.story.tsx +33 -27
  84. package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +11 -5
  85. package/src/components/DropdownSelector/Popover/index.story.tsx +6 -6
  86. package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +313 -151
  87. package/src/components/DropdownSelector/index.story.tsx +207 -171
  88. package/src/components/DropdownSelector/index.tsx +22 -22
  89. package/src/components/Icon/__snapshots__/index.story.storyshot +1 -1
  90. package/src/components/Icon/index.story.tsx +8 -12
  91. package/src/components/IconButton/__snapshots__/index.story.storyshot +130 -13
  92. package/src/components/IconButton/index.story.tsx +30 -23
  93. package/src/components/IconButton/index.tsx +32 -20
  94. package/src/components/LoadingSpinner/LoadingSpinnerIcon.story.tsx +12 -0
  95. package/src/components/LoadingSpinner/__snapshots__/LoadingSpinnerIcon.story.storyshot +28 -0
  96. package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +1 -35
  97. package/src/components/LoadingSpinner/index.story.tsx +11 -54
  98. package/src/components/LoadingSpinner/index.tsx +1 -1
  99. package/src/components/Modal/__snapshots__/index.story.storyshot +231 -194
  100. package/src/components/Modal/index.story.tsx +139 -133
  101. package/src/components/MultiSelect/__snapshots__/index.story.storyshot +56 -4
  102. package/src/components/MultiSelect/index.tsx +3 -0
  103. package/src/components/Radio/__snapshots__/index.story.storyshot +981 -121
  104. package/src/components/Radio/index.story.tsx +128 -63
  105. package/src/components/Radio/index.tsx +10 -16
  106. package/src/components/SegmentedControl/RadioGroupContext.tsx +1 -1
  107. package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +11 -11
  108. package/src/components/SegmentedControl/index.story.tsx +24 -29
  109. package/src/components/SegmentedControl/index.tsx +1 -1
  110. package/src/components/Switch/__snapshots__/index.story.storyshot +184 -26
  111. package/src/components/Switch/index.story.tsx +72 -48
  112. package/src/components/Switch/index.tsx +2 -7
  113. package/src/components/TagItem/__snapshots__/index.story.storyshot +72 -33
  114. package/src/components/TagItem/index.story.tsx +154 -159
  115. package/src/components/TagItem/index.tsx +2 -6
  116. package/src/components/TextArea/TextArea.story.tsx +29 -32
  117. package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +139 -83
  118. package/src/components/TextField/TextField.story.tsx +67 -66
  119. package/src/components/TextField/__snapshots__/TextField.story.storyshot +198 -162
  120. package/src/components/TextField/index.tsx +0 -7
  121. package/dist/components/Checkbox/performance.test.d.ts +0 -4
  122. package/dist/components/Checkbox/performance.test.d.ts.map +0 -1
  123. package/dist/components/Checkbox/snapshot.test.d.ts +0 -2
  124. package/dist/components/Checkbox/snapshot.test.d.ts.map +0 -1
  125. package/src/components/Checkbox/__snapshots__/snapshot.test.tsx.snap +0 -1093
  126. package/src/components/Checkbox/performance.test.tsx +0 -30
  127. package/src/components/Checkbox/snapshot.test.tsx +0 -66
@@ -1,7 +1,45 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Storyshots TextArea Auto Height 1`] = `
4
- .c3 {
3
+ exports[`Storybook Tests TextArea AutoHeight 1`] = `
4
+ .c7 {
5
+ cursor: pointer;
6
+ -webkit-appearance: none;
7
+ -moz-appearance: none;
8
+ appearance: none;
9
+ background: transparent;
10
+ padding: 0;
11
+ border-style: none;
12
+ outline: none;
13
+ color: inherit;
14
+ text-rendering: inherit;
15
+ -webkit-letter-spacing: inherit;
16
+ -moz-letter-spacing: inherit;
17
+ -ms-letter-spacing: inherit;
18
+ letter-spacing: inherit;
19
+ word-spacing: inherit;
20
+ -webkit-text-decoration: none;
21
+ text-decoration: none;
22
+ font: inherit;
23
+ margin: 0;
24
+ overflow: visible;
25
+ text-transform: none;
26
+ }
27
+
28
+ .c7:disabled,
29
+ .c7[aria-disabled]:not([aria-disabled=false]) {
30
+ cursor: default;
31
+ }
32
+
33
+ .c7:focus {
34
+ outline: none;
35
+ }
36
+
37
+ .c7::-moz-focus-inner {
38
+ border-style: none;
39
+ padding: 0;
40
+ }
41
+
42
+ .c4 {
5
43
  font-size: 14px;
6
44
  line-height: 22px;
7
45
  font-weight: bold;
@@ -9,7 +47,7 @@ exports[`Storyshots TextArea Auto Height 1`] = `
9
47
  color: var(--charcoal-text1);
10
48
  }
11
49
 
12
- .c3::before {
50
+ .c4::before {
13
51
  display: block;
14
52
  width: 0;
15
53
  height: 0;
@@ -17,7 +55,7 @@ exports[`Storyshots TextArea Auto Height 1`] = `
17
55
  margin-top: -4px;
18
56
  }
19
57
 
20
- .c3::after {
58
+ .c4::after {
21
59
  display: block;
22
60
  width: 0;
23
61
  height: 0;
@@ -25,7 +63,7 @@ exports[`Storyshots TextArea Auto Height 1`] = `
25
63
  margin-bottom: -4px;
26
64
  }
27
65
 
28
- .c5 {
66
+ .c6 {
29
67
  font-size: 14px;
30
68
  line-height: 22px;
31
69
  display: flow-root;
@@ -34,7 +72,7 @@ exports[`Storyshots TextArea Auto Height 1`] = `
34
72
  transition: 0.2s color,0.2s box-shadow;
35
73
  }
36
74
 
37
- .c5::before {
75
+ .c6::before {
38
76
  display: block;
39
77
  width: 0;
40
78
  height: 0;
@@ -42,7 +80,7 @@ exports[`Storyshots TextArea Auto Height 1`] = `
42
80
  margin-top: -4px;
43
81
  }
44
82
 
45
- .c5::after {
83
+ .c6::after {
46
84
  display: block;
47
85
  width: 0;
48
86
  height: 0;
@@ -50,27 +88,27 @@ exports[`Storyshots TextArea Auto Height 1`] = `
50
88
  margin-bottom: -4px;
51
89
  }
52
90
 
53
- .c5:not(:disabled):not([aria-disabled]):hover,
54
- .c5[aria-disabled='false']:hover {
91
+ .c6:not(:disabled):not([aria-disabled]):hover,
92
+ .c6[aria-disabled='false']:hover {
55
93
  color: var(--charcoal-text3-hover);
56
94
  }
57
95
 
58
- .c5:not(:disabled):not([aria-disabled]):active,
59
- .c5[aria-disabled='false']:active {
96
+ .c6:not(:disabled):not([aria-disabled]):active,
97
+ .c6[aria-disabled='false']:active {
60
98
  color: var(--charcoal-text3-press);
61
99
  }
62
100
 
63
- .c5:not(:disabled):not([aria-disabled]):active,
64
- .c5[aria-disabled='false']:active,
65
- .c5:not(:disabled):not([aria-disabled]):focus,
66
- .c5[aria-disabled='false']:focus,
67
- .c5:not(:disabled):not([aria-disabled]):focus-visible,
68
- .c5[aria-disabled='false']:focus-visible {
101
+ .c6:not(:disabled):not([aria-disabled]):active,
102
+ .c6[aria-disabled='false']:active,
103
+ .c6:not(:disabled):not([aria-disabled]):focus,
104
+ .c6[aria-disabled='false']:focus,
105
+ .c6:not(:disabled):not([aria-disabled]):focus-visible,
106
+ .c6[aria-disabled='false']:focus-visible {
69
107
  outline: none;
70
108
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
71
109
  }
72
110
 
73
- .c1 {
111
+ .c2 {
74
112
  display: -webkit-inline-box;
75
113
  display: -webkit-inline-flex;
76
114
  display: -ms-inline-flexbox;
@@ -81,15 +119,15 @@ exports[`Storyshots TextArea Auto Height 1`] = `
81
119
  align-items: center;
82
120
  }
83
121
 
84
- .c1 > .c4 {
122
+ .c2 > .c5 {
85
123
  margin-left: auto;
86
124
  }
87
125
 
88
- .c2 {
126
+ .c3 {
89
127
  margin-bottom: 8px;
90
128
  }
91
129
 
92
- .c0 {
130
+ .c1 {
93
131
  display: -webkit-box;
94
132
  display: -webkit-flex;
95
133
  display: -ms-flexbox;
@@ -99,7 +137,7 @@ exports[`Storyshots TextArea Auto Height 1`] = `
99
137
  flex-direction: column;
100
138
  }
101
139
 
102
- .c6 {
140
+ .c8 {
103
141
  position: relative;
104
142
  overflow: hidden;
105
143
  color: var(--charcoal-text2);
@@ -110,17 +148,17 @@ exports[`Storyshots TextArea Auto Height 1`] = `
110
148
  height: calc(22px * 4 + 18px);
111
149
  }
112
150
 
113
- .c6:not([aria-disabled]):hover,
114
- .c6 [aria-disabled='false']:hover {
151
+ .c8:not([aria-disabled]):hover,
152
+ .c8 [aria-disabled='false']:hover {
115
153
  background-color: var(--charcoal-surface3-hover);
116
154
  }
117
155
 
118
- .c6:focus-within {
156
+ .c8:focus-within {
119
157
  outline: none;
120
158
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
121
159
  }
122
160
 
123
- .c7 {
161
+ .c9 {
124
162
  border: none;
125
163
  outline: none;
126
164
  resize: none;
@@ -144,22 +182,27 @@ exports[`Storyshots TextArea Auto Height 1`] = `
144
182
  background: none;
145
183
  }
146
184
 
147
- .c7::-webkit-input-placeholder {
185
+ .c9::-webkit-input-placeholder {
148
186
  color: var(--charcoal-text3);
149
187
  }
150
188
 
151
- .c7::-moz-placeholder {
189
+ .c9::-moz-placeholder {
152
190
  color: var(--charcoal-text3);
153
191
  }
154
192
 
155
- .c7:-ms-input-placeholder {
193
+ .c9:-ms-input-placeholder {
156
194
  color: var(--charcoal-text3);
157
195
  }
158
196
 
159
- .c7::placeholder {
197
+ .c9::placeholder {
160
198
  color: var(--charcoal-text3);
161
199
  }
162
200
 
201
+ .c0 {
202
+ display: grid;
203
+ gap: 24px;
204
+ }
205
+
163
206
  <div
164
207
  data-dark={false}
165
208
  >
@@ -167,57 +210,68 @@ exports[`Storyshots TextArea Auto Height 1`] = `
167
210
  className="c0"
168
211
  >
169
212
  <div
170
- className="c1 c2"
171
- style={
172
- Object {
173
- "border": 0,
174
- "clip": "rect(0 0 0 0)",
175
- "clipPath": "inset(50%)",
176
- "height": 1,
177
- "margin": "0 -1px -1px 0",
178
- "overflow": "hidden",
179
- "padding": 0,
180
- "position": "absolute",
181
- "whiteSpace": "nowrap",
182
- "width": 1,
183
- }
184
- }
213
+ className="c1"
185
214
  >
186
- <label
187
- className="c3"
188
- htmlFor="test-id"
189
- id="test-id"
190
- onBlur={null}
191
- onFocus={null}
192
- >
193
- Label
194
- </label>
195
215
  <div
196
- className="c4 c5"
216
+ className="c2 c3"
217
+ style={
218
+ Object {
219
+ "border": 0,
220
+ "clip": "rect(0 0 0 0)",
221
+ "clipPath": "inset(50%)",
222
+ "height": "1px",
223
+ "margin": "-1px",
224
+ "overflow": "hidden",
225
+ "padding": 0,
226
+ "position": "absolute",
227
+ "whiteSpace": "nowrap",
228
+ "width": "1px",
229
+ }
230
+ }
197
231
  >
198
- <span />
232
+ <label
233
+ className="c4"
234
+ htmlFor="test-id"
235
+ id="test-id"
236
+ >
237
+ Label
238
+ </label>
239
+ <div
240
+ className="c5 c6"
241
+ >
242
+ <span>
243
+ <button
244
+ className="c7"
245
+ onClick={[Function]}
246
+ >
247
+ Text Link
248
+ </button>
249
+ </span>
250
+ </div>
199
251
  </div>
200
- </div>
201
- <div
202
- className="c6"
203
- rows={4}
204
- >
205
- <textarea
206
- aria-labelledby="test-id"
207
- className="c7"
208
- disabled={false}
209
- id="test-id"
210
- onChange={[Function]}
211
- placeholder="TextArea"
212
- readOnly={false}
252
+ <div
253
+ className="c8"
213
254
  rows={4}
214
- />
255
+ >
256
+ <textarea
257
+ aria-labelledby="test-id"
258
+ className="c9"
259
+ disabled={false}
260
+ id="test-id"
261
+ onChange={[Function]}
262
+ placeholder="Text Area"
263
+ readOnly={false}
264
+ required={false}
265
+ rows={4}
266
+ value=""
267
+ />
268
+ </div>
215
269
  </div>
216
270
  </div>
217
271
  </div>
218
272
  `;
219
273
 
220
- exports[`Storyshots TextArea Default 1`] = `
274
+ exports[`Storybook Tests TextArea Default 1`] = `
221
275
  .c7 {
222
276
  cursor: pointer;
223
277
  -webkit-appearance: none;
@@ -436,13 +490,13 @@ exports[`Storyshots TextArea Default 1`] = `
436
490
  "border": 0,
437
491
  "clip": "rect(0 0 0 0)",
438
492
  "clipPath": "inset(50%)",
439
- "height": 1,
440
- "margin": "0 -1px -1px 0",
493
+ "height": "1px",
494
+ "margin": "-1px",
441
495
  "overflow": "hidden",
442
496
  "padding": 0,
443
497
  "position": "absolute",
444
498
  "whiteSpace": "nowrap",
445
- "width": 1,
499
+ "width": "1px",
446
500
  }
447
501
  }
448
502
  >
@@ -450,8 +504,6 @@ exports[`Storyshots TextArea Default 1`] = `
450
504
  className="c4"
451
505
  htmlFor="test-id"
452
506
  id="test-id"
453
- onBlur={null}
454
- onFocus={null}
455
507
  >
456
508
  Label
457
509
  </label>
@@ -480,7 +532,9 @@ exports[`Storyshots TextArea Default 1`] = `
480
532
  onChange={[Function]}
481
533
  placeholder="Text Area"
482
534
  readOnly={false}
535
+ required={false}
483
536
  rows={4}
537
+ value=""
484
538
  />
485
539
  </div>
486
540
  </div>
@@ -488,7 +542,7 @@ exports[`Storyshots TextArea Default 1`] = `
488
542
  </div>
489
543
  `;
490
544
 
491
- exports[`Storyshots TextArea Has Count 1`] = `
545
+ exports[`Storybook Tests TextArea HasCount 1`] = `
492
546
  .c7 {
493
547
  cursor: pointer;
494
548
  -webkit-appearance: none;
@@ -716,13 +770,13 @@ exports[`Storyshots TextArea Has Count 1`] = `
716
770
  "border": 0,
717
771
  "clip": "rect(0 0 0 0)",
718
772
  "clipPath": "inset(50%)",
719
- "height": 1,
720
- "margin": "0 -1px -1px 0",
773
+ "height": "1px",
774
+ "margin": "-1px",
721
775
  "overflow": "hidden",
722
776
  "padding": 0,
723
777
  "position": "absolute",
724
778
  "whiteSpace": "nowrap",
725
- "width": 1,
779
+ "width": "1px",
726
780
  }
727
781
  }
728
782
  >
@@ -730,8 +784,6 @@ exports[`Storyshots TextArea Has Count 1`] = `
730
784
  className="c4"
731
785
  htmlFor="test-id"
732
786
  id="test-id"
733
- onBlur={null}
734
- onFocus={null}
735
787
  >
736
788
  Label
737
789
  </label>
@@ -761,7 +813,9 @@ exports[`Storyshots TextArea Has Count 1`] = `
761
813
  onChange={[Function]}
762
814
  placeholder="Text Area"
763
815
  readOnly={false}
816
+ required={false}
764
817
  rows={4}
818
+ value=""
765
819
  />
766
820
  <span
767
821
  className="c10"
@@ -774,7 +828,7 @@ exports[`Storyshots TextArea Has Count 1`] = `
774
828
  </div>
775
829
  `;
776
830
 
777
- exports[`Storyshots TextArea Has Label 1`] = `
831
+ exports[`Storybook Tests TextArea HasLabel 1`] = `
778
832
  .c9 {
779
833
  cursor: pointer;
780
834
  -webkit-appearance: none;
@@ -1062,7 +1116,9 @@ exports[`Storyshots TextArea Has Label 1`] = `
1062
1116
  onChange={[Function]}
1063
1117
  placeholder="Text Area"
1064
1118
  readOnly={false}
1119
+ required={false}
1065
1120
  rows={4}
1121
+ value=""
1066
1122
  />
1067
1123
  </div>
1068
1124
  <p
@@ -1,10 +1,10 @@
1
1
  import styled from 'styled-components'
2
- import { Story } from '../../_lib/compat'
3
2
  import Clickable from '../Clickable'
4
- import TextField, { TextFieldProps } from '.'
3
+ import TextField from '.'
5
4
  import { px } from '@charcoal-ui/utils'
6
5
  import IconButton from '../IconButton'
7
6
  import { useCallback, useState } from 'react'
7
+ import { Meta, StoryObj } from '@storybook/react'
8
8
 
9
9
  export default {
10
10
  title: 'TextField',
@@ -12,86 +12,53 @@ export default {
12
12
  argTypes: {},
13
13
  args: {
14
14
  showLabel: false,
15
- label: 'Label',
16
15
  assistiveText: '',
17
16
  disabled: false,
18
17
  required: false,
19
18
  invalid: false,
19
+ label: 'Label',
20
+ requiredText: '*必須',
21
+ subLabel: <Clickable>Text Link</Clickable>,
22
+ placeholder: 'TextField',
20
23
  },
21
- }
24
+ render: function Render(args) {
25
+ return (
26
+ <Container>
27
+ <TextField {...args} />
28
+ </Container>
29
+ )
30
+ },
31
+ } as Meta<typeof TextField>
22
32
 
23
33
  const Container = styled.div`
24
34
  display: grid;
25
35
  gap: ${({ theme }) => px(theme.spacing[24])};
26
36
  `
27
37
 
28
- const Template: Story<Partial<TextFieldProps>> = (args) => (
29
- <Container>
30
- <TextField
31
- label="Label"
32
- requiredText="*必須"
33
- subLabel={<Clickable>Text Link</Clickable>}
34
- placeholder="TextField"
35
- {...args}
36
- />
37
- </Container>
38
- )
38
+ export const Default = {}
39
39
 
40
- export const Default = Template.bind({})
41
-
42
- export const HasLabel = Template.bind({})
43
- HasLabel.args = {
44
- showLabel: true,
45
- assistiveText: 'Assistive text',
46
- required: true,
47
- }
48
-
49
- export const HasCount = Template.bind({})
50
- HasCount.args = {
51
- showCount: true,
52
- maxLength: 100,
40
+ export const HasLabel = {
41
+ args: {
42
+ showLabel: true,
43
+ assistiveText: 'Assistive text',
44
+ required: true,
45
+ },
53
46
  }
54
47
 
55
- export const HasAffix: Story<Partial<TextFieldProps>> = (args) => (
56
- <TextField label="Label" placeholder="path/to/your/file" {...args} />
57
- )
58
- HasAffix.args = {
59
- showCount: true,
60
- maxLength: 200,
61
- prefix: '/home/john/',
62
- suffix: '.png',
48
+ export const HasCount = {
49
+ args: {
50
+ showCount: true,
51
+ maxLength: 100,
52
+ },
63
53
  }
64
54
 
65
- export const PrefixIcon: Story<Partial<TextFieldProps>> = (args) => {
66
- const [value, setValue] = useState('')
67
- const handleChange = useCallback((value: string) => {
68
- setValue(value)
69
- }, [])
70
- const handleClear = useCallback(() => {
71
- setValue('')
72
- }, [])
73
- return (
74
- <TextField
75
- {...args}
76
- label="Label"
77
- placeholder="作品を検索"
78
- value={value}
79
- onChange={handleChange}
80
- prefix={
81
- <PrefixIconWrap>
82
- <pixiv-icon name="16/Search" />
83
- </PrefixIconWrap>
84
- }
85
- suffix={
86
- <IconButton
87
- variant="Overlay"
88
- icon={'16/Remove'}
89
- size="XS"
90
- onClick={handleClear}
91
- />
92
- }
93
- />
94
- )
55
+ export const HasAffix: StoryObj<typeof TextField> = {
56
+ args: {
57
+ showCount: true,
58
+ maxLength: 200,
59
+ prefix: '/home/john/',
60
+ suffix: '.png',
61
+ },
95
62
  }
96
63
 
97
64
  const PrefixIconWrap = styled.div`
@@ -99,3 +66,37 @@ const PrefixIconWrap = styled.div`
99
66
  align-items: center;
100
67
  color: ${({ theme }) => theme.color.text3};
101
68
  `
69
+
70
+ export const PrefixIcon: StoryObj<typeof TextField> = {
71
+ render: function Render(args) {
72
+ const [value, setValue] = useState('')
73
+ const handleChange = useCallback((value: string) => {
74
+ setValue(value)
75
+ }, [])
76
+ const handleClear = useCallback(() => {
77
+ setValue('')
78
+ }, [])
79
+ return (
80
+ <TextField
81
+ {...args}
82
+ label="Label"
83
+ placeholder="作品を検索"
84
+ value={value}
85
+ onChange={handleChange}
86
+ prefix={
87
+ <PrefixIconWrap>
88
+ <pixiv-icon name="16/Search" />
89
+ </PrefixIconWrap>
90
+ }
91
+ suffix={
92
+ <IconButton
93
+ variant="Overlay"
94
+ icon={'16/Remove'}
95
+ size="XS"
96
+ onClick={handleClear}
97
+ />
98
+ }
99
+ />
100
+ )
101
+ },
102
+ }