@sonic-equipment/ui 189.0.0 → 191.0.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.
@@ -244,7 +244,7 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
244
244
  MA: t('industry.MA'),
245
245
  OT: t('industry.OT'),
246
246
  /* eslint-enable sort-keys-fix/sort-keys-fix */
247
- }, placeholder: t('Select an industry'), variant: "solid" }), jsx(TextField, { showLabel: true, isDisabled: isDisabled, label: t('VAT Number'), minLength: 8, name: "customerVatNumber" }, `vat${Boolean(validationErrors.customerVatNumber)}`), jsx(TextField, { showLabel: true, defaultValue: cart.poNumber, isDisabled: isDisabled, isRequired: cart.requiresPoNumber, label: t('PO Number'), name: "poNumber" }), paymentMethodOptions && Object.keys(paymentMethodOptions).length > 1 && (jsx(Select, { "data-test-selector": "paymentMethodSelect", defaultSelectedOption: cart.paymentOptions?.paymentMethods?.[0]?.name || 'ADY', isDisabled: isDisabled, label: t('Payment method'), name: "paymentMethod", onChange: setSelectedPaymentMethod, options: paymentMethodOptions, selectedOption: selectedPaymentMethod, variant: "solid" })), isAdyenPayment && cart.billTo && (jsx(AdyenPayment, { amount: cart.orderGrandTotal, cartId: cart.trackId, countryCode: countryCode, currencyCode: currencyCode, customerId: cart.billTo.id, dropinRef: dropinRef, environment: environment === 'production' ? 'live' : 'test', isDisabled: isDisabled, onComplete: onComplete, onError: onError, orderAmount: cart.orderGrandTotal, returnUrl:
247
+ }, placeholder: t('Select an industry'), variant: "solid" }), jsx(TextField, { showLabel: true, defaultValue: cart.customerVatNumber, isDisabled: isDisabled, label: t('VAT Number'), minLength: 8, name: "customerVatNumber" }, `vat${Boolean(validationErrors.customerVatNumber)}`), jsx(TextField, { showLabel: true, defaultValue: cart.poNumber, isDisabled: isDisabled, isRequired: cart.requiresPoNumber, label: t('PO Number'), name: "poNumber" }), paymentMethodOptions && Object.keys(paymentMethodOptions).length > 1 && (jsx(Select, { "data-test-selector": "paymentMethodSelect", defaultSelectedOption: cart.paymentOptions?.paymentMethods?.[0]?.name || 'ADY', isDisabled: isDisabled, label: t('Payment method'), name: "paymentMethod", onChange: setSelectedPaymentMethod, options: paymentMethodOptions, selectedOption: selectedPaymentMethod, variant: "solid" })), isAdyenPayment && cart.billTo && (jsx(AdyenPayment, { amount: cart.orderGrandTotal, cartId: cart.trackId, countryCode: countryCode, currencyCode: currencyCode, customerId: cart.billTo.id, dropinRef: dropinRef, environment: environment === 'production' ? 'live' : 'test', isDisabled: isDisabled, onComplete: onComplete, onError: onError, orderAmount: cart.orderGrandTotal, returnUrl:
248
248
  /* eslint-disable ssr-friendly/no-dom-globals-in-react-fc */
249
249
  typeof window === 'undefined'
250
250
  ? ''
package/dist/styles.css CHANGED
@@ -7976,7 +7976,6 @@ button.swiper-pagination-bullet {
7976
7976
  .table-module-k47fT .table-module-dISOo.table-module-PQejy {
7977
7977
  position: sticky;
7978
7978
  z-index: var(--z-selected);
7979
- container-name: sticky-column;
7980
7979
  /* stylelint-disable-next-line declaration-property-value-no-unknown */
7981
7980
  container-type: scroll-state;
7982
7981
  inset-inline: 0;
@@ -7997,7 +7996,7 @@ button.swiper-pagination-bullet {
7997
7996
  inset-inline: auto 100%;
7998
7997
  }
7999
7998
 
8000
- @container sticky-column scroll-state(stuck: inline-end) {
7999
+ @container scroll-state(stuck: inline-end) {
8001
8000
 
8002
8001
  .table-module-k47fT .table-module-dISOo.table-module-PQejy::before {
8003
8002
  opacity: 1
@@ -8009,7 +8008,7 @@ button.swiper-pagination-bullet {
8009
8008
  rotate: 180deg;
8010
8009
  }
8011
8010
 
8012
- @container sticky-column scroll-state(stuck: inline-start) {
8011
+ @container scroll-state(stuck: inline-start) {
8013
8012
 
8014
8013
  .table-module-k47fT .table-module-dISOo.table-module-PQejy::after {
8015
8014
  opacity: 1
@@ -8157,10 +8156,6 @@ button.swiper-pagination-bullet {
8157
8156
  text-wrap: nowrap;
8158
8157
  }
8159
8158
 
8160
- .table-module-k47fT col:hover {
8161
- background-color: red;
8162
- }
8163
-
8164
8159
  @media (pointer: fine) {
8165
8160
 
8166
8161
  .table-module-k47fT.table-module-JEp5f:has(.table-module-DK-wn th.table-module-hyPmy:nth-child(1):hover) .table-module-dISOo:nth-child(1),
@@ -8266,9 +8261,10 @@ button.swiper-pagination-bullet {
8266
8261
 
8267
8262
  display: grid;
8268
8263
  gap: var(--gap-row) var(--gap-col);
8269
- grid-template:
8270
- [bar-start] auto [bar-end] repeat(3, auto)
8271
- / [bar-start] 1fr [bar-end];
8264
+ grid-template: [bar-start] auto [bar-end] repeat(
8265
+ 3,
8266
+ auto
8267
+ ) / [bar-start] 1fr [bar-end];
8272
8268
  grid-template-areas:
8273
8269
  'search'
8274
8270
  'filter'
@@ -8352,7 +8348,6 @@ button.swiper-pagination-bullet {
8352
8348
  margin: calc(var(--gap-row) * -1)
8353
8349
  calc(var(--page-container-padding-inline) * -1);
8354
8350
  background-color: var(--color-white);
8355
- container-name: sticky-bar;
8356
8351
  /* stylelint-disable-next-line declaration-property-value-no-unknown */
8357
8352
  container-type: scroll-state;
8358
8353
  grid-area: bar;
@@ -8376,7 +8371,7 @@ button.swiper-pagination-bullet {
8376
8371
  transition: opacity var(--transition-duration-short);
8377
8372
  }
8378
8373
 
8379
- @container sticky-bar scroll-state(stuck: block-start) {
8374
+ @container scroll-state(stuck: block-start) {
8380
8375
 
8381
8376
  .order-history-module-LrkiZ .order-history-module-98Tvf::after {
8382
8377
  opacity: 1
@@ -64,7 +64,7 @@ function DataTable({ actions, columns: _columns, data, onSort: _onSort, }) {
64
64
  if (data.length === 0 || columns.length === 0)
65
65
  return null;
66
66
  if (isXl)
67
- return (jsx("div", { className: styles['data-table'], children: jsx(Table, { className: styles['content'], cssColumns: cssColumns, highlight: "col", stretch: true, thead: jsx(TR, { children: columns.map(column => (jsx(TH, { ...column.props, sortable: !!column.sort?.isEnabled, children: 'Icon' in column.header ? (jsx(column.header.Icon, { className: styles['th-icon'] })) : (!column.header.isHidden && (jsx(SortWrapper, { column: column, direction: sortInfo?.key === column.key ||
67
+ return (jsx("div", { className: styles['data-table'], children: jsx(Table, { className: styles['content'], cssColumns: cssColumns, highlight: "col", stretch: true, thead: jsx(TR, { children: columns.map(column => (jsx(TH, { scope: "col", ...column.props, sortable: !!column.sort?.isEnabled, children: 'Icon' in column.header ? (jsx(column.header.Icon, { className: styles['th-icon'] })) : (!column.header.isHidden && (jsx(SortWrapper, { column: column, direction: sortInfo?.key === column.key ||
68
68
  (column.sort?.isEnabled &&
69
69
  sortInfo?.key === column.sort.columnName)
70
70
  ? sortInfo?.direction
@@ -4,11 +4,14 @@ import { OnColumnChangedHandler } from './table-context';
4
4
  import { TableColumnProperties } from './types';
5
5
  export interface ColumnInfo {
6
6
  id: UUID;
7
+ index: number | null;
7
8
  props: TableColumnProperties;
8
9
  rowId: UUID;
9
10
  }
10
11
  export interface CellInfo {
12
+ columnId: UUID | null;
11
13
  id: UUID;
14
+ index: number | null;
12
15
  onColumnChanged: OnColumnChangedHandler;
13
16
  }
14
17
  export interface RowInfo {
@@ -13,9 +13,19 @@ function TableProvider({ children, onColumnsChanged, }) {
13
13
  cell: (rowId, onColumnChanged) => {
14
14
  const row = rowsRef.current.find(row => row.id === rowId);
15
15
  if (!row)
16
- return { deregister: voidFunction }; // throw new Error(`Row with id ${id} does not exist.`)
17
- const cell = { id: createUUID(), onColumnChanged };
18
- row.cells.push(cell);
16
+ return { deregister: voidFunction };
17
+ const cell = {
18
+ columnId: null,
19
+ id: createUUID(),
20
+ index: null,
21
+ onColumnChanged,
22
+ };
23
+ cell.index = row.cells.push(cell);
24
+ const columnInfo = columnsRef.current.find(column => column.index === cell.index);
25
+ if (!columnInfo)
26
+ throw new Error(`Column with index ${cell.index} does not exist.`);
27
+ cell.columnId = columnInfo.id;
28
+ onColumnChanged(columnInfo.props);
19
29
  return {
20
30
  deregister: () => {
21
31
  row.cells = row.cells.filter(c => c.id !== cell.id);
@@ -25,10 +35,11 @@ function TableProvider({ children, onColumnsChanged, }) {
25
35
  column: (rowId, props) => {
26
36
  const column = {
27
37
  id: createUUID(),
38
+ index: null,
28
39
  props,
29
40
  rowId,
30
41
  };
31
- columnsRef.current.push(column);
42
+ column.index = columnsRef.current.push(column);
32
43
  onColumnsChanged?.(columnsRef.current);
33
44
  return {
34
45
  deregister: () => {
@@ -36,13 +47,11 @@ function TableProvider({ children, onColumnsChanged, }) {
36
47
  onColumnsChanged?.(columnsRef.current);
37
48
  },
38
49
  update: (props) => {
39
- const updatedColumn = columnsRef.current.find(c => c.id === column.id);
40
- if (!updatedColumn)
41
- throw new Error(`Column with id ${column.id} does not exist.`);
42
- updatedColumn.props = props;
43
- rowsRef.current.forEach(row => row.cells
44
- .find(cell => cell.id === column.id)
45
- ?.onColumnChanged(props));
50
+ column.props = { ...column.props, ...props };
51
+ rowsRef.current.forEach(row => row.cells.forEach(cell => {
52
+ if (cell.columnId === column.id)
53
+ cell.onColumnChanged(props);
54
+ }));
46
55
  },
47
56
  };
48
57
  },
@@ -7,10 +7,10 @@ function useTD(props) {
7
7
  const onColumnChanged = useCallback((columnProps) => {
8
8
  setColumnProps(columnProps);
9
9
  }, []);
10
- const [{ deregister }] = useState(register.cell(onColumnChanged));
11
10
  useEffect(() => {
11
+ const { deregister } = register.cell(onColumnChanged);
12
12
  return deregister;
13
- }, [deregister]);
13
+ }, [onColumnChanged, register]);
14
14
  return {
15
15
  ...props,
16
16
  align: columnProps?.align ?? props.align ?? 'start',
@@ -1,21 +1,19 @@
1
- import { useRef, useEffect } from 'react';
1
+ import { useState, useEffect } from 'react';
2
2
  import { useTableRow } from './use-table-row.js';
3
3
 
4
4
  function useTH(props) {
5
5
  const { register } = useTableRow();
6
- const updateRef = useRef();
6
+ const [update, setUpdate] = useState(null);
7
7
  useEffect(() => {
8
8
  const { deregister, update } = register.column(props);
9
- updateRef.current = update;
10
- return () => {
11
- deregister();
12
- updateRef.current = undefined;
13
- };
9
+ // eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
10
+ setUpdate(update);
11
+ return deregister;
14
12
  // eslint-disable-next-line react-hooks/exhaustive-deps
15
13
  }, [register]);
16
14
  useEffect(() => {
17
- updateRef.current?.(props);
18
- }, [props]);
15
+ update?.(props);
16
+ }, [update, props]);
19
17
  return props;
20
18
  }
21
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "189.0.0",
3
+ "version": "191.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {