@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.cjs CHANGED
@@ -12873,9 +12873,9 @@ var import_react_i18next28 = require("react-i18next");
12873
12873
 
12874
12874
  // src/dashboard/_select-internals/utils.ts
12875
12875
  function isOptionGroup(item) {
12876
- return Boolean(
12877
- item && Array.isArray(item.options)
12878
- );
12876
+ if (!item || typeof item !== "object") return false;
12877
+ if ("value" in item) return false;
12878
+ return Array.isArray(item.options);
12879
12879
  }
12880
12880
  function flattenGroupedOptions(items) {
12881
12881
  if (!items) return [];
@@ -12986,7 +12986,7 @@ function DefaultOption(props) {
12986
12986
 
12987
12987
  // src/dashboard/_select-internals/SelectMenu.tsx
12988
12988
  var import_jsx_runtime148 = require("react/jsx-runtime");
12989
- function buildMenuEntries(groupedOptions, options, formatGroupLabel) {
12989
+ function buildMenuEntries(groupedOptions, options, formatGroupLabel, listboxId) {
12990
12990
  if (!groupedOptions || !groupedOptions.some((item) => isOptionGroup(item))) {
12991
12991
  return options.map((option, index) => ({
12992
12992
  kind: "option",
@@ -12995,38 +12995,39 @@ function buildMenuEntries(groupedOptions, options, formatGroupLabel) {
12995
12995
  flatIndex: index
12996
12996
  }));
12997
12997
  }
12998
- const indexByOption = /* @__PURE__ */ new Map();
12999
- options.forEach((option, index) => indexByOption.set(option, index));
12998
+ const visibleValues = new Set(options.map((option) => option.value));
13000
12999
  const entries = [];
13000
+ let flatIndex = 0;
13001
13001
  let groupCount = 0;
13002
13002
  for (const item of groupedOptions) {
13003
13003
  if (isOptionGroup(item)) {
13004
- const visible = item.options.filter((option) => indexByOption.has(option));
13005
- if (visible.length === 0) continue;
13006
- const label = formatGroupLabel ? formatGroupLabel(item) : item.label;
13007
- entries.push({
13008
- kind: "group-label",
13009
- key: `__group-${groupCount}`,
13010
- label
13011
- });
13012
- groupCount += 1;
13013
- for (const option of visible) {
13014
- const flatIndex = indexByOption.get(option);
13015
- entries.push({
13016
- kind: "option",
13004
+ const visible = [];
13005
+ for (const option of item.options) {
13006
+ if (!visibleValues.has(option.value)) continue;
13007
+ visible.push({
13017
13008
  key: `${String(option.value)}-${flatIndex}`,
13018
13009
  option,
13019
13010
  flatIndex
13020
13011
  });
13012
+ flatIndex += 1;
13021
13013
  }
13022
- } else if (indexByOption.has(item)) {
13023
- const flatIndex = indexByOption.get(item);
13014
+ if (visible.length === 0) continue;
13015
+ entries.push({
13016
+ kind: "group",
13017
+ key: `__group-${groupCount}`,
13018
+ labelId: `${listboxId}-group-${groupCount}`,
13019
+ label: formatGroupLabel ? formatGroupLabel(item) : item.label,
13020
+ options: visible
13021
+ });
13022
+ groupCount += 1;
13023
+ } else if (visibleValues.has(item.value)) {
13024
13024
  entries.push({
13025
13025
  kind: "option",
13026
13026
  key: `${String(item.value)}-${flatIndex}`,
13027
13027
  option: item,
13028
13028
  flatIndex
13029
13029
  });
13030
+ flatIndex += 1;
13030
13031
  }
13031
13032
  }
13032
13033
  return entries;
@@ -13070,9 +13071,37 @@ function SelectMenu({
13070
13071
  [selectedValues, selectedValue]
13071
13072
  );
13072
13073
  const entries = React45.useMemo(
13073
- () => buildMenuEntries(groupedOptions, options, formatGroupLabel),
13074
- [groupedOptions, options, formatGroupLabel]
13074
+ () => buildMenuEntries(groupedOptions, options, formatGroupLabel, id),
13075
+ [groupedOptions, options, formatGroupLabel, id]
13075
13076
  );
13077
+ const renderOption = (entry) => {
13078
+ const { option, flatIndex, key } = entry;
13079
+ const isSelected = isOptionSelected2 ? isOptionSelected2(option, selectedList) : isOptionSelected(option, selectedValue, selectedValues);
13080
+ const isHighlighted = flatIndex === highlightedIndex;
13081
+ const optionDisabled = Boolean(
13082
+ disabled || option.isDisabled || isOptionDisabled?.(option)
13083
+ );
13084
+ return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
13085
+ Option,
13086
+ {
13087
+ id: getOptionId2(flatIndex),
13088
+ option,
13089
+ index: flatIndex,
13090
+ isSelected,
13091
+ isHighlighted,
13092
+ isDisabled: optionDisabled,
13093
+ isLast: flatIndex === lastIndex,
13094
+ isMulti: Boolean(isMulti),
13095
+ onClick: onOptionClick,
13096
+ onHover: onOptionHover ?? (() => void 0),
13097
+ innerRef: (node) => selectedOptionRef?.(flatIndex, node),
13098
+ inputValue,
13099
+ selectedOptions: selectedList,
13100
+ formatOptionLabel
13101
+ },
13102
+ key
13103
+ );
13104
+ };
13076
13105
  const wasAtBottomRef = React45.useRef(false);
13077
13106
  const handleScroll = React45.useCallback(
13078
13107
  (event) => {
@@ -13107,43 +13136,20 @@ function SelectMenu({
13107
13136
  children: [
13108
13137
  !hasOptions && (emptyContent ?? /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("div", { className: "px-3 py-3 text-left text-[14px] font-medium text-[var(--chekin-color-gray-1)]", children: emptyMessage })),
13109
13138
  entries.map((entry) => {
13110
- if (entry.kind === "group-label") {
13111
- return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
13112
- "div",
13113
- {
13114
- role: "presentation",
13115
- className: "px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-[var(--chekin-color-gray-1)]",
13116
- children: entry.label
13117
- },
13118
- entry.key
13119
- );
13139
+ if (entry.kind === "group") {
13140
+ return /* @__PURE__ */ (0, import_jsx_runtime148.jsxs)("div", { role: "group", "aria-labelledby": entry.labelId, children: [
13141
+ /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
13142
+ "div",
13143
+ {
13144
+ id: entry.labelId,
13145
+ className: "px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-[var(--chekin-color-gray-1)]",
13146
+ children: entry.label
13147
+ }
13148
+ ),
13149
+ entry.options.map(renderOption)
13150
+ ] }, entry.key);
13120
13151
  }
13121
- const { option, flatIndex } = entry;
13122
- const isSelected = isOptionSelected2 ? isOptionSelected2(option, selectedList) : isOptionSelected(option, selectedValue, selectedValues);
13123
- const isHighlighted = flatIndex === highlightedIndex;
13124
- const optionDisabled = Boolean(
13125
- disabled || option.isDisabled || isOptionDisabled?.(option)
13126
- );
13127
- return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
13128
- Option,
13129
- {
13130
- id: getOptionId2(flatIndex),
13131
- option,
13132
- index: flatIndex,
13133
- isSelected,
13134
- isHighlighted,
13135
- isDisabled: optionDisabled,
13136
- isLast: flatIndex === lastIndex,
13137
- isMulti: Boolean(isMulti),
13138
- onClick: onOptionClick,
13139
- onHover: onOptionHover ?? (() => void 0),
13140
- innerRef: (node) => selectedOptionRef?.(flatIndex, node),
13141
- inputValue,
13142
- selectedOptions: selectedList,
13143
- formatOptionLabel
13144
- },
13145
- entry.key
13146
- );
13152
+ return renderOption(entry);
13147
13153
  }),
13148
13154
  footer
13149
13155
  ]
@@ -15148,13 +15154,7 @@ function createCountTrigger(opts) {
15148
15154
 
15149
15155
  // src/dashboard/select-checkboxes/SelectAllRow.tsx
15150
15156
  var import_jsx_runtime169 = require("react/jsx-runtime");
15151
- function SelectAllRow({
15152
- label,
15153
- checked,
15154
- indeterminate,
15155
- disabled,
15156
- onToggle
15157
- }) {
15157
+ function SelectAllRow({ label, checked, disabled, onToggle }) {
15158
15158
  return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)(
15159
15159
  "button",
15160
15160
  {
@@ -15169,7 +15169,7 @@ function SelectAllRow({
15169
15169
  /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(
15170
15170
  BaseCheckbox,
15171
15171
  {
15172
- checked: indeterminate ? "indeterminate" : checked,
15172
+ checked,
15173
15173
  disabled,
15174
15174
  size: "s",
15175
15175
  tabIndex: -1,
@@ -15205,7 +15205,6 @@ function SelectCheckboxesInternal(props, ref) {
15205
15205
  allowSelectAll = false,
15206
15206
  selectAllLabel,
15207
15207
  searchable = true,
15208
- searchPlaceholder,
15209
15208
  filterOption = defaultFilterOption,
15210
15209
  closeMenuOnSelect = false,
15211
15210
  onSearchChange,
@@ -15240,7 +15239,6 @@ function SelectCheckboxesInternal(props, ref) {
15240
15239
  return acc + (selected.some((s) => s.value === option.value) ? 1 : 0);
15241
15240
  }, 0);
15242
15241
  const allVisibleSelected = filteredFlat.length > 0 && visibleSelectedCount === filteredFlat.length;
15243
- const someVisibleSelected = visibleSelectedCount > 0 && visibleSelectedCount < filteredFlat.length;
15244
15242
  const handleToggleAll = React59.useCallback(() => {
15245
15243
  if (allVisibleSelected) {
15246
15244
  const visibleValues = new Set(filteredFlat.map((option) => option.value));
@@ -15276,7 +15274,6 @@ function SelectCheckboxesInternal(props, ref) {
15276
15274
  {
15277
15275
  label: selectAllLabel ?? t("select_all", { defaultValue: "Select All" }),
15278
15276
  checked: allVisibleSelected,
15279
- indeterminate: someVisibleSelected,
15280
15277
  onToggle: handleToggleAll
15281
15278
  }
15282
15279
  ) : void 0;
@@ -20311,44 +20308,59 @@ var React83 = __toESM(require("react"), 1);
20311
20308
  var SwitchPrimitives2 = __toESM(require("@radix-ui/react-switch"), 1);
20312
20309
  var import_lucide_react59 = require("lucide-react");
20313
20310
  var import_jsx_runtime196 = require("react/jsx-runtime");
20314
- var AirbnbSwitch = React83.forwardRef(({ className, value, onChange, disabled, loading, readOnly, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
20315
- SwitchPrimitives2.Root,
20316
- {
20317
- ref,
20318
- className: cn(
20319
- "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",
20320
- "focus-visible:outline-none focus-visible:shadow-[var(--chekin-shadow-focus)]",
20321
- "disabled:cursor-not-allowed disabled:opacity-50 aria-busy:cursor-wait aria-busy:opacity-50",
20322
- "aria-readonly:cursor-default aria-readonly:opacity-100",
20323
- "data-[state=checked]:bg-[#222222] data-[state=unchecked]:bg-[#E7E7E4]",
20324
- className
20325
- ),
20326
- disabled,
20327
- checked: value,
20328
- value: String(value),
20329
- onCheckedChange: !disabled && !readOnly ? onChange : void 0,
20330
- "aria-busy": loading,
20331
- "aria-readonly": readOnly,
20332
- ...props,
20333
- children: /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
20334
- SwitchPrimitives2.Thumb,
20335
- {
20336
- className: cn(
20337
- "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",
20338
- "data-[state=checked]:translate-x-[12px] data-[state=unchecked]:translate-x-0"
20339
- ),
20340
- children: /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
20341
- import_lucide_react59.Check,
20342
- {
20343
- "aria-hidden": "true",
20344
- className: "h-3 w-3 text-[#222222] opacity-0 transition-opacity duration-150 group-data-[state=checked]:opacity-100",
20345
- strokeWidth: 3
20346
- }
20347
- )
20348
- }
20349
- )
20311
+ var AirbnbSwitch = React83.forwardRef(({ className, value, onChange, disabled, loading, readOnly, id, label, error, wrapperClassName, ...props }, ref) => {
20312
+ const generatedId = React83.useId();
20313
+ const fieldId = id || generatedId;
20314
+ const switchElement = /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
20315
+ SwitchPrimitives2.Root,
20316
+ {
20317
+ ref,
20318
+ className: cn(
20319
+ "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",
20320
+ "focus-visible:outline-none focus-visible:shadow-[var(--chekin-shadow-focus)]",
20321
+ "disabled:cursor-not-allowed disabled:opacity-50 aria-busy:cursor-wait aria-busy:opacity-50",
20322
+ "aria-readonly:cursor-default aria-readonly:opacity-100",
20323
+ "data-[state=checked]:bg-[#222222] data-[state=unchecked]:bg-[#E7E7E4]",
20324
+ className
20325
+ ),
20326
+ id: fieldId,
20327
+ disabled,
20328
+ checked: value,
20329
+ value: String(value),
20330
+ onCheckedChange: !disabled && !readOnly ? onChange : void 0,
20331
+ "aria-busy": loading,
20332
+ "aria-readonly": readOnly,
20333
+ ...props,
20334
+ children: /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
20335
+ SwitchPrimitives2.Thumb,
20336
+ {
20337
+ className: cn(
20338
+ "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",
20339
+ "data-[state=checked]:translate-x-[12px] data-[state=unchecked]:translate-x-0"
20340
+ ),
20341
+ children: /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
20342
+ import_lucide_react59.Check,
20343
+ {
20344
+ "aria-hidden": "true",
20345
+ className: "h-3 w-3 text-[#222222] opacity-0 transition-opacity duration-150 group-data-[state=checked]:opacity-100",
20346
+ strokeWidth: 3
20347
+ }
20348
+ )
20349
+ }
20350
+ )
20351
+ }
20352
+ );
20353
+ if (!label && !error) {
20354
+ return switchElement;
20350
20355
  }
20351
- ));
20356
+ return /* @__PURE__ */ (0, import_jsx_runtime196.jsxs)(import_jsx_runtime196.Fragment, { children: [
20357
+ /* @__PURE__ */ (0, import_jsx_runtime196.jsxs)("div", { className: cn("flex items-center gap-x-3 gap-y-1.5", wrapperClassName), children: [
20358
+ switchElement,
20359
+ label && /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(Label, { htmlFor: fieldId, className: "cursor-pointer text-base font-medium", children: label })
20360
+ ] }),
20361
+ error && /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(ErrorMessage, { disabled, children: error })
20362
+ ] });
20363
+ });
20352
20364
  AirbnbSwitch.displayName = "AirbnbSwitch";
20353
20365
  // Annotate the CommonJS export names for ESM import in node:
20354
20366
  0 && (module.exports = {