@northlight/ui 2.28.7 → 2.28.9

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.
@@ -599,11 +599,12 @@ declare const CheckboxField: (props: CheckboxFieldProps & React__default.RefAttr
599
599
 
600
600
  type ColorPickerSize = 'sm' | 'md' | 'lg';
601
601
  interface ColorPickerProps extends Omit<IconButtonProps$1, 'onChange' | 'value' | 'aria-label' | 'variant'> {
602
- onChange?: (value: string) => void;
602
+ onChange?: (value: string | null) => void;
603
603
  /** This are what color options the user can choose */
604
604
  colors?: string[];
605
605
  /** This are the extended color options displayed when clicking the down caret */
606
606
  expandedColors?: string[];
607
+ clearable?: boolean;
607
608
  value?: string | null;
608
609
  size?: ColorPickerSize;
609
610
  name?: string;
@@ -652,7 +653,7 @@ type ColorPickerFieldProps = ColorPickerProps & {
652
653
  *
653
654
  *
654
655
  */
655
- declare const ColorPicker: ({ onChange, colors, expandedColors, value, name, size, popoverProps, ...rest }: ColorPickerProps) => JSX.Element;
656
+ declare const ColorPicker: ({ onChange, clearable, colors, expandedColors, value, name, size, popoverProps, ...rest }: ColorPickerProps) => JSX.Element;
656
657
 
657
658
  /**
658
659
  * The <ColorPicker /> component wrapped in a <Field />
@@ -1776,7 +1776,12 @@ const AvatarGroup = (_a) => {
1776
1776
  "spacing"
1777
1777
  ]);
1778
1778
  const [nbrRemainingAvatars, setNbrRemainingAvatars] = useState(0);
1779
- return /* @__PURE__ */ React.createElement(HStack, __spreadValues$1_({ bgColor: "background.default" }, rest), /* @__PURE__ */ React.createElement(HStack, { spacing }, /* @__PURE__ */ React.createElement(OverflowGroup, { max, onChange: setNbrRemainingAvatars }, children)), nbrRemainingAvatars > 0 && /* @__PURE__ */ React.createElement(Small$1, { sx: { color: "blue.500" } }, "+", nbrRemainingAvatars));
1779
+ const childrenWithMargin = getChildrenWithProps(
1780
+ children,
1781
+ { ml: spacing },
1782
+ (_child, idx) => idx > 0
1783
+ );
1784
+ return /* @__PURE__ */ React.createElement(HStack, __spreadValues$1_({ bgColor: "background.default" }, rest), /* @__PURE__ */ React.createElement(HStack, { spacing: 0 }, /* @__PURE__ */ React.createElement(OverflowGroup, { max, onChange: setNbrRemainingAvatars }, childrenWithMargin)), nbrRemainingAvatars > 0 && /* @__PURE__ */ React.createElement(Small$1, { sx: { color: "blue.500" } }, "+", nbrRemainingAvatars));
1780
1785
  };
1781
1786
 
1782
1787
  var __defProp$1Z = Object.defineProperty;
@@ -2503,6 +2508,7 @@ const ColorPicker$1 = (_a) => {
2503
2508
  var _b = _a, {
2504
2509
  onChange = () => {
2505
2510
  },
2511
+ clearable = false,
2506
2512
  colors = defaultColors,
2507
2513
  expandedColors = paletteColors,
2508
2514
  value = null,
@@ -2511,6 +2517,7 @@ const ColorPicker$1 = (_a) => {
2511
2517
  popoverProps
2512
2518
  } = _b, rest = __objRest$1l(_b, [
2513
2519
  "onChange",
2520
+ "clearable",
2514
2521
  "colors",
2515
2522
  "expandedColors",
2516
2523
  "value",
@@ -2566,6 +2573,10 @@ const ColorPicker$1 = (_a) => {
2566
2573
  setSelectedColor(color);
2567
2574
  onChange(color);
2568
2575
  };
2576
+ const clearSelection = () => {
2577
+ setSelectedColor(null);
2578
+ onChange(null);
2579
+ };
2569
2580
  return /* @__PURE__ */ React.createElement(Box, { "data-testid": "color-picker-test-id" }, /* @__PURE__ */ React.createElement(
2570
2581
  Popover$1,
2571
2582
  __spreadValues$1O({
@@ -2588,9 +2599,23 @@ const ColorPicker$1 = (_a) => {
2588
2599
  PopoverHeader,
2589
2600
  {
2590
2601
  color: "text.default",
2591
- sx: heading
2602
+ sx: heading,
2603
+ display: "flex",
2604
+ alignItems: "center",
2605
+ justifyContent: "space-between",
2606
+ width: "full"
2592
2607
  },
2593
- "Pick a color"
2608
+ "Pick a color",
2609
+ clearable && trigger.color !== "unset" && /* @__PURE__ */ React.createElement(
2610
+ Button$1,
2611
+ {
2612
+ size: "sm",
2613
+ h: "5",
2614
+ onClick: clearSelection,
2615
+ variant: "ghost"
2616
+ },
2617
+ "Clear"
2618
+ )
2594
2619
  ), /* @__PURE__ */ React.createElement(PopoverBody, { p: 0 }, /* @__PURE__ */ React.createElement(Stack, { alignItems: "center", p: 0, spacing: 0 }, /* @__PURE__ */ React.createElement(FocusScope, null, /* @__PURE__ */ React.createElement(
2595
2620
  SimpleGrid,
2596
2621
  {