@sonic-equipment/ui 130.0.0 → 131.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.
@@ -159,7 +159,7 @@ function Payment({ atp, cart: _cart, form, onError: _onError, onPaymentComplete,
159
159
  setAsSoonAsPossible(checked);
160
160
  if (checked)
161
161
  setDeliveryDate('');
162
- }, children: jsx(FormattedMessage, { id: "As soon as possible" }) }), jsx(Tooltip, { text: t('Selecting As Soon As Possible will enable us to send the products to you as they become available.') })] })] })), jsx(Select, { isRequired: true, defaultSelectedOption: cart.properties.industry, isDisabled: hasReturnedFromAdyen, label: t('Industry'), name: "industry", options: {
162
+ }, children: jsx(FormattedMessage, { id: "As soon as possible" }) }), jsx(Tooltip, { text: t('Selecting As Soon As Possible will enable us to send the products to you as they become available.') })] })] })), jsx(Select, { isRequired: true, "data-test-selector": "industrySelect", defaultSelectedOption: cart.properties.industry, isDisabled: hasReturnedFromAdyen, label: t('Industry'), name: "industry", options: {
163
163
  /* eslint-disable sort-keys-fix/sort-keys-fix */
164
164
  PP: 'Private User',
165
165
  AU: 'Automotive',
@@ -171,7 +171,7 @@ function Payment({ atp, cart: _cart, form, onError: _onError, onPaymentComplete,
171
171
  MA: 'Maritime',
172
172
  OT: 'Other',
173
173
  /* eslint-enable sort-keys-fix/sort-keys-fix */
174
- }, variant: "solid" }), jsx(TextField, { showLabel: true, defaultValue: cart.customerVatNumber, isDisabled: hasReturnedFromAdyen || isProcessing, label: t('VAT Number'), name: "vatNumber", onInput: e => debouncedValidator(e.target.value), validate: () => validationErrors.vatNumber ?? true }), jsx(TextField, { showLabel: true, defaultValue: cart.poNumber, isDisabled: hasReturnedFromAdyen || isProcessing, label: t('PO Number'), name: "poNumber" }), paymentMethodOptions && (jsx(Select, { defaultSelectedOption: cart.paymentOptions?.paymentMethods?.[0]?.name || 'ADY', isDisabled: (hasReturnedFromAdyen ||
174
+ }, variant: "solid" }), jsx(TextField, { showLabel: true, defaultValue: cart.customerVatNumber, isDisabled: hasReturnedFromAdyen || isProcessing, label: t('VAT Number'), name: "vatNumber", onInput: e => debouncedValidator(e.target.value), validate: () => validationErrors.vatNumber ?? true }), jsx(TextField, { showLabel: true, defaultValue: cart.poNumber, isDisabled: hasReturnedFromAdyen || isProcessing, label: t('PO Number'), name: "poNumber" }), paymentMethodOptions && (jsx(Select, { "data-test-selector": "paymentMethodSelect", defaultSelectedOption: cart.paymentOptions?.paymentMethods?.[0]?.name || 'ADY', isDisabled: (hasReturnedFromAdyen ||
175
175
  (cart.paymentOptions?.paymentMethods &&
176
176
  cart.paymentOptions.paymentMethods.length <= 1)) ??
177
177
  true, label: t('Payment method'), name: "paymentMethod", options: paymentMethodOptions, variant: "solid" })), cart.paymentMethod?.name !== 'PBI' &&
package/dist/exports.d.ts CHANGED
@@ -84,6 +84,7 @@ export * from './forms/input/input';
84
84
  export * from './forms/label/label';
85
85
  export * from './forms/number-field/number-field';
86
86
  export * from './forms/select/select';
87
+ export * from './forms/switch/switch';
87
88
  export * from './forms/text-field/text-field';
88
89
  export * from './forms/textarea/textarea';
89
90
  export * from './global-search/categories-grid/categories-grid';
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  export interface CheckboxProps {
3
3
  _pseudo?: 'none' | 'focus' | 'hover' | 'active';
4
- children: ReactNode;
4
+ children?: ReactNode;
5
5
  className?: string;
6
6
  'data-test-selector'?: string;
7
7
  isDisabled?: boolean;
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ export interface SwitchProps {
3
+ _pseudo?: 'none' | 'focus' | 'hover' | 'active';
4
+ children?: ReactNode;
5
+ className?: string;
6
+ 'data-test-selector'?: string;
7
+ isDisabled?: boolean;
8
+ isSelected?: boolean;
9
+ onChange?: (isSelected: boolean) => void;
10
+ value?: string;
11
+ }
12
+ export declare function Switch({ _pseudo, children, className, 'data-test-selector': dataTestSelector, isDisabled, isSelected, onChange, value, }: SwitchProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { Switch as Switch$1 } from 'react-aria-components';
4
+ import clsx from 'clsx';
5
+ import styles from './switch.module.css.js';
6
+
7
+ function Switch({ _pseudo = 'none', children, className, 'data-test-selector': dataTestSelector, isDisabled, isSelected, onChange, value, }) {
8
+ return (jsxs(Switch$1, { className: clsx(className, styles.switch, styles[_pseudo]), "data-test-selector": dataTestSelector, isDisabled: isDisabled, isSelected: isSelected, onChange: onChange, value: value, children: [jsx("div", { className: styles.indicator }), children] }));
9
+ }
10
+
11
+ export { Switch };
@@ -0,0 +1,3 @@
1
+ var styles = {"switch":"switch-module-ywpXc","indicator":"switch-module-2e1rG","focus":"switch-module-rRUh4","active":"switch-module-hSbOs"};
2
+
3
+ export { styles as default };
package/dist/index.js CHANGED
@@ -89,6 +89,7 @@ export { Input } from './forms/input/input.js';
89
89
  export { Label } from './forms/label/label.js';
90
90
  export { NumberField } from './forms/number-field/number-field.js';
91
91
  export { Select } from './forms/select/select.js';
92
+ export { Switch } from './forms/switch/switch.js';
92
93
  export { TextField } from './forms/text-field/text-field.js';
93
94
  export { TextArea } from './forms/textarea/textarea.js';
94
95
  export { CategoriesGrid } from './global-search/categories-grid/categories-grid.js';
@@ -41,7 +41,7 @@ function EditAddresses({ countries, isLoading, isPickup, onSubmit, }) {
41
41
  },
42
42
  notes: formData.get('notes')?.toString() || '',
43
43
  });
44
- }, children: [jsx(TextField, { isDisabled: isLoading, label: t('First name'), name: "firstName", showLabel: true }), jsx(TextField, { isDisabled: isLoading, isRequired: !companyName, label: t('Last name'), minLength: 3, name: "lastName", onChange: setLastName, showLabel: true, value: lastName }, `lastname-${Boolean(companyName)}`), jsx(TextField, { isDisabled: isLoading, label: t('Company name'), name: "companyName", onChange: setCompanyName, showLabel: true, value: companyName }), jsx(TextField, { isDisabled: isLoading, label: t('Attention'), name: "attention", showLabel: true }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isRequired: true, isDisabled: isLoading, label: `${t('Address')} 1`, maxLength: 30, minLength: 3, name: "address1", showLabel: true }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, label: `${t('Address')} 2`, maxLength: 30, minLength: 3, name: "address2", showLabel: true }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, label: `${t('Address')} 3`, maxLength: 30, minLength: 3, name: "address3", showLabel: true }) }), jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('Postal Code'), maxLength: 10, minLength: 4, name: "postalCode", showLabel: true }), jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('City'), maxLength: 30, minLength: 3, name: "city", showLabel: true }), jsx("div", { className: styles['span-2'], children: jsx(CountrySelect, { isRequired: true, countries: countries, name: "country" }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('Phone'), name: "phone", showLabel: true, validate: value => {
44
+ }, children: [jsx(TextField, { isDisabled: isLoading, label: t('First name'), name: "firstName", showLabel: true }), jsx(TextField, { isDisabled: isLoading, isRequired: !companyName, label: t('Last name'), minLength: 3, name: "lastName", onChange: setLastName, showLabel: true, value: lastName }, `lastname-${Boolean(companyName)}`), jsx(TextField, { isDisabled: isLoading, label: t('Company name'), name: "companyName", onChange: setCompanyName, showLabel: true, value: companyName }), jsx(TextField, { isDisabled: isLoading, label: t('Attention'), name: "attention", showLabel: true }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isRequired: true, isDisabled: isLoading, label: `${t('Address')} 1`, maxLength: 30, minLength: 3, name: "address1", showLabel: true }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, label: `${t('Address')} 2`, maxLength: 30, minLength: 3, name: "address2", showLabel: true }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, label: `${t('Address')} 3`, maxLength: 30, minLength: 3, name: "address3", showLabel: true }) }), jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('Postal Code'), maxLength: 10, minLength: 4, name: "postalCode", showLabel: true }), jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('City'), maxLength: 30, minLength: 3, name: "city", showLabel: true }), jsx("div", { className: styles['span-2'], children: jsx(CountrySelect, { isRequired: true, countries: countries, "data-test-selector": "countrySelect", name: "countrySelect" }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('Phone'), name: "phone", showLabel: true, validate: value => {
45
45
  if (!value)
46
46
  return value;
47
47
  return (validatePhone(value) || 'Vul een geldig telefoonnummer in');
@@ -49,7 +49,7 @@ function EditAddresses({ countries, isLoading, isPickup, onSubmit, }) {
49
49
  if (!value)
50
50
  return value;
51
51
  return validateEmail(value) || 'Vul een geldig emailadres in';
52
- } }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] }) }) }), jsx(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: jsx(CheckoutPageSectionContent, { children: jsx(Fragment, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs("div", { className: styles['use-invoice-checkbox'], children: [jsx(Checkbox, { isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), jsx(Tooltip, { text: t('Changing your address is currently not possible. Please contact customer support to change your address.') })] })) }) }) })] }));
52
+ } }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] }) }) }), jsx(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: jsx(CheckoutPageSectionContent, { children: jsx(Fragment, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs("div", { className: styles['use-invoice-checkbox'], children: [jsx(Checkbox, { "data-test-selector": "checkboxUseBillingAddress", isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), jsx(Tooltip, { text: t('Changing your address is currently not possible. Please contact customer support to change your address.') })] })) }) }) })] }));
53
53
  }
54
54
 
55
55
  export { EDIT_ADDRESS_FORM_ID, EditAddresses };
@@ -22,7 +22,7 @@ function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipT
22
22
  onSubmit({
23
23
  notes: formData.get('notes')?.toString() || '',
24
24
  });
25
- }, children: [jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: "Billing address" }), children: [jsx(CheckoutPageSectionLink, { children: jsxs(RouteLink, { color: "secondary", href: ACCOUNT_ADDRESSES_PATH, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit billing address" }), " >"] }) }), jsxs(CheckoutPageSectionContent, { children: [billTo && (jsx(Address, { address1: billTo.address1, address2: billTo.address2, address3: billTo.address3, city: billTo.city, companyName: billTo.companyName, country: billTo.country?.name, email: billTo.email, firstName: billTo.firstName, lastName: billTo.lastName, phone: billTo.phone, postalCode: billTo.postalCode })), jsx("div", { className: styles.notes, children: jsx(TextField, { defaultValue: notes, isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] })] }), jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: [!isPickup && (jsx(CheckoutPageSectionLink, { children: jsxs(RouteLink, { color: "secondary", href: ACCOUNT_ADDRESSES_PATH, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit shipping address" }), " >"] }) })), jsx(CheckoutPageSectionContent, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs(Fragment, { children: [jsx(Checkbox, { className: styles['use-invoice-checkbox'], isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), shipTo && (jsx(Address, { address1: shipTo.address1, address2: shipTo.address2, address3: shipTo.address3, city: shipTo.city, companyName: shipTo.companyName, country: shipTo.country?.name, email: shipTo.email, firstName: shipTo.firstName, lastName: shipTo.lastName, phone: shipTo.phone, postalCode: shipTo.postalCode }))] })) })] })] }));
25
+ }, children: [jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: "Billing address" }), children: [jsx(CheckoutPageSectionLink, { children: jsxs(RouteLink, { color: "secondary", href: ACCOUNT_ADDRESSES_PATH, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit billing address" }), " >"] }) }), jsxs(CheckoutPageSectionContent, { children: [billTo && (jsx(Address, { address1: billTo.address1, address2: billTo.address2, address3: billTo.address3, city: billTo.city, companyName: billTo.companyName, country: billTo.country?.name, email: billTo.email, firstName: billTo.firstName, lastName: billTo.lastName, phone: billTo.phone, postalCode: billTo.postalCode })), jsx("div", { className: styles.notes, children: jsx(TextField, { defaultValue: notes, isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] })] }), jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: [!isPickup && (jsx(CheckoutPageSectionLink, { children: jsxs(RouteLink, { color: "secondary", href: ACCOUNT_ADDRESSES_PATH, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit shipping address" }), " >"] }) })), jsx(CheckoutPageSectionContent, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs(Fragment, { children: [jsx(Checkbox, { className: styles['use-invoice-checkbox'], "data-test-selector": "checkboxUseBillingAddress", isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), shipTo && (jsx(Address, { address1: shipTo.address1, address2: shipTo.address2, address3: shipTo.address3, city: shipTo.city, companyName: shipTo.companyName, country: shipTo.country?.name, email: shipTo.email, firstName: shipTo.firstName, lastName: shipTo.lastName, phone: shipTo.phone, postalCode: shipTo.postalCode }))] })) })] })] }));
26
26
  }
27
27
 
28
28
  export { ReadOnlyAddresses };
package/dist/styles.css CHANGED
@@ -3882,11 +3882,10 @@ button.swiper-pagination-bullet {
3882
3882
  margin-bottom: var(--space-32);
3883
3883
  margin-left: calc(-1 * var(--breakout));
3884
3884
  background-color: var(--color-brand-light-gray);
3885
- font-weight: var(--font-weight-bold);
3886
3885
  }
3887
3886
  .cart-totals-module-Bk9zi .cart-totals-module-2RLLQ .cart-totals-module-ciNsz,
3888
3887
  .cart-totals-module-Bk9zi .cart-totals-module-2RLLQ .cart-totals-module-KaxpH {
3889
- font-weight: inherit;
3888
+ font-weight: var(--font-weight-bold);
3890
3889
  }
3891
3890
 
3892
3891
  .cart-totals-summary-module-iFaoy {
@@ -4194,6 +4193,87 @@ button.swiper-pagination-bullet {
4194
4193
  margin-inline: var(--space-4);
4195
4194
  }
4196
4195
 
4196
+ .switch-module-ywpXc {
4197
+ --pin-color: var(--color-white);
4198
+ --box-color: var(--color-brand-light-gray);
4199
+ --box-color-pressed: var(--color-brand-medium-gray);
4200
+ --selected-box-color: var(--color-brand-red);
4201
+ --selected-box-color-pressed: var(--color-brand-dark-red);
4202
+ --disabled-box-color: var(--color-brand-medium-gray);
4203
+ --disabled-selected-box-color: var(--color-brand-dark-gray);
4204
+
4205
+ display: flex;
4206
+ align-items: center;
4207
+ color: var(--color-brand-black);
4208
+ cursor: pointer;
4209
+ font-size: var(--font-size-14);
4210
+ forced-color-adjust: none;
4211
+ gap: 6px;
4212
+ }
4213
+
4214
+ .switch-module-ywpXc .switch-module-2e1rG {
4215
+ width: 44px;
4216
+ height: 24px;
4217
+ box-sizing: border-box;
4218
+ border-radius: 12px;
4219
+ background: var(--box-color);
4220
+ transition: all 200ms;
4221
+ }
4222
+
4223
+ .switch-module-ywpXc .switch-module-2e1rG::before {
4224
+ display: block;
4225
+ width: 20px;
4226
+ height: 20px;
4227
+ box-sizing: border-box;
4228
+ border: solid 0.5px rgb(0 0 0 / 4%);
4229
+ border-radius: 50%;
4230
+ margin: var(--space-2);
4231
+ background: var(--pin-color);
4232
+ box-shadow: 0 3px 1px 0 rgb(0 0 0 / 6%), 0 3px 8px 0 rgb(0 0 0 / 15%);
4233
+ content: '';
4234
+ transition: all 200ms;
4235
+ }
4236
+
4237
+ .switch-module-ywpXc[data-pressed] .switch-module-2e1rG {
4238
+ background: var(--box-color-pressed);
4239
+ }
4240
+
4241
+ .switch-module-ywpXc[data-disabled] {
4242
+ cursor: default;
4243
+ opacity: 0.4;
4244
+ }
4245
+
4246
+ .switch-module-ywpXc[data-disabled] .switch-module-2e1rG {
4247
+ background: var(--disabled-box-color);
4248
+ }
4249
+
4250
+ .switch-module-ywpXc[data-disabled] .switch-module-2e1rG::before {
4251
+ box-shadow: none;
4252
+ opacity: 0.4;
4253
+ }
4254
+
4255
+ .switch-module-ywpXc.switch-module-rRUh4 .switch-module-2e1rG, .switch-module-ywpXc.switch-module-hSbOs .switch-module-2e1rG, .switch-module-ywpXc[data-focus-visible] .switch-module-2e1rG {
4256
+ box-shadow: var(--shadow-focus-outline-padded);
4257
+ outline: 2px solid var(--color-brand-white);
4258
+ outline-offset: 0;
4259
+ }
4260
+
4261
+ .switch-module-ywpXc[data-selected] .switch-module-2e1rG {
4262
+ background: var(--selected-box-color);
4263
+ }
4264
+
4265
+ .switch-module-ywpXc[data-selected] .switch-module-2e1rG::before {
4266
+ transform: translateX(100%);
4267
+ }
4268
+
4269
+ .switch-module-ywpXc[data-selected][data-pressed] .switch-module-2e1rG {
4270
+ background: var(--selected-box-color-pressed);
4271
+ }
4272
+
4273
+ .switch-module-ywpXc[data-selected][data-disabled] .switch-module-2e1rG {
4274
+ background: var(--disabled-selected-box-color);
4275
+ }
4276
+
4197
4277
  .categories-grid-module-C751R {
4198
4278
  --amount-of-columns: 2;
4199
4279
  --border: 1px solid var(--color-brand-light-gray);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "130.0.0",
3
+ "version": "131.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -19,7 +19,8 @@
19
19
  "main": "dist/index.js",
20
20
  "types": "./dist/index.d.ts",
21
21
  "scripts": {
22
- "build": "pnpm generate:exports:save && rollup --config",
22
+ "build": "rollup --config",
23
+ "build:export": "pnpm generate:exports:save && rollup --config",
23
24
  "rebuild": "rm -rf dist && pnpm run build",
24
25
  "build-storybook": "storybook build",
25
26
  "check-updates": "npx npm-check-updates",