@wix/site-ui 1.83.0 → 1.85.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.
@@ -0,0 +1,124 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Select, Select_module } from "../Select/index.js";
3
+ import { FieldRoot_FieldRoot, FieldError_FieldError, FieldDescription_FieldDescription } from "../8972.js";
4
+ import * as __rspack_external_react from "react";
5
+ const DEFAULT_ICON = '▾';
6
+ const isDivider = (item)=>'divider' in item;
7
+ const isGroup = (item)=>'groupLabel' in item;
8
+ function renderOption(option) {
9
+ const { value, label, disabled, icon, description, suffix } = option;
10
+ const text = label ?? value;
11
+ const isRich = null != icon || null != description || null != suffix;
12
+ return /*#__PURE__*/ jsx(Select.Item, {
13
+ value: value,
14
+ disabled: disabled,
15
+ children: isRich ? /*#__PURE__*/ jsxs(Fragment, {
16
+ children: [
17
+ null != icon ? /*#__PURE__*/ jsx("span", {
18
+ className: Select_module.itemIcon,
19
+ "aria-hidden": "true",
20
+ children: icon
21
+ }) : null,
22
+ /*#__PURE__*/ jsxs("div", {
23
+ className: Select_module.itemContent,
24
+ children: [
25
+ /*#__PURE__*/ jsx(Select.ItemText, {
26
+ children: text
27
+ }),
28
+ null != description ? /*#__PURE__*/ jsx("div", {
29
+ className: Select_module.itemDescription,
30
+ children: description
31
+ }) : null
32
+ ]
33
+ }),
34
+ null != suffix ? /*#__PURE__*/ jsx("span", {
35
+ className: Select_module.itemSuffix,
36
+ children: suffix
37
+ }) : null
38
+ ]
39
+ }) : /*#__PURE__*/ jsx(Select.ItemText, {
40
+ children: text
41
+ })
42
+ }, value);
43
+ }
44
+ const SelectField = /*#__PURE__*/ __rspack_external_react.forwardRef(({ options, label, 'aria-label': ariaLabel, placeholder, description, error, variant = 'floating', alignment = 'start', invalid = false, loading = false, required = false, disabled = false, readOnly, icon = DEFAULT_ICON, outerBorder = false, sideOffset = 4, dir, triggerClassName, popupClassName, ...rootProps }, ref)=>/*#__PURE__*/ jsx(FieldRoot_FieldRoot, {
45
+ className: Select_module.root,
46
+ invalid: invalid,
47
+ disabled: disabled,
48
+ children: /*#__PURE__*/ jsxs(Select.Root, {
49
+ readOnly: readOnly || loading,
50
+ required: required,
51
+ disabled: disabled,
52
+ ...rootProps,
53
+ children: [
54
+ null != label ? /*#__PURE__*/ jsxs(Select.Label, {
55
+ children: [
56
+ label,
57
+ required ? /*#__PURE__*/ jsx("span", {
58
+ className: Select_module.requiredMarker,
59
+ "aria-hidden": "true",
60
+ children: "*"
61
+ }) : null
62
+ ]
63
+ }) : null,
64
+ /*#__PURE__*/ jsxs(Select.Trigger, {
65
+ ref: ref,
66
+ dir: dir,
67
+ "aria-label": null == label ? ariaLabel : void 0,
68
+ "aria-busy": loading || void 0,
69
+ "data-variant": variant,
70
+ "data-alignment": alignment,
71
+ "data-loading": loading ? '' : void 0,
72
+ className: triggerClassName,
73
+ children: [
74
+ /*#__PURE__*/ jsx(Select.Value, {
75
+ placeholder: placeholder
76
+ }),
77
+ loading ? /*#__PURE__*/ jsx("span", {
78
+ className: Select_module.loadingIndicator,
79
+ "aria-hidden": "true"
80
+ }) : /*#__PURE__*/ jsx(Select.Icon, {
81
+ children: icon
82
+ })
83
+ ]
84
+ }),
85
+ null != error ? /*#__PURE__*/ jsx(FieldError_FieldError, {
86
+ className: Select_module.error,
87
+ match: invalid,
88
+ children: error
89
+ }) : null,
90
+ null != description ? /*#__PURE__*/ jsx(FieldDescription_FieldDescription, {
91
+ className: Select_module.description,
92
+ children: description
93
+ }) : null,
94
+ /*#__PURE__*/ jsx(Select.Portal, {
95
+ children: /*#__PURE__*/ jsx(Select.Positioner, {
96
+ alignItemWithTrigger: false,
97
+ sideOffset: sideOffset,
98
+ children: /*#__PURE__*/ jsx(Select.Popup, {
99
+ dir: dir,
100
+ "data-variant": variant,
101
+ "data-outer-border": outerBorder ? '' : void 0,
102
+ className: popupClassName,
103
+ children: /*#__PURE__*/ jsx(Select.List, {
104
+ children: options.map((item, index)=>{
105
+ if (isDivider(item)) return /*#__PURE__*/ jsx(Select.Separator, {}, `divider-${index}`);
106
+ if (isGroup(item)) return /*#__PURE__*/ jsxs(Select.Group, {
107
+ children: [
108
+ /*#__PURE__*/ jsx(Select.GroupLabel, {
109
+ children: item.groupLabel
110
+ }),
111
+ item.options.map(renderOption)
112
+ ]
113
+ }, `group-${index}`);
114
+ return renderOption(item);
115
+ })
116
+ })
117
+ })
118
+ })
119
+ })
120
+ ]
121
+ })
122
+ }));
123
+ SelectField.displayName = 'SelectField';
124
+ export { SelectField };
package/dist/index.d.ts CHANGED
@@ -8574,6 +8574,8 @@ declare function Root_4<Value>({ className, size, style, ...props }: RootProps<V
8574
8574
 
8575
8575
  declare function Root_5<Value extends number | ReadonlyArray<number>>({ className, size, style, ...props }: RootProps_2<Value>): JSX_2.Element;
8576
8576
 
8577
+ declare type RootOwnProps = Omit<React_2.ComponentProps<typeof Select.Root>, 'children'>;
8578
+
8577
8579
  declare type RootProps<Value> = WithStringClassName<Radio_2.Root.Props<Value>> & {
8578
8580
  size?: number;
8579
8581
  };
@@ -8782,6 +8784,7 @@ export declare interface ScrollAreaViewportState extends ScrollAreaRootState {}
8782
8784
  declare const scrub: "scrub";
8783
8785
 
8784
8786
  export declare const Select: {
8787
+ Root: typeof Select_2.Root;
8785
8788
  Label: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<SelectLabelProps_2, "ref"> & React_2.RefAttributes<HTMLDivElement>, "ref">, "className"> & {
8786
8789
  className?: string | undefined;
8787
8790
  } & React_2.RefAttributes<HTMLDivElement>>;
@@ -8794,6 +8797,7 @@ export declare const Select: {
8794
8797
  Icon: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<SelectIconProps_2, "ref"> & React_2.RefAttributes<HTMLSpanElement>, "ref">, "className"> & {
8795
8798
  className?: string | undefined;
8796
8799
  } & React_2.RefAttributes<HTMLSpanElement>>;
8800
+ Portal: React_2.ForwardRefExoticComponent<Omit<SelectPortalProps_2, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
8797
8801
  Backdrop: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<SelectBackdropProps_2, "ref"> & React_2.RefAttributes<HTMLDivElement>, "ref">, "className"> & {
8798
8802
  className?: string | undefined;
8799
8803
  } & React_2.RefAttributes<HTMLDivElement>>;
@@ -8830,9 +8834,9 @@ export declare const Select: {
8830
8834
  GroupLabel: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<SelectGroupLabelProps_2, "ref"> & React_2.RefAttributes<HTMLDivElement>, "ref">, "className"> & {
8831
8835
  className?: string | undefined;
8832
8836
  } & React_2.RefAttributes<HTMLDivElement>>;
8833
- Root: typeof Select_2.Root;
8834
- Portal: React_2.ForwardRefExoticComponent<Omit<SelectPortalProps_2, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
8835
- Separator: React_2.ForwardRefExoticComponent<Omit<SeparatorProps_2, "ref"> & React_2.RefAttributes<HTMLDivElement>>;
8837
+ Separator: React_2.ForwardRefExoticComponent<Omit<Omit<Omit<SeparatorProps_2, "ref"> & React_2.RefAttributes<HTMLDivElement>, "ref">, "className"> & {
8838
+ className?: string | undefined;
8839
+ } & React_2.RefAttributes<HTMLDivElement>>;
8836
8840
  };
8837
8841
 
8838
8842
  export declare namespace Select_2 {
@@ -8919,6 +8923,120 @@ export declare interface SelectBackdropState {
8919
8923
  transitionStatus: TransitionStatus;
8920
8924
  }
8921
8925
 
8926
+ /**
8927
+ * Composite, data-driven dropdown built on the `Select` atoms.
8928
+ *
8929
+ * Unlike `Select`, which exposes each part for fully custom composition,
8930
+ * `SelectField` renders the full label → trigger → popup → list tree from a
8931
+ * single `options` prop, mirroring the wix-ui-tpa `Dropdown` API.
8932
+ */
8933
+ export declare const SelectField: React_2.ForwardRefExoticComponent<RootOwnProps & {
8934
+ /** The options, dividers, and groups to render in the popup. */
8935
+ options: Array<SelectFieldItem>;
8936
+ /** Accessible label rendered above the trigger. */
8937
+ label?: React_2.ReactNode;
8938
+ /** Accessible label for the trigger when no visible `label` is provided. */
8939
+ 'aria-label'?: string | undefined;
8940
+ /** Text shown in the trigger when nothing is selected. */
8941
+ placeholder?: string | undefined;
8942
+ /** Always-visible helper text rendered below the trigger. */
8943
+ description?: React_2.ReactNode;
8944
+ /** Error message rendered below the trigger when the field is invalid. */
8945
+ error?: React_2.ReactNode;
8946
+ /** Visual style of the trigger. */
8947
+ variant?: SelectFieldVariant | undefined;
8948
+ /** Horizontal alignment of the trigger value. */
8949
+ alignment?: SelectFieldAlignment | undefined;
8950
+ /** Marks the field invalid, styling the trigger and revealing `error`. */
8951
+ invalid?: boolean | undefined;
8952
+ /** Shows a spinner in place of the icon and blocks interaction. */
8953
+ loading?: boolean | undefined;
8954
+ /** Trigger icon. Defaults to a chevron; replaced by a spinner while loading. */
8955
+ icon?: React_2.ReactNode;
8956
+ /** Draws a border around the popup. */
8957
+ outerBorder?: boolean | undefined;
8958
+ /** Gap in pixels between the trigger and the popup. */
8959
+ sideOffset?: number | undefined;
8960
+ /**
8961
+ * Text direction. Forwarded to both the trigger and the portaled popup so the
8962
+ * popup lays out correctly even though it renders outside the field's subtree.
8963
+ */
8964
+ dir?: "ltr" | "rtl" | undefined;
8965
+ /** Class applied to the trigger button. */
8966
+ triggerClassName?: string | undefined;
8967
+ /** Class applied to the popup. */
8968
+ popupClassName?: string | undefined;
8969
+ } & React_2.RefAttributes<HTMLButtonElement>>;
8970
+
8971
+ export declare type SelectFieldAlignment = 'start' | 'center';
8972
+
8973
+ /** A visual divider between options. */
8974
+ export declare type SelectFieldDivider = {
8975
+ divider: true;
8976
+ };
8977
+
8978
+ /** A labelled group of options rendered under a {@link Select.GroupLabel}. */
8979
+ export declare type SelectFieldGroup = {
8980
+ groupLabel: React_2.ReactNode;
8981
+ options: Array<SelectFieldOption>;
8982
+ };
8983
+
8984
+ export declare type SelectFieldItem = SelectFieldOption | SelectFieldDivider | SelectFieldGroup;
8985
+
8986
+ /**
8987
+ * A single selectable option rendered inside the {@link SelectField} popup.
8988
+ * `label` defaults to `value` when omitted. `icon`, `description`, and `suffix`
8989
+ * opt the row into the rich layout (leading icon, secondary line, trailing slot).
8990
+ */
8991
+ export declare type SelectFieldOption = {
8992
+ value: string;
8993
+ label?: React_2.ReactNode;
8994
+ disabled?: boolean;
8995
+ icon?: React_2.ReactNode;
8996
+ description?: React_2.ReactNode;
8997
+ suffix?: React_2.ReactNode;
8998
+ };
8999
+
9000
+ export declare type SelectFieldProps = RootOwnProps & {
9001
+ /** The options, dividers, and groups to render in the popup. */
9002
+ options: Array<SelectFieldItem>;
9003
+ /** Accessible label rendered above the trigger. */
9004
+ label?: React_2.ReactNode;
9005
+ /** Accessible label for the trigger when no visible `label` is provided. */
9006
+ 'aria-label'?: string;
9007
+ /** Text shown in the trigger when nothing is selected. */
9008
+ placeholder?: string;
9009
+ /** Always-visible helper text rendered below the trigger. */
9010
+ description?: React_2.ReactNode;
9011
+ /** Error message rendered below the trigger when the field is invalid. */
9012
+ error?: React_2.ReactNode;
9013
+ /** Visual style of the trigger. */
9014
+ variant?: SelectFieldVariant;
9015
+ /** Horizontal alignment of the trigger value. */
9016
+ alignment?: SelectFieldAlignment;
9017
+ /** Marks the field invalid, styling the trigger and revealing `error`. */
9018
+ invalid?: boolean;
9019
+ /** Shows a spinner in place of the icon and blocks interaction. */
9020
+ loading?: boolean;
9021
+ /** Trigger icon. Defaults to a chevron; replaced by a spinner while loading. */
9022
+ icon?: React_2.ReactNode;
9023
+ /** Draws a border around the popup. */
9024
+ outerBorder?: boolean;
9025
+ /** Gap in pixels between the trigger and the popup. */
9026
+ sideOffset?: number;
9027
+ /**
9028
+ * Text direction. Forwarded to both the trigger and the portaled popup so the
9029
+ * popup lays out correctly even though it renders outside the field's subtree.
9030
+ */
9031
+ dir?: 'ltr' | 'rtl';
9032
+ /** Class applied to the trigger button. */
9033
+ triggerClassName?: string;
9034
+ /** Class applied to the popup. */
9035
+ popupClassName?: string;
9036
+ };
9037
+
9038
+ export declare type SelectFieldVariant = 'floating' | 'box' | 'line';
9039
+
8922
9040
  /**
8923
9041
  * Groups related select items with the corresponding label.
8924
9042
  * Renders a `<div>` element.
package/dist/index.js CHANGED
@@ -29,6 +29,7 @@ export { Radio, RadioSize } from "./Radio/index.js";
29
29
  export { RadioGroup } from "./RadioGroup/index.js";
30
30
  export { ScrollArea } from "./ScrollArea/index.js";
31
31
  export { Select } from "./Select/index.js";
32
+ export { SelectField } from "./SelectField/index.js";
32
33
  export { Separator } from "./Separator/index.js";
33
34
  export { Slider, SliderSize } from "./Slider/index.js";
34
35
  export { Switch, SwitchSize } from "./Switch/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/site-ui",
3
- "version": "1.83.0",
3
+ "version": "1.85.0",
4
4
  "description": "Pure UI components for the Wix site builder",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,6 +29,7 @@
29
29
  "check:lint-and-format": "yarn run -T concurrently yarn:lint yarn:format:check",
30
30
  "test:visual": "test-storybook --url http://localhost:6006",
31
31
  "test:visual:update": "test-storybook --url http://localhost:6006 --updateSnapshot",
32
+ "tpa:coverage": "node scripts/tpa-coverage.mjs",
32
33
  "verify:component": "node scripts/verify-component-status.mjs",
33
34
  "verify:visual": "node scripts/visual-review-component.mjs",
34
35
  "tsc": "tsc -b ./tsconfig.json --force",
@@ -37,7 +38,7 @@
37
38
  "build-storybook": "NODE_OPTIONS=--max-old-space-size=8192 storybook build"
38
39
  },
39
40
  "dependencies": {
40
- "@wix/wix-ui-icons-common": "^3.114.0",
41
+ "@wix/wix-ui-icons-common": "^3.173.0",
41
42
  "clsx": "2.0.0"
42
43
  },
43
44
  "peerDependencies": {
@@ -94,5 +95,5 @@
94
95
  "registry": "https://registry.npmjs.org/",
95
96
  "access": "public"
96
97
  },
97
- "falconPackageHash": "3a309112efa840c5f4adcf6ae31501fc60a3f71247490debd3b674eb"
98
+ "falconPackageHash": "d0c650c8061789b98b5add0bff6db0e4df6f06baffcc4ac6792b4065"
98
99
  }