@crisp-ui-kit/crisp 0.17.0 → 0.18.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.
@@ -57,13 +57,15 @@ const fromDate = (d) => ({
57
57
  * popover. This is what `DatePicker` used to be; `DatePicker` is now
58
58
  * seed-design's bare calendar, and this composes it.
59
59
  */
60
- function DatePickerField({ value, defaultValue, onChange, placeholder = "Set date…", variant = "default", format = defaultFormat, presets, calendarProps, "aria-label": ariaLabel, className, ...rest }) {
60
+ function DatePickerField({ value, defaultValue, onValueChange, onChange, placeholder = "Set date…", variant = "default", format = defaultFormat, presets, calendarProps, "aria-label": ariaLabel, className, ...rest }) {
61
61
  const [internal, setInternal] = React.useState(defaultValue ?? null);
62
62
  const selected = value ?? internal;
63
63
  const [open, setOpen] = React.useState(false);
64
64
  const pick = (d) => {
65
65
  if (value === undefined)
66
66
  setInternal(d);
67
+ // both, so a consumer passing either name is heard
68
+ onValueChange?.(d);
67
69
  onChange?.(d);
68
70
  setOpen(false);
69
71
  };
@@ -42,12 +42,15 @@ const viewtoggle_recipe_1 = require("./viewtoggle.recipe");
42
42
  * of icon tiles; the selected tile is raised. Use for view-mode switches (list ⇄
43
43
  * grid) or any small mutually-exclusive icon choice.
44
44
  */
45
- function ViewToggle({ options, value: valueProp, defaultValue, onChange, "aria-label": ariaLabel, className, ...rest }) {
45
+ function ViewToggle({ options, value: valueProp, defaultValue, onValueChange, onChange, "aria-label": ariaLabel, className, ...rest }) {
46
46
  const [internalValue, setInternalValue] = React.useState(defaultValue);
47
47
  const value = valueProp ?? internalValue ?? options[0]?.value;
48
48
  const pick = (next) => {
49
49
  if (valueProp === undefined)
50
50
  setInternalValue(next);
51
+ // both, so a consumer passing either name is heard and one passing both
52
+ // does not silently lose one
53
+ onValueChange?.(next);
51
54
  onChange?.(next);
52
55
  };
53
56
  return ((0, jsx_runtime_1.jsx)("div", { className: (0, viewtoggle_recipe_1.viewtoggleRecipe)({ className }), ...rest, role: "group", "aria-label": ariaLabel, children: options.map((o) => ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "viewtoggle-tile", "aria-pressed": o.value === value, "aria-label": o.label, title: o.label, "data-active": o.value === value ? "" : undefined, onClick: () => pick(o.value), children: o.icon }, o.value))) }));
@@ -21,13 +21,15 @@ const fromDate = (d) => ({
21
21
  * popover. This is what `DatePicker` used to be; `DatePicker` is now
22
22
  * seed-design's bare calendar, and this composes it.
23
23
  */
24
- export function DatePickerField({ value, defaultValue, onChange, placeholder = "Set date…", variant = "default", format = defaultFormat, presets, calendarProps, "aria-label": ariaLabel, className, ...rest }) {
24
+ export function DatePickerField({ value, defaultValue, onValueChange, onChange, placeholder = "Set date…", variant = "default", format = defaultFormat, presets, calendarProps, "aria-label": ariaLabel, className, ...rest }) {
25
25
  const [internal, setInternal] = React.useState(defaultValue ?? null);
26
26
  const selected = value ?? internal;
27
27
  const [open, setOpen] = React.useState(false);
28
28
  const pick = (d) => {
29
29
  if (value === undefined)
30
30
  setInternal(d);
31
+ // both, so a consumer passing either name is heard
32
+ onValueChange?.(d);
31
33
  onChange?.(d);
32
34
  setOpen(false);
33
35
  };
@@ -6,12 +6,15 @@ import { viewtoggleRecipe } from "./viewtoggle.recipe.js";
6
6
  * of icon tiles; the selected tile is raised. Use for view-mode switches (list ⇄
7
7
  * grid) or any small mutually-exclusive icon choice.
8
8
  */
9
- export function ViewToggle({ options, value: valueProp, defaultValue, onChange, "aria-label": ariaLabel, className, ...rest }) {
9
+ export function ViewToggle({ options, value: valueProp, defaultValue, onValueChange, onChange, "aria-label": ariaLabel, className, ...rest }) {
10
10
  const [internalValue, setInternalValue] = React.useState(defaultValue);
11
11
  const value = valueProp ?? internalValue ?? options[0]?.value;
12
12
  const pick = (next) => {
13
13
  if (valueProp === undefined)
14
14
  setInternalValue(next);
15
+ // both, so a consumer passing either name is heard and one passing both
16
+ // does not silently lose one
17
+ onValueChange?.(next);
15
18
  onChange?.(next);
16
19
  };
17
20
  return (_jsx("div", { className: viewtoggleRecipe({ className }), ...rest, role: "group", "aria-label": ariaLabel, children: options.map((o) => (_jsx("button", { type: "button", className: "viewtoggle-tile", "aria-pressed": o.value === value, "aria-label": o.label, title: o.label, "data-active": o.value === value ? "" : undefined, onClick: () => pick(o.value), children: o.icon }, o.value))) }));
@@ -11,6 +11,14 @@ export type DatePickerFieldProps = Omit<React.ComponentPropsWithoutRef<"div">, "
11
11
  /** Controlled value. Omit to let the field manage it (see defaultValue). */
12
12
  value?: Date | null;
13
13
  defaultValue?: Date | null;
14
+ /** Fires with the picked date, controlled or not. */
15
+ onValueChange?: (date: Date) => void;
16
+ /**
17
+ * The original name for `onValueChange`, kept working so no consumer breaks.
18
+ * Prefer `onValueChange`: it is what every other crisp component calls this,
19
+ * and passing the house name to a component that only knew `onChange` was
20
+ * not a type error — the handler simply never fired (#202).
21
+ */
14
22
  onChange?: (date: Date) => void;
15
23
  placeholder?: string;
16
24
  /** `default` = outlined trigger; `ghost` = transparent (for table cells). */
@@ -29,7 +37,7 @@ export type DatePickerFieldProps = Omit<React.ComponentPropsWithoutRef<"div">, "
29
37
  * popover. This is what `DatePicker` used to be; `DatePicker` is now
30
38
  * seed-design's bare calendar, and this composes it.
31
39
  */
32
- export declare function DatePickerField({ value, defaultValue, onChange, placeholder, variant, format, presets, calendarProps, "aria-label": ariaLabel, className, ...rest }: DatePickerFieldProps): React.JSX.Element;
40
+ export declare function DatePickerField({ value, defaultValue, onValueChange, onChange, placeholder, variant, format, presets, calendarProps, "aria-label": ariaLabel, className, ...rest }: DatePickerFieldProps): React.JSX.Element;
33
41
  export declare namespace DatePickerField {
34
42
  var displayName: string;
35
43
  }
@@ -12,9 +12,15 @@ export type ViewToggleProps<T extends string = string> = Omit<React.ComponentPro
12
12
  value?: T;
13
13
  /** Initially selected value, when uncontrolled. Defaults to the first option. */
14
14
  defaultValue?: T;
15
- /** Fires with the next value on every pick, controlled or not.
16
- * Named `onChange` rather than the house `onValueChange` for historical
17
- * reasons; renaming it would break consumers. */
15
+ /** Fires with the next value on every pick, controlled or not. */
16
+ onValueChange?: (value: T) => void;
17
+ /**
18
+ * The original name for `onValueChange`, kept working so no consumer breaks.
19
+ * Prefer `onValueChange`: it is what every other crisp component calls this,
20
+ * and because these props extend a `<div>`'s, passing the house name to a
21
+ * component that only knew `onChange` was not a type error — it landed on
22
+ * the DOM and React dropped it with a development-only warning (#202).
23
+ */
18
24
  onChange?: (value: T) => void;
19
25
  "aria-label"?: string;
20
26
  className?: string;
@@ -24,7 +30,7 @@ export type ViewToggleProps<T extends string = string> = Omit<React.ComponentPro
24
30
  * of icon tiles; the selected tile is raised. Use for view-mode switches (list ⇄
25
31
  * grid) or any small mutually-exclusive icon choice.
26
32
  */
27
- export declare function ViewToggle<T extends string = string>({ options, value: valueProp, defaultValue, onChange, "aria-label": ariaLabel, className, ...rest }: ViewToggleProps<T>): React.JSX.Element;
33
+ export declare function ViewToggle<T extends string = string>({ options, value: valueProp, defaultValue, onValueChange, onChange, "aria-label": ariaLabel, className, ...rest }: ViewToggleProps<T>): React.JSX.Element;
28
34
  export declare namespace ViewToggle {
29
35
  var displayName: string;
30
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crisp-ui-kit/crisp",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "A lean React design system, measured pixel-for-pixel from Attio.",
5
5
  "license": "MIT",
6
6
  "type": "module",