@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe-commerce/elsie",
3
- "version": "1.5.0-alpha3000",
3
+ "version": "1.5.0-alpha3001",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "description": "Domain Package SDK",
6
6
  "engines": {
@@ -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
- <div
109
- className={classes([
110
- 'dropin-incrementer__button-container',
111
- [`dropin-incrementer__button-container--disabled`, disabled],
112
- ])}
113
- >
114
- <Localizer>
115
- <button
116
- type="button"
117
- className={classes([
118
- 'dropin-incrementer__decrease-button',
119
- [`dropin-incrementer__decrease-button--disabled`, disabled],
120
- ])}
121
- onClick={() => handleIncrementer(currentValue - 1)}
122
- disabled={disabled || currentValue < minValue + 1}
123
- aria-label={
124
- (<Text id="Dropin.Incrementer.decreaseLabel" />) as any
125
- }
126
- >
127
- <Icon
128
- source={Minus}
129
- size="16"
130
- stroke="1"
131
- viewBox="4 2 20 20"
132
- className="dropin-incrementer__down"
133
- />
134
- </button>
135
- </Localizer>
136
- </div>
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
- <div
161
- className={classes([
162
- 'dropin-incrementer__button-container',
163
- [`dropin-incrementer__button-container--disabled`, disabled],
164
- ])}
165
- >
166
- {/* Plus/Add button */}
167
- <Localizer>
168
- <button
169
- type="button"
170
- className={classes([
171
- 'dropin-incrementer__increase-button',
172
- [`dropin-incrementer__increase-button--disabled`, disabled],
173
- ])}
174
- onClick={() => handleIncrementer(currentValue + 1)}
175
- disabled={disabled || currentValue > maxValue - 1}
176
- aria-label={
177
- (<Text id="Dropin.Incrementer.increaseLabel" />) as any
178
- }
179
- >
180
- <Icon
181
- source={Add}
182
- size="16"
183
- stroke="1"
184
- viewBox="4 2 20 20"
185
- className="dropin-incrementer__add"
186
- />
187
- </button>
188
- </Localizer>
189
- </div>
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 style="background: green; color: white; padding: 2px 8px; border-radius: 4px;">Active</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 style={{
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 style={{ marginBottom: '4px', display: 'block' }}>Edit</button>
375
- <button style={{ marginBottom: '4px', display: 'block' }}>Delete</button>
376
- <button style={{ display: 'block' }}>View</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 style={{
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 style={{ marginBottom: '4px', display: 'block' }}>Edit</button>
410
- <button style={{ marginBottom: '4px', display: 'block' }}>Approve</button>
411
- <button style={{ display: 'block' }}>Reject</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 style={{
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 style={{ marginBottom: '4px', display: 'block' }}>Edit</button>
445
- <button style={{ marginBottom: '4px', display: 'block' }}>Activate</button>
446
- <button style={{ display: 'block' }}>Archive</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
- role="columnheader"
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)}
@@ -143,6 +143,7 @@
143
143
  "picker": "Select a date"
144
144
  },
145
145
  "Table": {
146
+ "ariaSortNone": "none",
146
147
  "ariaSortAscending": "ascending",
147
148
  "ariaSortDescending": "descending",
148
149
  "sortedAscending": "Sort {label} ascending",