@choice-ui/react 2.0.0 → 2.0.2

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.
Files changed (53) hide show
  1. package/dist/components/button/dist/index.d.ts +2 -9
  2. package/dist/components/button/dist/index.js +45 -19
  3. package/dist/components/checkbox/dist/index.d.ts +10 -1
  4. package/dist/components/checkbox/dist/index.js +49 -5
  5. package/dist/components/code-block/dist/index.d.ts +11 -14
  6. package/dist/components/code-block/dist/index.js +120 -93
  7. package/dist/components/colors/dist/index.d.ts +39 -6
  8. package/dist/components/colors/src/color-image-paint/color-image-paint.js +2 -2
  9. package/dist/components/dropdown/dist/index.d.ts +6 -0
  10. package/dist/components/dropdown/dist/index.js +20 -10
  11. package/dist/components/emoji-picker/dist/index.d.ts +30 -1
  12. package/dist/components/emoji-picker/dist/index.js +148 -44
  13. package/dist/components/form/src/adapters/range-adapter.js +2 -2
  14. package/dist/components/icon-button/dist/index.d.ts +1 -1
  15. package/dist/components/icon-button/dist/index.js +39 -0
  16. package/dist/components/list/dist/index.d.ts +1 -1
  17. package/dist/components/md-render/dist/index.d.ts +2 -1
  18. package/dist/components/md-render/dist/index.js +5 -9
  19. package/dist/components/md-render/src/components/markdown-block.d.ts +3 -0
  20. package/dist/components/md-render/src/md-render.js +4 -0
  21. package/dist/components/md-render/src/types.d.ts +3 -0
  22. package/dist/components/menus/dist/index.d.ts +5 -0
  23. package/dist/components/menus/dist/index.js +32 -3
  24. package/dist/components/modal/dist/index.js +2 -2
  25. package/dist/components/notifications/dist/index.d.ts +1 -5
  26. package/dist/components/numeric-input/dist/index.d.ts +27 -10
  27. package/dist/components/numeric-input/dist/index.js +132 -34
  28. package/dist/components/numeric-input/src/hooks/use-input-interactions.d.ts +3 -1
  29. package/dist/components/numeric-input/src/hooks/use-input-interactions.js +7 -3
  30. package/dist/components/numeric-input/src/hooks/use-numeric-input.js +15 -4
  31. package/dist/components/numeric-input/src/numeric-input.js +5 -4
  32. package/dist/components/numeric-input/src/utils/value-comparator.js +1 -5
  33. package/dist/components/panel/dist/index.d.ts +16 -16
  34. package/dist/components/picture-preview/dist/index.d.ts +5 -0
  35. package/dist/components/picture-preview/dist/index.js +287 -140
  36. package/dist/components/popover/dist/index.d.ts +5 -0
  37. package/dist/components/popover/dist/index.js +21 -2
  38. package/dist/components/radio/dist/index.d.ts +9 -1
  39. package/dist/components/radio/dist/index.js +50 -6
  40. package/dist/components/range/dist/index.d.ts +276 -20
  41. package/dist/components/range/dist/index.js +1030 -602
  42. package/dist/components/scroll-area/dist/index.d.ts +4 -27
  43. package/dist/components/scroll-area/dist/index.js +96 -123
  44. package/dist/components/separator/dist/index.d.ts +1 -8
  45. package/dist/components/splitter/dist/index.d.ts +1 -1
  46. package/dist/components/text-field/dist/index.d.ts +2 -3
  47. package/dist/components/text-field/dist/index.js +4 -19
  48. package/dist/components/textarea/dist/index.js +3 -1
  49. package/dist/components/toast/dist/index.d.ts +274 -0
  50. package/dist/components/tooltip/dist/index.d.ts +2 -0
  51. package/dist/components/tooltip/dist/index.js +23 -5
  52. package/dist/components/virtual-select/dist/index.d.ts +48 -0
  53. package/package.json +3 -3
@@ -1,6 +1,13 @@
1
1
  import { HTMLProps, ReactNode } from 'react';
2
2
  import * as react from 'react';
3
3
 
4
+ interface RadioIconProps extends Omit<HTMLProps<HTMLDivElement>, "children"> {
5
+ children?: ReactNode | ((props: {
6
+ value?: boolean;
7
+ }) => ReactNode);
8
+ }
9
+ declare const RadioIcon: react.MemoExoticComponent<react.ForwardRefExoticComponent<Omit<RadioIconProps, "ref"> & react.RefAttributes<HTMLDivElement>>>;
10
+
4
11
  interface RadioLabelProps extends Omit<HTMLProps<HTMLLabelElement>, "htmlFor" | "id" | "disabled"> {
5
12
  children: ReactNode;
6
13
  }
@@ -19,6 +26,7 @@ interface RadioType {
19
26
  (props: RadioProps & {
20
27
  ref?: React.Ref<HTMLInputElement>;
21
28
  }): JSX.Element;
29
+ Icon: typeof RadioIcon;
22
30
  Label: typeof RadioLabel;
23
31
  displayName?: string;
24
32
  }
@@ -50,4 +58,4 @@ interface RadioGroupType {
50
58
  }
51
59
  declare const RadioGroup: RadioGroupType;
52
60
 
53
- export { Radio, RadioGroup, type RadioGroupProps, type RadioProps };
61
+ export { Radio, RadioGroup, type RadioGroupProps, type RadioIconProps, type RadioLabelProps, type RadioProps };
@@ -1,5 +1,5 @@
1
1
  import { Dot } from "@choiceform/icons-react";
2
- import { memo, forwardRef, useId, useMemo, createContext, useContext } from "react";
2
+ import { memo, forwardRef, useId, useMemo, createContext, useContext, Children, isValidElement } from "react";
3
3
  import { useEventCallback } from "usehooks-ts";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { tcx, tcv } from "../../../shared/utils/tcx/tcx.js";
@@ -145,6 +145,38 @@ var radioTv = tcv({
145
145
  focused: false
146
146
  }
147
147
  });
148
+ var RadioIcon = memo(
149
+ forwardRef(function RadioIcon2(props, ref) {
150
+ const { className, children, ...rest } = props;
151
+ const { value, disabled, variant } = useRadioContext();
152
+ const tv = radioTv({
153
+ type: "radio",
154
+ variant,
155
+ disabled,
156
+ checked: value
157
+ });
158
+ const renderIcon = () => {
159
+ if (typeof children === "function") {
160
+ return children({ value });
161
+ }
162
+ if (children !== void 0) {
163
+ return children;
164
+ }
165
+ return value ? /* @__PURE__ */ jsx(Dot, {}) : null;
166
+ };
167
+ return /* @__PURE__ */ jsx(
168
+ "div",
169
+ {
170
+ ref,
171
+ className: tcx(tv.box(), className),
172
+ "data-active": value,
173
+ ...rest,
174
+ children: renderIcon()
175
+ }
176
+ );
177
+ })
178
+ );
179
+ RadioIcon.displayName = "Radio.Icon";
148
180
  var RadioLabel = memo(
149
181
  forwardRef(function RadioLabel2(props, ref) {
150
182
  const { children, className, ...rest } = props;
@@ -201,13 +233,24 @@ var RadioBase = forwardRef(function Radio(props, ref) {
201
233
  }
202
234
  onKeyDown == null ? void 0 : onKeyDown(e);
203
235
  });
236
+ const isIconElement = (child) => {
237
+ var _a;
238
+ return isValidElement(child) && (child.type === RadioIcon || ((_a = child.type) == null ? void 0 : _a.displayName) === "Radio.Icon");
239
+ };
240
+ const childArray = Children.toArray(children);
241
+ const iconChild = childArray.find(isIconElement);
242
+ const otherChildren = childArray.filter((child) => !isIconElement(child));
204
243
  const renderChildren = () => {
205
- if (typeof children === "string" || typeof children === "number") {
206
- return /* @__PURE__ */ jsx(RadioLabel, { children });
244
+ if (otherChildren.length === 1) {
245
+ const child = otherChildren[0];
246
+ if (typeof child === "string" || typeof child === "number") {
247
+ return /* @__PURE__ */ jsx(RadioLabel, { children: child });
248
+ }
207
249
  }
208
- return children;
250
+ return otherChildren;
209
251
  };
210
- return /* @__PURE__ */ jsx(RadioContext.Provider, { value: { id, descriptionId, disabled }, children: /* @__PURE__ */ jsxs("div", { className: tcx(tv.root(), className), children: [
252
+ const renderDefaultIcon = () => /* @__PURE__ */ jsx("div", { className: tv.box(), children: value && /* @__PURE__ */ jsx(Dot, {}) });
253
+ return /* @__PURE__ */ jsx(RadioContext.Provider, { value: { id, descriptionId, disabled, value, variant }, children: /* @__PURE__ */ jsxs("div", { className: tcx(tv.root(), className), children: [
211
254
  /* @__PURE__ */ jsxs("div", { className: "pointer-events-none relative", children: [
212
255
  /* @__PURE__ */ jsx(
213
256
  "input",
@@ -229,13 +272,14 @@ var RadioBase = forwardRef(function Radio(props, ref) {
229
272
  ...rest
230
273
  }
231
274
  ),
232
- /* @__PURE__ */ jsx("div", { className: tv.box(), children: value && /* @__PURE__ */ jsx(Dot, {}) })
275
+ iconChild ?? renderDefaultIcon()
233
276
  ] }),
234
277
  renderChildren()
235
278
  ] }) });
236
279
  });
237
280
  var MemoizedRadio = memo(RadioBase);
238
281
  var Radio2 = MemoizedRadio;
282
+ Radio2.Icon = RadioIcon;
239
283
  Radio2.Label = RadioLabel;
240
284
  Radio2.displayName = "Radio";
241
285
  var RadioGroupItem = memo(
@@ -1,10 +1,60 @@
1
- import { default as React } from 'react';
1
+ import { default as React__default } from 'react';
2
+ import * as React$1 from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import * as tailwind_variants from 'tailwind-variants';
5
+
6
+ interface RangeConnectsProps {
7
+ className?: string;
8
+ }
9
+ declare const RangeConnects: React$1.ForwardRefExoticComponent<RangeConnectsProps & React$1.RefAttributes<HTMLDivElement>>;
10
+ interface RangeContainerProps extends React.HTMLAttributes<HTMLDivElement> {
11
+ children?: React.ReactNode;
12
+ className?: string;
13
+ height?: number;
14
+ }
15
+ declare function RangeContainer(props: RangeContainerProps): react_jsx_runtime.JSX.Element;
16
+ declare namespace RangeContainer {
17
+ var displayName: string;
18
+ }
19
+ interface RangeTupleConnectsProps extends React.HTMLAttributes<HTMLDivElement> {
20
+ className?: string;
21
+ }
22
+ declare const RangeTupleConnects: React$1.ForwardRefExoticComponent<RangeTupleConnectsProps & React$1.RefAttributes<HTMLDivElement>>;
23
+ interface RangeTupleContainerProps extends React.HTMLAttributes<HTMLDivElement> {
24
+ children?: React.ReactNode;
25
+ className?: string;
26
+ height?: number;
27
+ }
28
+ declare function RangeTupleContainer(props: RangeTupleContainerProps): react_jsx_runtime.JSX.Element;
29
+ declare namespace RangeTupleContainer {
30
+ var displayName: string;
31
+ }
32
+
33
+ interface RangeThumbProps {
34
+ className?: string;
35
+ size?: number;
36
+ }
37
+ declare const RangeThumb: React__default.ForwardRefExoticComponent<RangeThumbProps & React__default.RefAttributes<HTMLDivElement>>;
38
+ type ThumbIndex$1 = 0 | 1;
39
+ interface RangeTupleThumbProps {
40
+ className?: string;
41
+ size?: number;
42
+ index: ThumbIndex$1;
43
+ }
44
+ declare const RangeTupleThumb: React__default.ForwardRefExoticComponent<RangeTupleThumbProps & React__default.RefAttributes<HTMLDivElement>>;
45
+
46
+ interface RangeDotProps extends React.HTMLAttributes<HTMLDivElement> {
47
+ className?: string;
48
+ }
49
+ interface RangeTupleDotProps extends React.HTMLAttributes<HTMLDivElement> {
50
+ className?: string;
51
+ }
52
+ declare const RangeDot: React$1.ForwardRefExoticComponent<RangeDotProps & React$1.RefAttributes<HTMLDivElement>>;
53
+ declare const RangeTupleDot: React$1.ForwardRefExoticComponent<RangeTupleDotProps & React$1.RefAttributes<HTMLDivElement>>;
54
+
2
55
  interface RangeProps {
56
+ children?: React__default.ReactNode;
3
57
  className?: string;
4
- connectsClassName?: {
5
- negative?: string;
6
- positive?: string;
7
- };
8
58
  defaultValue?: number;
9
59
  disabled?: boolean;
10
60
  max?: number;
@@ -15,20 +65,24 @@ interface RangeProps {
15
65
  readOnly?: boolean;
16
66
  step?: number;
17
67
  thumbSize?: number;
18
- trackSize?: {
19
- height?: number;
20
- width?: number | "auto";
21
- };
22
68
  value?: number;
69
+ /**
70
+ * Width of the range track in pixels.
71
+ * If not provided (undefined), the width will be auto-calculated from the container.
72
+ */
73
+ width?: number | boolean;
74
+ }
75
+ interface RangeComponent extends React__default.ForwardRefExoticComponent<RangeProps & React__default.RefAttributes<HTMLDivElement>> {
76
+ Container: typeof RangeContainer;
77
+ Connects: typeof RangeConnects;
78
+ Thumb: typeof RangeThumb;
79
+ Dot: typeof RangeDot;
23
80
  }
24
- declare const Range: React.ForwardRefExoticComponent<RangeProps & React.RefAttributes<HTMLDivElement>>;
81
+ declare const Range: RangeComponent;
25
82
 
26
83
  interface RangeTupleProps {
84
+ children?: React__default.ReactNode;
27
85
  className?: string;
28
- connectsClassName?: {
29
- negative?: string;
30
- positive?: string;
31
- };
32
86
  defaultValue?: [number, number];
33
87
  disabled?: boolean;
34
88
  max?: number;
@@ -39,12 +93,214 @@ interface RangeTupleProps {
39
93
  readOnly?: boolean;
40
94
  step?: number;
41
95
  thumbSize?: number;
42
- trackSize?: {
43
- height?: number;
44
- width?: number | "auto";
45
- };
46
96
  value?: [number, number];
97
+ /**
98
+ * Width of the range track in pixels.
99
+ * If not provided (undefined) or set to false, the width will be auto-calculated from the container.
100
+ */
101
+ width?: number | boolean;
102
+ }
103
+ interface RangeTupleComponent extends React__default.ForwardRefExoticComponent<RangeTupleProps & React__default.RefAttributes<HTMLDivElement>> {
104
+ Container: typeof RangeTupleContainer;
105
+ Connects: typeof RangeTupleConnects;
106
+ Thumb: typeof RangeTupleThumb;
107
+ Dot: typeof RangeTupleDot;
108
+ }
109
+ declare const RangeTuple: RangeTupleComponent;
110
+
111
+ declare const rangeTv: tailwind_variants.TVReturnType<{
112
+ overStepValue: {
113
+ true: {
114
+ dot: string;
115
+ };
116
+ false: {
117
+ dot: string;
118
+ };
119
+ };
120
+ defaultStepValue: {
121
+ true: {
122
+ dot: string;
123
+ };
124
+ };
125
+ hasStepOrDefault: {
126
+ true: {};
127
+ false: {};
128
+ };
129
+ currentDefaultValue: {
130
+ true: {};
131
+ false: {};
132
+ };
133
+ disabled: {
134
+ true: {
135
+ connect: string;
136
+ thumb: string;
137
+ };
138
+ false: {
139
+ connect: string;
140
+ };
141
+ };
142
+ }, {
143
+ container: string[];
144
+ connect: string[];
145
+ thumbWrapper: string[];
146
+ thumb: string[];
147
+ dotContainer: string;
148
+ dot: string[];
149
+ input: string;
150
+ }, undefined, {
151
+ overStepValue: {
152
+ true: {
153
+ dot: string;
154
+ };
155
+ false: {
156
+ dot: string;
157
+ };
158
+ };
159
+ defaultStepValue: {
160
+ true: {
161
+ dot: string;
162
+ };
163
+ };
164
+ hasStepOrDefault: {
165
+ true: {};
166
+ false: {};
167
+ };
168
+ currentDefaultValue: {
169
+ true: {};
170
+ false: {};
171
+ };
172
+ disabled: {
173
+ true: {
174
+ connect: string;
175
+ thumb: string;
176
+ };
177
+ false: {
178
+ connect: string;
179
+ };
180
+ };
181
+ }, {
182
+ container: string[];
183
+ connect: string[];
184
+ thumbWrapper: string[];
185
+ thumb: string[];
186
+ dotContainer: string;
187
+ dot: string[];
188
+ input: string;
189
+ }, tailwind_variants.TVReturnType<{
190
+ overStepValue: {
191
+ true: {
192
+ dot: string;
193
+ };
194
+ false: {
195
+ dot: string;
196
+ };
197
+ };
198
+ defaultStepValue: {
199
+ true: {
200
+ dot: string;
201
+ };
202
+ };
203
+ hasStepOrDefault: {
204
+ true: {};
205
+ false: {};
206
+ };
207
+ currentDefaultValue: {
208
+ true: {};
209
+ false: {};
210
+ };
211
+ disabled: {
212
+ true: {
213
+ connect: string;
214
+ thumb: string;
215
+ };
216
+ false: {
217
+ connect: string;
218
+ };
219
+ };
220
+ }, {
221
+ container: string[];
222
+ connect: string[];
223
+ thumbWrapper: string[];
224
+ thumb: string[];
225
+ dotContainer: string;
226
+ dot: string[];
227
+ input: string;
228
+ }, undefined, unknown, unknown, undefined>>;
229
+
230
+ interface RangeContextValue {
231
+ currentValue: number;
232
+ disabled: boolean;
233
+ readOnly: boolean;
234
+ min: number;
235
+ max: number;
236
+ step: number;
237
+ thumbSize: number;
238
+ trackHeight: number;
239
+ transforms: {
240
+ minTransform: number;
241
+ maxTransform: number;
242
+ transformX: number;
243
+ };
244
+ defaultStepValue: number | null;
245
+ currentStepValue: number;
246
+ dotsData: Array<{
247
+ value: number;
248
+ position: number;
249
+ }> | null;
250
+ defaultDotPosition: number | null;
251
+ thumbRef: React.MutableRefObject<HTMLDivElement | null>;
252
+ inputRef: React.MutableRefObject<HTMLInputElement | null>;
253
+ isDragging: React.MutableRefObject<boolean>;
254
+ handlePointerDown: (e: React.PointerEvent) => void;
255
+ handleKeyDown: (e: React.KeyboardEvent) => void;
256
+ tv: ReturnType<typeof rangeTv>;
257
+ defaultValue?: number;
258
+ hasCustomDot: boolean;
259
+ hasCustomConnects: boolean;
260
+ isDefaultValue?: boolean;
261
+ }
262
+ declare const RangeContext: React$1.Context<RangeContextValue | null>;
263
+ declare function useRangeContext(): RangeContextValue;
264
+
265
+ type ThumbIndex = 0 | 1;
266
+ interface RangeTupleContextValue {
267
+ currentValue: [number, number];
268
+ disabled: boolean;
269
+ readOnly: boolean;
270
+ min: number;
271
+ max: number;
272
+ step: number;
273
+ thumbSize: number;
274
+ trackHeight: number;
275
+ transforms: {
276
+ minTransform: number;
277
+ maxTransform: number;
278
+ transformX0: number;
279
+ transformX1: number;
280
+ };
281
+ defaultStepValue: [number, number] | null;
282
+ currentStepValue: [number, number];
283
+ dotsData: Array<{
284
+ value: number;
285
+ position: number;
286
+ }> | null;
287
+ defaultDotPositions: [number, number] | null;
288
+ normalizedDefaultValue: [number, number] | undefined;
289
+ thumb0Ref: React.RefObject<HTMLDivElement | null>;
290
+ thumb1Ref: React.RefObject<HTMLDivElement | null>;
291
+ input0Ref: React.RefObject<HTMLInputElement | null>;
292
+ input1Ref: React.RefObject<HTMLInputElement | null>;
293
+ isDragging: React.MutableRefObject<ThumbIndex | null>;
294
+ handlePointerDown: (e: React.PointerEvent, thumbIndex: ThumbIndex) => void;
295
+ handleKeyDown: (e: React.KeyboardEvent, thumbIndex: ThumbIndex) => void;
296
+ tv: ReturnType<typeof rangeTv>;
297
+ thumbTv0: ReturnType<typeof rangeTv>;
298
+ thumbTv1: ReturnType<typeof rangeTv>;
299
+ hasCustomDot: boolean;
300
+ hasCustomConnects: boolean;
301
+ isDefaultValue?: boolean;
47
302
  }
48
- declare const RangeTuple: React.ForwardRefExoticComponent<RangeTupleProps & React.RefAttributes<HTMLDivElement>>;
303
+ declare const RangeTupleContext: React$1.Context<RangeTupleContextValue | null>;
304
+ declare function useRangeTupleContext(): RangeTupleContextValue;
49
305
 
50
- export { Range, type RangeProps, RangeTuple, type RangeTupleProps };
306
+ export { Range, type RangeConnectsProps, type RangeContainerProps, RangeContext, type RangeContextValue, type RangeDotProps, type RangeProps, type RangeThumbProps, RangeTuple, type RangeTupleConnectsProps, type RangeTupleContainerProps, RangeTupleContext, type RangeTupleContextValue, type RangeTupleDotProps, type RangeTupleProps, type RangeTupleThumbProps, useRangeContext, useRangeTupleContext };