@nexus-cross/design-system 1.0.11 → 1.0.13

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.
@@ -31,7 +31,8 @@ var toggleGroupVariants = classVarianceAuthority.cva("nexus-toggle-group", {
31
31
  variants: {
32
32
  variant: {
33
33
  default: "nexus-toggle-group--default",
34
- outline: "nexus-toggle-group--outline"
34
+ primary: "nexus-toggle-group--primary",
35
+ secondary: "nexus-toggle-group--secondary"
35
36
  },
36
37
  size: {
37
38
  sm: "nexus-toggle-group--sm",
@@ -45,7 +46,7 @@ var toggleGroupVariants = classVarianceAuthority.cva("nexus-toggle-group", {
45
46
  }
46
47
  });
47
48
  var ToggleGroup = React__namespace.forwardRef(
48
- ({ className, variant, size, items, disabled, ...props }, ref) => {
49
+ ({ className, variant, size, items, disabled, required = true, ...props }, ref) => {
49
50
  const rootRef = React__namespace.useRef(null);
50
51
  const [animated, setAnimated] = React__namespace.useState(false);
51
52
  const [pos, setPos] = React__namespace.useState(null);
@@ -62,10 +63,9 @@ var ToggleGroup = React__namespace.forwardRef(
62
63
  React__namespace.useEffect(() => {
63
64
  if (currentValue !== void 0) setTrackedValue(currentValue);
64
65
  }, [currentValue]);
65
- const isDefault = variant !== "outline";
66
66
  React__namespace.useLayoutEffect(() => {
67
67
  const root = rootRef.current;
68
- if (!root || !isDefault) return;
68
+ if (!root) return;
69
69
  const activeVal = Array.isArray(trackedValue) ? trackedValue[0] : trackedValue;
70
70
  if (!activeVal) {
71
71
  setPos(null);
@@ -89,7 +89,7 @@ var ToggleGroup = React__namespace.forwardRef(
89
89
  x: elRect.left - rootRect.left,
90
90
  y: elRect.top - rootRect.top
91
91
  });
92
- }, [trackedValue, items, isDefault]);
92
+ }, [trackedValue, items]);
93
93
  React__namespace.useEffect(() => {
94
94
  const frame = requestAnimationFrame(() => {
95
95
  requestAnimationFrame(() => setAnimated(true));
@@ -98,21 +98,23 @@ var ToggleGroup = React__namespace.forwardRef(
98
98
  }, []);
99
99
  const handleSingleChange = React__namespace.useCallback(
100
100
  (val) => {
101
+ if (required && !val) return;
101
102
  setTrackedValue(val);
102
103
  if (props.type !== "multiple") {
103
104
  props.onValueChange?.(val);
104
105
  }
105
106
  },
106
- [props.type, props.onValueChange]
107
+ [props.type, props.onValueChange, required]
107
108
  );
108
109
  const handleMultipleChange = React__namespace.useCallback(
109
110
  (val) => {
111
+ if (required && val.length === 0) return;
110
112
  setTrackedValue(val);
111
113
  if (props.type === "multiple") {
112
114
  props.onValueChange?.(val);
113
115
  }
114
116
  },
115
- [props.type, props.onValueChange]
117
+ [props.type, props.onValueChange, required]
116
118
  );
117
119
  const rootProps = props.type === "multiple" ? {
118
120
  type: "multiple",
@@ -139,7 +141,7 @@ var ToggleGroup = React__namespace.forwardRef(
139
141
  disabled,
140
142
  ...rootProps,
141
143
  children: [
142
- isDefault && /* @__PURE__ */ jsxRuntime.jsx(
144
+ /* @__PURE__ */ jsxRuntime.jsx(
143
145
  "span",
144
146
  {
145
147
  className: chunkCZC76ZD5_js.cn(
@@ -155,7 +157,7 @@ var ToggleGroup = React__namespace.forwardRef(
155
157
  {
156
158
  value: item.value,
157
159
  disabled: item.disabled,
158
- className: "nexus-toggle-group__item",
160
+ className: chunkCZC76ZD5_js.cn("nexus-toggle-group__item", item.className),
159
161
  children: [
160
162
  item.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nexus-toggle-group__icon", children: item.icon }),
161
163
  item.label && /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.label })
@@ -193,15 +193,15 @@ var ImageUpload = React__namespace.forwardRef(
193
193
  !hasField && className
194
194
  ),
195
195
  children: [
196
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nexus-image-upload__preview-wrapper", children: [
197
- /* @__PURE__ */ jsxRuntime.jsx(
196
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nexus-image-upload__preview-area", children: [
197
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nexus-image-upload__preview-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(
198
198
  "img",
199
199
  {
200
200
  src: preview,
201
201
  alt: "Uploaded preview",
202
202
  className: "nexus-image-upload__preview"
203
203
  }
204
- ),
204
+ ) }),
205
205
  !disabled && /* @__PURE__ */ jsxRuntime.jsx(
206
206
  "button",
207
207
  {