@chekinapp/ui 0.0.116 → 0.0.117

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.
package/dist/index.d.cts CHANGED
@@ -3193,14 +3193,10 @@ type SelectCheckboxesProps<T = undefined, V extends SelectValue$1 = string, L ex
3193
3193
  options?: SelectGroupedOption<T, V, L>[];
3194
3194
  trigger?: SelectCheckboxesTriggerRenderer;
3195
3195
  components?: SelectComponents<T, V, L>;
3196
- /** Custom display for the count text in the trigger. Receives (count, total). */
3197
3196
  valueText?: string | ((selectedCount: number, total: number) => string);
3198
- /** Show "Select All" row at top of menu (default false). */
3199
3197
  allowSelectAll?: boolean;
3200
3198
  selectAllLabel?: string;
3201
- /** Render the in-menu search input (default true). */
3202
3199
  searchable?: boolean;
3203
- searchPlaceholder?: string;
3204
3200
  } & SelectCheckboxesPaginationProps<T, V, L>;
3205
3201
  type SelectCheckboxesComponent = <T = undefined, V extends SelectValue$1 = string, L extends ReactNode = string>(props: SelectCheckboxesProps<T, V, L> & {
3206
3202
  ref?: React$1.Ref<HTMLDivElement>;
@@ -3212,11 +3208,10 @@ declare function SelectCheckboxOption<T, V extends SelectValue$1, L extends Reac
3212
3208
  type SelectAllRowProps = {
3213
3209
  label: string;
3214
3210
  checked: boolean;
3215
- indeterminate?: boolean;
3216
3211
  disabled?: boolean;
3217
3212
  onToggle: () => void;
3218
3213
  };
3219
- declare function SelectAllRow({ label, checked, indeterminate, disabled, onToggle, }: SelectAllRowProps): react_jsx_runtime.JSX.Element;
3214
+ declare function SelectAllRow({ label, checked, disabled, onToggle }: SelectAllRowProps): react_jsx_runtime.JSX.Element;
3220
3215
 
3221
3216
  type TextareaProps = Omit<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, 'name'> & {
3222
3217
  label?: React$1.ReactNode;
@@ -4095,6 +4090,9 @@ interface AirbnbSwitchProps extends Omit<React$1.ComponentPropsWithoutRef<typeof
4095
4090
  onChange?: React$1.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>['onCheckedChange'];
4096
4091
  loading?: boolean;
4097
4092
  readOnly?: boolean;
4093
+ label?: React$1.ReactNode;
4094
+ error?: string;
4095
+ wrapperClassName?: string;
4098
4096
  }
4099
4097
  declare const AirbnbSwitch: React$1.ForwardRefExoticComponent<AirbnbSwitchProps & React$1.RefAttributes<HTMLButtonElement>>;
4100
4098
 
package/dist/index.d.ts CHANGED
@@ -3193,14 +3193,10 @@ type SelectCheckboxesProps<T = undefined, V extends SelectValue$1 = string, L ex
3193
3193
  options?: SelectGroupedOption<T, V, L>[];
3194
3194
  trigger?: SelectCheckboxesTriggerRenderer;
3195
3195
  components?: SelectComponents<T, V, L>;
3196
- /** Custom display for the count text in the trigger. Receives (count, total). */
3197
3196
  valueText?: string | ((selectedCount: number, total: number) => string);
3198
- /** Show "Select All" row at top of menu (default false). */
3199
3197
  allowSelectAll?: boolean;
3200
3198
  selectAllLabel?: string;
3201
- /** Render the in-menu search input (default true). */
3202
3199
  searchable?: boolean;
3203
- searchPlaceholder?: string;
3204
3200
  } & SelectCheckboxesPaginationProps<T, V, L>;
3205
3201
  type SelectCheckboxesComponent = <T = undefined, V extends SelectValue$1 = string, L extends ReactNode = string>(props: SelectCheckboxesProps<T, V, L> & {
3206
3202
  ref?: React$1.Ref<HTMLDivElement>;
@@ -3212,11 +3208,10 @@ declare function SelectCheckboxOption<T, V extends SelectValue$1, L extends Reac
3212
3208
  type SelectAllRowProps = {
3213
3209
  label: string;
3214
3210
  checked: boolean;
3215
- indeterminate?: boolean;
3216
3211
  disabled?: boolean;
3217
3212
  onToggle: () => void;
3218
3213
  };
3219
- declare function SelectAllRow({ label, checked, indeterminate, disabled, onToggle, }: SelectAllRowProps): react_jsx_runtime.JSX.Element;
3214
+ declare function SelectAllRow({ label, checked, disabled, onToggle }: SelectAllRowProps): react_jsx_runtime.JSX.Element;
3220
3215
 
3221
3216
  type TextareaProps = Omit<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, 'name'> & {
3222
3217
  label?: React$1.ReactNode;
@@ -4095,6 +4090,9 @@ interface AirbnbSwitchProps extends Omit<React$1.ComponentPropsWithoutRef<typeof
4095
4090
  onChange?: React$1.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>['onCheckedChange'];
4096
4091
  loading?: boolean;
4097
4092
  readOnly?: boolean;
4093
+ label?: React$1.ReactNode;
4094
+ error?: string;
4095
+ wrapperClassName?: string;
4098
4096
  }
4099
4097
  declare const AirbnbSwitch: React$1.ForwardRefExoticComponent<AirbnbSwitchProps & React$1.RefAttributes<HTMLButtonElement>>;
4100
4098
 
package/dist/index.js CHANGED
@@ -12512,9 +12512,9 @@ import { useTranslation as useTranslation28 } from "react-i18next";
12512
12512
 
12513
12513
  // src/dashboard/_select-internals/utils.ts
12514
12514
  function isOptionGroup(item) {
12515
- return Boolean(
12516
- item && Array.isArray(item.options)
12517
- );
12515
+ if (!item || typeof item !== "object") return false;
12516
+ if ("value" in item) return false;
12517
+ return Array.isArray(item.options);
12518
12518
  }
12519
12519
  function flattenGroupedOptions(items) {
12520
12520
  if (!items) return [];
@@ -12625,7 +12625,7 @@ function DefaultOption(props) {
12625
12625
 
12626
12626
  // src/dashboard/_select-internals/SelectMenu.tsx
12627
12627
  import { jsx as jsx146, jsxs as jsxs93 } from "react/jsx-runtime";
12628
- function buildMenuEntries(groupedOptions, options, formatGroupLabel) {
12628
+ function buildMenuEntries(groupedOptions, options, formatGroupLabel, listboxId) {
12629
12629
  if (!groupedOptions || !groupedOptions.some((item) => isOptionGroup(item))) {
12630
12630
  return options.map((option, index) => ({
12631
12631
  kind: "option",
@@ -12634,38 +12634,39 @@ function buildMenuEntries(groupedOptions, options, formatGroupLabel) {
12634
12634
  flatIndex: index
12635
12635
  }));
12636
12636
  }
12637
- const indexByOption = /* @__PURE__ */ new Map();
12638
- options.forEach((option, index) => indexByOption.set(option, index));
12637
+ const visibleValues = new Set(options.map((option) => option.value));
12639
12638
  const entries = [];
12639
+ let flatIndex = 0;
12640
12640
  let groupCount = 0;
12641
12641
  for (const item of groupedOptions) {
12642
12642
  if (isOptionGroup(item)) {
12643
- const visible = item.options.filter((option) => indexByOption.has(option));
12644
- if (visible.length === 0) continue;
12645
- const label = formatGroupLabel ? formatGroupLabel(item) : item.label;
12646
- entries.push({
12647
- kind: "group-label",
12648
- key: `__group-${groupCount}`,
12649
- label
12650
- });
12651
- groupCount += 1;
12652
- for (const option of visible) {
12653
- const flatIndex = indexByOption.get(option);
12654
- entries.push({
12655
- kind: "option",
12643
+ const visible = [];
12644
+ for (const option of item.options) {
12645
+ if (!visibleValues.has(option.value)) continue;
12646
+ visible.push({
12656
12647
  key: `${String(option.value)}-${flatIndex}`,
12657
12648
  option,
12658
12649
  flatIndex
12659
12650
  });
12651
+ flatIndex += 1;
12660
12652
  }
12661
- } else if (indexByOption.has(item)) {
12662
- const flatIndex = indexByOption.get(item);
12653
+ if (visible.length === 0) continue;
12654
+ entries.push({
12655
+ kind: "group",
12656
+ key: `__group-${groupCount}`,
12657
+ labelId: `${listboxId}-group-${groupCount}`,
12658
+ label: formatGroupLabel ? formatGroupLabel(item) : item.label,
12659
+ options: visible
12660
+ });
12661
+ groupCount += 1;
12662
+ } else if (visibleValues.has(item.value)) {
12663
12663
  entries.push({
12664
12664
  kind: "option",
12665
12665
  key: `${String(item.value)}-${flatIndex}`,
12666
12666
  option: item,
12667
12667
  flatIndex
12668
12668
  });
12669
+ flatIndex += 1;
12669
12670
  }
12670
12671
  }
12671
12672
  return entries;
@@ -12709,9 +12710,37 @@ function SelectMenu({
12709
12710
  [selectedValues, selectedValue]
12710
12711
  );
12711
12712
  const entries = React45.useMemo(
12712
- () => buildMenuEntries(groupedOptions, options, formatGroupLabel),
12713
- [groupedOptions, options, formatGroupLabel]
12713
+ () => buildMenuEntries(groupedOptions, options, formatGroupLabel, id),
12714
+ [groupedOptions, options, formatGroupLabel, id]
12714
12715
  );
12716
+ const renderOption = (entry) => {
12717
+ const { option, flatIndex, key } = entry;
12718
+ const isSelected = isOptionSelected2 ? isOptionSelected2(option, selectedList) : isOptionSelected(option, selectedValue, selectedValues);
12719
+ const isHighlighted = flatIndex === highlightedIndex;
12720
+ const optionDisabled = Boolean(
12721
+ disabled || option.isDisabled || isOptionDisabled?.(option)
12722
+ );
12723
+ return /* @__PURE__ */ jsx146(
12724
+ Option,
12725
+ {
12726
+ id: getOptionId2(flatIndex),
12727
+ option,
12728
+ index: flatIndex,
12729
+ isSelected,
12730
+ isHighlighted,
12731
+ isDisabled: optionDisabled,
12732
+ isLast: flatIndex === lastIndex,
12733
+ isMulti: Boolean(isMulti),
12734
+ onClick: onOptionClick,
12735
+ onHover: onOptionHover ?? (() => void 0),
12736
+ innerRef: (node) => selectedOptionRef?.(flatIndex, node),
12737
+ inputValue,
12738
+ selectedOptions: selectedList,
12739
+ formatOptionLabel
12740
+ },
12741
+ key
12742
+ );
12743
+ };
12715
12744
  const wasAtBottomRef = React45.useRef(false);
12716
12745
  const handleScroll = React45.useCallback(
12717
12746
  (event) => {
@@ -12746,43 +12775,20 @@ function SelectMenu({
12746
12775
  children: [
12747
12776
  !hasOptions && (emptyContent ?? /* @__PURE__ */ jsx146("div", { className: "px-3 py-3 text-left text-[14px] font-medium text-[var(--chekin-color-gray-1)]", children: emptyMessage })),
12748
12777
  entries.map((entry) => {
12749
- if (entry.kind === "group-label") {
12750
- return /* @__PURE__ */ jsx146(
12751
- "div",
12752
- {
12753
- role: "presentation",
12754
- className: "px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-[var(--chekin-color-gray-1)]",
12755
- children: entry.label
12756
- },
12757
- entry.key
12758
- );
12778
+ if (entry.kind === "group") {
12779
+ return /* @__PURE__ */ jsxs93("div", { role: "group", "aria-labelledby": entry.labelId, children: [
12780
+ /* @__PURE__ */ jsx146(
12781
+ "div",
12782
+ {
12783
+ id: entry.labelId,
12784
+ className: "px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-[var(--chekin-color-gray-1)]",
12785
+ children: entry.label
12786
+ }
12787
+ ),
12788
+ entry.options.map(renderOption)
12789
+ ] }, entry.key);
12759
12790
  }
12760
- const { option, flatIndex } = entry;
12761
- const isSelected = isOptionSelected2 ? isOptionSelected2(option, selectedList) : isOptionSelected(option, selectedValue, selectedValues);
12762
- const isHighlighted = flatIndex === highlightedIndex;
12763
- const optionDisabled = Boolean(
12764
- disabled || option.isDisabled || isOptionDisabled?.(option)
12765
- );
12766
- return /* @__PURE__ */ jsx146(
12767
- Option,
12768
- {
12769
- id: getOptionId2(flatIndex),
12770
- option,
12771
- index: flatIndex,
12772
- isSelected,
12773
- isHighlighted,
12774
- isDisabled: optionDisabled,
12775
- isLast: flatIndex === lastIndex,
12776
- isMulti: Boolean(isMulti),
12777
- onClick: onOptionClick,
12778
- onHover: onOptionHover ?? (() => void 0),
12779
- innerRef: (node) => selectedOptionRef?.(flatIndex, node),
12780
- inputValue,
12781
- selectedOptions: selectedList,
12782
- formatOptionLabel
12783
- },
12784
- entry.key
12785
- );
12791
+ return renderOption(entry);
12786
12792
  }),
12787
12793
  footer
12788
12794
  ]
@@ -14787,13 +14793,7 @@ function createCountTrigger(opts) {
14787
14793
 
14788
14794
  // src/dashboard/select-checkboxes/SelectAllRow.tsx
14789
14795
  import { jsx as jsx167, jsxs as jsxs104 } from "react/jsx-runtime";
14790
- function SelectAllRow({
14791
- label,
14792
- checked,
14793
- indeterminate,
14794
- disabled,
14795
- onToggle
14796
- }) {
14796
+ function SelectAllRow({ label, checked, disabled, onToggle }) {
14797
14797
  return /* @__PURE__ */ jsxs104(
14798
14798
  "button",
14799
14799
  {
@@ -14808,7 +14808,7 @@ function SelectAllRow({
14808
14808
  /* @__PURE__ */ jsx167(
14809
14809
  BaseCheckbox,
14810
14810
  {
14811
- checked: indeterminate ? "indeterminate" : checked,
14811
+ checked,
14812
14812
  disabled,
14813
14813
  size: "s",
14814
14814
  tabIndex: -1,
@@ -14844,7 +14844,6 @@ function SelectCheckboxesInternal(props, ref) {
14844
14844
  allowSelectAll = false,
14845
14845
  selectAllLabel,
14846
14846
  searchable = true,
14847
- searchPlaceholder,
14848
14847
  filterOption = defaultFilterOption,
14849
14848
  closeMenuOnSelect = false,
14850
14849
  onSearchChange,
@@ -14879,7 +14878,6 @@ function SelectCheckboxesInternal(props, ref) {
14879
14878
  return acc + (selected.some((s) => s.value === option.value) ? 1 : 0);
14880
14879
  }, 0);
14881
14880
  const allVisibleSelected = filteredFlat.length > 0 && visibleSelectedCount === filteredFlat.length;
14882
- const someVisibleSelected = visibleSelectedCount > 0 && visibleSelectedCount < filteredFlat.length;
14883
14881
  const handleToggleAll = React59.useCallback(() => {
14884
14882
  if (allVisibleSelected) {
14885
14883
  const visibleValues = new Set(filteredFlat.map((option) => option.value));
@@ -14915,7 +14913,6 @@ function SelectCheckboxesInternal(props, ref) {
14915
14913
  {
14916
14914
  label: selectAllLabel ?? t("select_all", { defaultValue: "Select All" }),
14917
14915
  checked: allVisibleSelected,
14918
- indeterminate: someVisibleSelected,
14919
14916
  onToggle: handleToggleAll
14920
14917
  }
14921
14918
  ) : void 0;
@@ -19952,45 +19949,60 @@ AirbnbSearchInput.displayName = "AirbnbSearchInput";
19952
19949
  import * as React83 from "react";
19953
19950
  import * as SwitchPrimitives2 from "@radix-ui/react-switch";
19954
19951
  import { Check as Check7 } from "lucide-react";
19955
- import { jsx as jsx194 } from "react/jsx-runtime";
19956
- var AirbnbSwitch = React83.forwardRef(({ className, value, onChange, disabled, loading, readOnly, ...props }, ref) => /* @__PURE__ */ jsx194(
19957
- SwitchPrimitives2.Root,
19958
- {
19959
- ref,
19960
- className: cn(
19961
- "group inline-flex h-[24px] w-[36px] shrink-0 cursor-pointer items-center rounded-full border border-solid border-transparent p-[2px] transition-colors duration-200",
19962
- "focus-visible:outline-none focus-visible:shadow-[var(--chekin-shadow-focus)]",
19963
- "disabled:cursor-not-allowed disabled:opacity-50 aria-busy:cursor-wait aria-busy:opacity-50",
19964
- "aria-readonly:cursor-default aria-readonly:opacity-100",
19965
- "data-[state=checked]:bg-[#222222] data-[state=unchecked]:bg-[#E7E7E4]",
19966
- className
19967
- ),
19968
- disabled,
19969
- checked: value,
19970
- value: String(value),
19971
- onCheckedChange: !disabled && !readOnly ? onChange : void 0,
19972
- "aria-busy": loading,
19973
- "aria-readonly": readOnly,
19974
- ...props,
19975
- children: /* @__PURE__ */ jsx194(
19976
- SwitchPrimitives2.Thumb,
19977
- {
19978
- className: cn(
19979
- "flex h-[20px] w-[20px] items-center justify-center rounded-full bg-white shadow-[0_1px_3px_rgba(0,0,0,0.22)] transition-transform duration-200",
19980
- "data-[state=checked]:translate-x-[12px] data-[state=unchecked]:translate-x-0"
19981
- ),
19982
- children: /* @__PURE__ */ jsx194(
19983
- Check7,
19984
- {
19985
- "aria-hidden": "true",
19986
- className: "h-3 w-3 text-[#222222] opacity-0 transition-opacity duration-150 group-data-[state=checked]:opacity-100",
19987
- strokeWidth: 3
19988
- }
19989
- )
19990
- }
19991
- )
19952
+ import { Fragment as Fragment19, jsx as jsx194, jsxs as jsxs126 } from "react/jsx-runtime";
19953
+ var AirbnbSwitch = React83.forwardRef(({ className, value, onChange, disabled, loading, readOnly, id, label, error, wrapperClassName, ...props }, ref) => {
19954
+ const generatedId = React83.useId();
19955
+ const fieldId = id || generatedId;
19956
+ const switchElement = /* @__PURE__ */ jsx194(
19957
+ SwitchPrimitives2.Root,
19958
+ {
19959
+ ref,
19960
+ className: cn(
19961
+ "group inline-flex h-[24px] w-[36px] shrink-0 cursor-pointer items-center rounded-full border border-solid border-transparent p-[2px] transition-colors duration-200",
19962
+ "focus-visible:outline-none focus-visible:shadow-[var(--chekin-shadow-focus)]",
19963
+ "disabled:cursor-not-allowed disabled:opacity-50 aria-busy:cursor-wait aria-busy:opacity-50",
19964
+ "aria-readonly:cursor-default aria-readonly:opacity-100",
19965
+ "data-[state=checked]:bg-[#222222] data-[state=unchecked]:bg-[#E7E7E4]",
19966
+ className
19967
+ ),
19968
+ id: fieldId,
19969
+ disabled,
19970
+ checked: value,
19971
+ value: String(value),
19972
+ onCheckedChange: !disabled && !readOnly ? onChange : void 0,
19973
+ "aria-busy": loading,
19974
+ "aria-readonly": readOnly,
19975
+ ...props,
19976
+ children: /* @__PURE__ */ jsx194(
19977
+ SwitchPrimitives2.Thumb,
19978
+ {
19979
+ className: cn(
19980
+ "flex h-[20px] w-[20px] items-center justify-center rounded-full bg-white shadow-[0_1px_3px_rgba(0,0,0,0.22)] transition-transform duration-200",
19981
+ "data-[state=checked]:translate-x-[12px] data-[state=unchecked]:translate-x-0"
19982
+ ),
19983
+ children: /* @__PURE__ */ jsx194(
19984
+ Check7,
19985
+ {
19986
+ "aria-hidden": "true",
19987
+ className: "h-3 w-3 text-[#222222] opacity-0 transition-opacity duration-150 group-data-[state=checked]:opacity-100",
19988
+ strokeWidth: 3
19989
+ }
19990
+ )
19991
+ }
19992
+ )
19993
+ }
19994
+ );
19995
+ if (!label && !error) {
19996
+ return switchElement;
19992
19997
  }
19993
- ));
19998
+ return /* @__PURE__ */ jsxs126(Fragment19, { children: [
19999
+ /* @__PURE__ */ jsxs126("div", { className: cn("flex items-center gap-x-3 gap-y-1.5", wrapperClassName), children: [
20000
+ switchElement,
20001
+ label && /* @__PURE__ */ jsx194(Label, { htmlFor: fieldId, className: "cursor-pointer text-base font-medium", children: label })
20002
+ ] }),
20003
+ error && /* @__PURE__ */ jsx194(ErrorMessage, { disabled, children: error })
20004
+ ] });
20005
+ });
19994
20006
  AirbnbSwitch.displayName = "AirbnbSwitch";
19995
20007
  export {
19996
20008
  ALERT_BOX_VARIANTS,