@adobe-commerce/elsie 1.5.0-alpha3000 → 1.5.0-alpha3001
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.
- package/package.json +1 -1
- package/src/components/Incrementer/Incrementer.css +6 -0
- package/src/components/Incrementer/Incrementer.stories.tsx +18 -0
- package/src/components/Incrementer/Incrementer.tsx +66 -59
- package/src/components/Table/Table.stories.tsx +13 -40
- package/src/components/Table/Table.tsx +6 -1
- package/src/i18n/en_US.json +1 -0
package/package.json
CHANGED
|
@@ -19,6 +19,12 @@
|
|
|
19
19
|
opacity: 1;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
.dropin-incrementer__content--no-buttons {
|
|
23
|
+
grid-template-columns: max-content;
|
|
24
|
+
width: fit-content;
|
|
25
|
+
margin-inline: auto;
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
.dropin-incrementer__content--disabled {
|
|
23
29
|
background: var(--color-neutral-300);
|
|
24
30
|
border-radius: var(--shape-border-radius-1);
|
|
@@ -79,6 +79,10 @@ const meta: Meta<IncrementerProps> = {
|
|
|
79
79
|
description: 'Maximum length of the input field',
|
|
80
80
|
type: 'number',
|
|
81
81
|
},
|
|
82
|
+
showButtons: {
|
|
83
|
+
description: 'Show increase/decrease buttons',
|
|
84
|
+
control: 'boolean',
|
|
85
|
+
},
|
|
82
86
|
},
|
|
83
87
|
};
|
|
84
88
|
|
|
@@ -170,3 +174,17 @@ export const WithError = {
|
|
|
170
174
|
await expect(error).toHaveTextContent('Maximum quantity is 100');
|
|
171
175
|
},
|
|
172
176
|
};
|
|
177
|
+
|
|
178
|
+
export const WithoutButtons: Story = {
|
|
179
|
+
args: {
|
|
180
|
+
size: 'medium',
|
|
181
|
+
onValue: action('onValue'),
|
|
182
|
+
name: 'incrementerField',
|
|
183
|
+
value: '1',
|
|
184
|
+
min: 1,
|
|
185
|
+
max: 100,
|
|
186
|
+
disabled: false,
|
|
187
|
+
'aria-label': 'Quantity',
|
|
188
|
+
showButtons: false,
|
|
189
|
+
},
|
|
190
|
+
};
|
|
@@ -28,6 +28,7 @@ export interface IncrementerProps
|
|
|
28
28
|
max?: number;
|
|
29
29
|
disabled?: boolean;
|
|
30
30
|
maxLength?: number;
|
|
31
|
+
showButtons?: boolean;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export const Incrementer: FunctionComponent<IncrementerProps> = ({
|
|
@@ -42,6 +43,7 @@ export const Incrementer: FunctionComponent<IncrementerProps> = ({
|
|
|
42
43
|
onValue,
|
|
43
44
|
onUpdateError,
|
|
44
45
|
size = 'medium',
|
|
46
|
+
showButtons = true,
|
|
45
47
|
...props
|
|
46
48
|
}) => {
|
|
47
49
|
const [currentValue, setCurrentValue] = useState<number>(Number(value));
|
|
@@ -99,41 +101,44 @@ export const Incrementer: FunctionComponent<IncrementerProps> = ({
|
|
|
99
101
|
className={classes([
|
|
100
102
|
'dropin-incrementer__content',
|
|
101
103
|
`dropin-incrementer__content--${size}`,
|
|
104
|
+
['dropin-incrementer__content--no-buttons', !showButtons],
|
|
102
105
|
[`dropin-incrementer__content--error`, isInvalid],
|
|
103
106
|
[`dropin-incrementer__content--success`, success],
|
|
104
107
|
[`dropin-incrementer__content--disabled`, disabled],
|
|
105
108
|
])}
|
|
106
109
|
>
|
|
107
110
|
{/* Minus Button */}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
111
|
+
{showButtons && (
|
|
112
|
+
<div
|
|
113
|
+
className={classes([
|
|
114
|
+
'dropin-incrementer__button-container',
|
|
115
|
+
[`dropin-incrementer__button-container--disabled`, disabled],
|
|
116
|
+
])}
|
|
117
|
+
>
|
|
118
|
+
<Localizer>
|
|
119
|
+
<button
|
|
120
|
+
type="button"
|
|
121
|
+
className={classes([
|
|
122
|
+
'dropin-incrementer__decrease-button',
|
|
123
|
+
[`dropin-incrementer__decrease-button--disabled`, disabled],
|
|
124
|
+
])}
|
|
125
|
+
onClick={() => handleIncrementer(currentValue - 1)}
|
|
126
|
+
disabled={disabled || currentValue < minValue + 1}
|
|
127
|
+
aria-label={
|
|
128
|
+
(<Text id="Dropin.Incrementer.decreaseLabel" />) as any
|
|
129
|
+
}
|
|
130
|
+
>
|
|
131
|
+
<Icon
|
|
132
|
+
source={Minus}
|
|
133
|
+
size="16"
|
|
134
|
+
stroke="1"
|
|
135
|
+
viewBox="4 2 20 20"
|
|
136
|
+
className="dropin-incrementer__down"
|
|
137
|
+
/>
|
|
138
|
+
</button>
|
|
139
|
+
</Localizer>
|
|
140
|
+
</div>
|
|
141
|
+
)}
|
|
137
142
|
|
|
138
143
|
{/* Input Field */}
|
|
139
144
|
<input
|
|
@@ -157,36 +162,38 @@ export const Incrementer: FunctionComponent<IncrementerProps> = ({
|
|
|
157
162
|
{...props}
|
|
158
163
|
/>
|
|
159
164
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
165
|
+
{showButtons && (
|
|
166
|
+
<div
|
|
167
|
+
className={classes([
|
|
168
|
+
'dropin-incrementer__button-container',
|
|
169
|
+
[`dropin-incrementer__button-container--disabled`, disabled],
|
|
170
|
+
])}
|
|
171
|
+
>
|
|
172
|
+
{/* Plus/Add button */}
|
|
173
|
+
<Localizer>
|
|
174
|
+
<button
|
|
175
|
+
type="button"
|
|
176
|
+
className={classes([
|
|
177
|
+
'dropin-incrementer__increase-button',
|
|
178
|
+
[`dropin-incrementer__increase-button--disabled`, disabled],
|
|
179
|
+
])}
|
|
180
|
+
onClick={() => handleIncrementer(currentValue + 1)}
|
|
181
|
+
disabled={disabled || currentValue > maxValue - 1}
|
|
182
|
+
aria-label={
|
|
183
|
+
(<Text id="Dropin.Incrementer.increaseLabel" />) as any
|
|
184
|
+
}
|
|
185
|
+
>
|
|
186
|
+
<Icon
|
|
187
|
+
source={Add}
|
|
188
|
+
size="16"
|
|
189
|
+
stroke="1"
|
|
190
|
+
viewBox="4 2 20 20"
|
|
191
|
+
className="dropin-incrementer__add"
|
|
192
|
+
/>
|
|
193
|
+
</button>
|
|
194
|
+
</Localizer>
|
|
195
|
+
</div>
|
|
196
|
+
)}
|
|
190
197
|
</div>
|
|
191
198
|
{isInvalid && (
|
|
192
199
|
<p className="dropin-incrementer__content--error-message">
|
|
@@ -326,7 +326,7 @@ export const WideTable: Story = {
|
|
|
326
326
|
* {
|
|
327
327
|
* user: <div><strong>John Doe</strong><br/>john@example.com<br/>Senior Developer</div>,
|
|
328
328
|
* description: <div>Lead developer for the<br/>e-commerce platform<br/>with 5+ years experience</div>,
|
|
329
|
-
* status: <span
|
|
329
|
+
* status: <span>Active</span>,
|
|
330
330
|
* actions: <div><button>Edit</button><br/><button>Delete</button><br/><button>View</button></div>
|
|
331
331
|
* }
|
|
332
332
|
* ]}
|
|
@@ -358,22 +358,13 @@ export const ComplexCells: Story = {
|
|
|
358
358
|
</div>
|
|
359
359
|
),
|
|
360
360
|
status: (
|
|
361
|
-
<span
|
|
362
|
-
background: '#22c55e',
|
|
363
|
-
color: 'white',
|
|
364
|
-
padding: '2px 8px',
|
|
365
|
-
borderRadius: '4px',
|
|
366
|
-
fontSize: '12px',
|
|
367
|
-
fontWeight: 'bold'
|
|
368
|
-
}}>
|
|
369
|
-
Active
|
|
370
|
-
</span>
|
|
361
|
+
<span>Active</span>
|
|
371
362
|
),
|
|
372
363
|
actions: (
|
|
373
364
|
<div>
|
|
374
|
-
<button
|
|
375
|
-
<button
|
|
376
|
-
<button
|
|
365
|
+
<button>Edit</button>
|
|
366
|
+
<button>Delete</button>
|
|
367
|
+
<button>View</button>
|
|
377
368
|
</div>
|
|
378
369
|
),
|
|
379
370
|
},
|
|
@@ -393,22 +384,13 @@ export const ComplexCells: Story = {
|
|
|
393
384
|
</div>
|
|
394
385
|
),
|
|
395
386
|
status: (
|
|
396
|
-
<span
|
|
397
|
-
background: '#f59e0b',
|
|
398
|
-
color: 'white',
|
|
399
|
-
padding: '2px 8px',
|
|
400
|
-
borderRadius: '4px',
|
|
401
|
-
fontSize: '12px',
|
|
402
|
-
fontWeight: 'bold'
|
|
403
|
-
}}>
|
|
404
|
-
Pending
|
|
405
|
-
</span>
|
|
387
|
+
<span>Pending</span>
|
|
406
388
|
),
|
|
407
389
|
actions: (
|
|
408
390
|
<div>
|
|
409
|
-
<button
|
|
410
|
-
<button
|
|
411
|
-
<button
|
|
391
|
+
<button>Edit</button>
|
|
392
|
+
<button>Approve</button>
|
|
393
|
+
<button>Reject</button>
|
|
412
394
|
</div>
|
|
413
395
|
),
|
|
414
396
|
},
|
|
@@ -428,22 +410,13 @@ export const ComplexCells: Story = {
|
|
|
428
410
|
</div>
|
|
429
411
|
),
|
|
430
412
|
status: (
|
|
431
|
-
<span
|
|
432
|
-
background: '#ef4444',
|
|
433
|
-
color: 'white',
|
|
434
|
-
padding: '2px 8px',
|
|
435
|
-
borderRadius: '4px',
|
|
436
|
-
fontSize: '12px',
|
|
437
|
-
fontWeight: 'bold'
|
|
438
|
-
}}>
|
|
439
|
-
Inactive
|
|
440
|
-
</span>
|
|
413
|
+
<span>Inactive</span>
|
|
441
414
|
),
|
|
442
415
|
actions: (
|
|
443
416
|
<div>
|
|
444
|
-
<button
|
|
445
|
-
<button
|
|
446
|
-
<button
|
|
417
|
+
<button>Edit</button>
|
|
418
|
+
<button>Activate</button>
|
|
419
|
+
<button>Archive</button>
|
|
447
420
|
</div>
|
|
448
421
|
),
|
|
449
422
|
},
|
|
@@ -49,6 +49,7 @@ export const Table: FunctionComponent<TableProps> = ({
|
|
|
49
49
|
...props
|
|
50
50
|
}) => {
|
|
51
51
|
const translations = useText({
|
|
52
|
+
ariaSortNone: 'Dropin.Table.ariaSortNone',
|
|
52
53
|
ariaSortAscending: 'Dropin.Table.ariaSortAscending',
|
|
53
54
|
ariaSortDescending: 'Dropin.Table.ariaSortDescending',
|
|
54
55
|
sortedAscending: 'Dropin.Table.sortedAscending',
|
|
@@ -115,7 +116,11 @@ export const Table: FunctionComponent<TableProps> = ({
|
|
|
115
116
|
['dropin-table__header__cell--sorted', column.sortBy === 'asc' || column.sortBy === 'desc'],
|
|
116
117
|
['dropin-table__header__cell--sortable', column.sortBy !== undefined]
|
|
117
118
|
])}
|
|
118
|
-
|
|
119
|
+
aria-sort={
|
|
120
|
+
column.sortBy === 'asc' ? translations.ariaSortAscending :
|
|
121
|
+
column.sortBy === 'desc' ? translations.ariaSortDescending :
|
|
122
|
+
column.sortBy === true ? translations.ariaSortNone : undefined
|
|
123
|
+
}
|
|
119
124
|
>
|
|
120
125
|
{column.label}
|
|
121
126
|
{getSortButton(column)}
|