@snapcall/design-system 1.14.2 → 1.14.4

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.mts CHANGED
@@ -154,21 +154,28 @@ declare const CommandItem: react.ForwardRefExoticComponent<Omit<{
154
154
  type StringKeys<T> = {
155
155
  [K in keyof T]: T[K] extends string ? K : never;
156
156
  }[keyof T];
157
- interface CreatableSelectProps<T, Multiple extends boolean> {
157
+ interface CreatableSelectBaseProps<Multiple extends boolean> {
158
158
  isLoading?: boolean;
159
- items: T[];
160
159
  multiple?: Multiple;
161
160
  newLabel?: string;
162
161
  nothingFoundLabel?: string;
163
162
  placeholder?: string;
164
163
  value: string[];
165
- valueKey: StringKeys<T>;
166
164
  onValueChanged: (v: string[]) => void;
165
+ 'data-has-error'?: string;
166
+ }
167
+ type WithItemsProps<T> = {
168
+ items: T[];
169
+ valueKey: StringKeys<T>;
167
170
  getItemProps: (item: T) => CommandItemExtension & {
168
171
  children: react__default.ReactNode;
169
172
  };
170
- 'data-has-error'?: string;
171
- }
173
+ };
174
+ type CreatableSelectProps<T, Multiple extends boolean> = (CreatableSelectBaseProps<Multiple> & WithItemsProps<T>) | (CreatableSelectBaseProps<Multiple> & {
175
+ items?: never;
176
+ valueKey?: never;
177
+ getItemProps?: never;
178
+ });
172
179
  declare function CreatableSelect<T, Multiple extends boolean>({ isLoading, items, multiple, newLabel, nothingFoundLabel, placeholder, value, valueKey, onValueChanged, getItemProps, ...props }: CreatableSelectProps<T, Multiple>): react_jsx_runtime.JSX.Element;
173
180
 
174
181
  declare const Dialog: react.FC<DialogPrimitive.DialogProps>;
package/dist/index.d.ts CHANGED
@@ -154,21 +154,28 @@ declare const CommandItem: react.ForwardRefExoticComponent<Omit<{
154
154
  type StringKeys<T> = {
155
155
  [K in keyof T]: T[K] extends string ? K : never;
156
156
  }[keyof T];
157
- interface CreatableSelectProps<T, Multiple extends boolean> {
157
+ interface CreatableSelectBaseProps<Multiple extends boolean> {
158
158
  isLoading?: boolean;
159
- items: T[];
160
159
  multiple?: Multiple;
161
160
  newLabel?: string;
162
161
  nothingFoundLabel?: string;
163
162
  placeholder?: string;
164
163
  value: string[];
165
- valueKey: StringKeys<T>;
166
164
  onValueChanged: (v: string[]) => void;
165
+ 'data-has-error'?: string;
166
+ }
167
+ type WithItemsProps<T> = {
168
+ items: T[];
169
+ valueKey: StringKeys<T>;
167
170
  getItemProps: (item: T) => CommandItemExtension & {
168
171
  children: react__default.ReactNode;
169
172
  };
170
- 'data-has-error'?: string;
171
- }
173
+ };
174
+ type CreatableSelectProps<T, Multiple extends boolean> = (CreatableSelectBaseProps<Multiple> & WithItemsProps<T>) | (CreatableSelectBaseProps<Multiple> & {
175
+ items?: never;
176
+ valueKey?: never;
177
+ getItemProps?: never;
178
+ });
172
179
  declare function CreatableSelect<T, Multiple extends boolean>({ isLoading, items, multiple, newLabel, nothingFoundLabel, placeholder, value, valueKey, onValueChanged, getItemProps, ...props }: CreatableSelectProps<T, Multiple>): react_jsx_runtime.JSX.Element;
173
180
 
174
181
  declare const Dialog: react.FC<DialogPrimitive.DialogProps>;
package/dist/index.js CHANGED
@@ -53375,15 +53375,23 @@ function CreatableSelect(_a) {
53375
53375
  },
53376
53376
  [onValueChanged, value]
53377
53377
  );
53378
- const selectables = items.filter(
53378
+ const selectables = items == null ? void 0 : items.filter(
53379
53379
  (it) => !value.includes(it[valueKey])
53380
53380
  );
53381
53381
  const selectNewValue = () => {
53382
- onValueChanged(
53383
- multiple ? [...value, ...inputValue.split(",").map((it) => it.trim())] : [inputValue]
53384
- );
53382
+ if (!value.includes(inputValue)) {
53383
+ onValueChanged(
53384
+ multiple ? [...value, ...inputValue.split(",").map((it) => it.trim())] : [inputValue]
53385
+ );
53386
+ }
53385
53387
  setInputValue("");
53388
+ if (!items) {
53389
+ setOpen(false);
53390
+ }
53386
53391
  };
53392
+ if (!inputValue && !items && open) {
53393
+ setOpen(false);
53394
+ }
53387
53395
  return /* @__PURE__ */ (0, import_jsx_runtime1232.jsxs)(
53388
53396
  Command,
53389
53397
  {
@@ -53423,6 +53431,9 @@ function CreatableSelect(_a) {
53423
53431
  ref: inputRef,
53424
53432
  value: inputValue,
53425
53433
  onValueChange: (v) => {
53434
+ if (!open) {
53435
+ setOpen(true);
53436
+ }
53426
53437
  setInputValue(v);
53427
53438
  !multiple && onValueChanged([]);
53428
53439
  },
@@ -53432,7 +53443,11 @@ function CreatableSelect(_a) {
53432
53443
  selectNewValue();
53433
53444
  }
53434
53445
  },
53435
- onFocus: () => setOpen(true),
53446
+ onFocus: () => {
53447
+ if (items) {
53448
+ setOpen(true);
53449
+ }
53450
+ },
53436
53451
  placeholder: multiple || value.length === 0 ? placeholder : "",
53437
53452
  className: "flex-grow text-sm bg-transparent outline-none text-gray-1000 placeholder:text-gray-700"
53438
53453
  }
@@ -53440,8 +53455,8 @@ function CreatableSelect(_a) {
53440
53455
  ] })
53441
53456
  }
53442
53457
  ),
53443
- /* @__PURE__ */ (0, import_jsx_runtime1232.jsx)("div", { className: "relative", children: open && /* @__PURE__ */ (0, import_jsx_runtime1232.jsx)("div", { className: "absolute z-50 w-full bg-white border rounded-md shadow-md outline-none top-2 text-gray-1000 animate-in max-h-[180px] overflow-auto", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime1232.jsx)(CommandLoading, {}) : selectables.length < 1 ? /* @__PURE__ */ (0, import_jsx_runtime1232.jsx)("span", { className: "flex flex-col gap-4 p-4 text-center text-gray-700", children: nothingFoundLabel }) : /* @__PURE__ */ (0, import_jsx_runtime1232.jsxs)(CommandList, { className: "h-full overflow-auto", children: [
53444
- selectables.map((it) => {
53458
+ /* @__PURE__ */ (0, import_jsx_runtime1232.jsx)("div", { className: "relative", children: open && /* @__PURE__ */ (0, import_jsx_runtime1232.jsx)("div", { className: "absolute z-50 w-full bg-white border rounded-md shadow-md outline-none top-2 text-gray-1000 animate-in", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime1232.jsx)(CommandLoading, {}) : selectables && selectables.length < 1 ? /* @__PURE__ */ (0, import_jsx_runtime1232.jsx)("span", { className: "flex flex-col gap-4 p-4 text-center text-gray-700", children: nothingFoundLabel }) : /* @__PURE__ */ (0, import_jsx_runtime1232.jsxs)(CommandList, { className: "h-full max-h-[180px] overflow-auto", children: [
53459
+ items && (selectables == null ? void 0 : selectables.map((it) => {
53445
53460
  const itemProps = getItemProps(it);
53446
53461
  return /* @__PURE__ */ (0, import_jsx_runtime1232.jsx)(
53447
53462
  CommandItem,
@@ -53460,7 +53475,7 @@ function CreatableSelect(_a) {
53460
53475
  }, itemProps),
53461
53476
  it[valueKey]
53462
53477
  );
53463
- }),
53478
+ })),
53464
53479
  inputValue && !value.includes(inputValue) && /* @__PURE__ */ (0, import_jsx_runtime1232.jsx)(
53465
53480
  CommandItem,
53466
53481
  {
package/dist/index.mjs CHANGED
@@ -52018,15 +52018,23 @@ function CreatableSelect(_a) {
52018
52018
  },
52019
52019
  [onValueChanged, value]
52020
52020
  );
52021
- const selectables = items.filter(
52021
+ const selectables = items == null ? void 0 : items.filter(
52022
52022
  (it) => !value.includes(it[valueKey])
52023
52023
  );
52024
52024
  const selectNewValue = () => {
52025
- onValueChanged(
52026
- multiple ? [...value, ...inputValue.split(",").map((it) => it.trim())] : [inputValue]
52027
- );
52025
+ if (!value.includes(inputValue)) {
52026
+ onValueChanged(
52027
+ multiple ? [...value, ...inputValue.split(",").map((it) => it.trim())] : [inputValue]
52028
+ );
52029
+ }
52028
52030
  setInputValue("");
52031
+ if (!items) {
52032
+ setOpen(false);
52033
+ }
52029
52034
  };
52035
+ if (!inputValue && !items && open) {
52036
+ setOpen(false);
52037
+ }
52030
52038
  return /* @__PURE__ */ jsxs1011(
52031
52039
  Command,
52032
52040
  {
@@ -52066,6 +52074,9 @@ function CreatableSelect(_a) {
52066
52074
  ref: inputRef,
52067
52075
  value: inputValue,
52068
52076
  onValueChange: (v) => {
52077
+ if (!open) {
52078
+ setOpen(true);
52079
+ }
52069
52080
  setInputValue(v);
52070
52081
  !multiple && onValueChanged([]);
52071
52082
  },
@@ -52075,7 +52086,11 @@ function CreatableSelect(_a) {
52075
52086
  selectNewValue();
52076
52087
  }
52077
52088
  },
52078
- onFocus: () => setOpen(true),
52089
+ onFocus: () => {
52090
+ if (items) {
52091
+ setOpen(true);
52092
+ }
52093
+ },
52079
52094
  placeholder: multiple || value.length === 0 ? placeholder : "",
52080
52095
  className: "flex-grow text-sm bg-transparent outline-none text-gray-1000 placeholder:text-gray-700"
52081
52096
  }
@@ -52083,8 +52098,8 @@ function CreatableSelect(_a) {
52083
52098
  ] })
52084
52099
  }
52085
52100
  ),
52086
- /* @__PURE__ */ jsx1232("div", { className: "relative", children: open && /* @__PURE__ */ jsx1232("div", { className: "absolute z-50 w-full bg-white border rounded-md shadow-md outline-none top-2 text-gray-1000 animate-in max-h-[180px] overflow-auto", children: isLoading ? /* @__PURE__ */ jsx1232(CommandLoading, {}) : selectables.length < 1 ? /* @__PURE__ */ jsx1232("span", { className: "flex flex-col gap-4 p-4 text-center text-gray-700", children: nothingFoundLabel }) : /* @__PURE__ */ jsxs1011(CommandList, { className: "h-full overflow-auto", children: [
52087
- selectables.map((it) => {
52101
+ /* @__PURE__ */ jsx1232("div", { className: "relative", children: open && /* @__PURE__ */ jsx1232("div", { className: "absolute z-50 w-full bg-white border rounded-md shadow-md outline-none top-2 text-gray-1000 animate-in", children: isLoading ? /* @__PURE__ */ jsx1232(CommandLoading, {}) : selectables && selectables.length < 1 ? /* @__PURE__ */ jsx1232("span", { className: "flex flex-col gap-4 p-4 text-center text-gray-700", children: nothingFoundLabel }) : /* @__PURE__ */ jsxs1011(CommandList, { className: "h-full max-h-[180px] overflow-auto", children: [
52102
+ items && (selectables == null ? void 0 : selectables.map((it) => {
52088
52103
  const itemProps = getItemProps(it);
52089
52104
  return /* @__PURE__ */ jsx1232(
52090
52105
  CommandItem,
@@ -52103,7 +52118,7 @@ function CreatableSelect(_a) {
52103
52118
  }, itemProps),
52104
52119
  it[valueKey]
52105
52120
  );
52106
- }),
52121
+ })),
52107
52122
  inputValue && !value.includes(inputValue) && /* @__PURE__ */ jsx1232(
52108
52123
  CommandItem,
52109
52124
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcall/design-system",
3
- "version": "1.14.2",
3
+ "version": "1.14.4",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",