@max-ts/kit 1.5.1 → 1.5.2

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.
@@ -1,8 +1,8 @@
1
1
  import type { SelectProps } from './types';
2
- declare function Select<Value = string, Multiple extends boolean | undefined = false>({ onValueChange, ...props }: SelectProps.Root<Value, Multiple>): import("react").JSX.Element;
2
+ declare function Select<Value = string, Multiple extends boolean | undefined = false>({ defaultValue, disabled, isItemEqualToValue, itemToStringLabel, items, multiple, onValueChange, value: valueProp, ...props }: SelectProps.Root<Value, Multiple>): import("react").JSX.Element;
3
3
  declare namespace Select {
4
- var Trigger: ({ className, children, size, ...props }: SelectProps.Trigger) => import("react").JSX.Element;
5
- var Value: ({ ...props }: SelectProps.Value) => import("react").JSX.Element;
4
+ var Trigger: ({ className, children, render, size, ...props }: SelectProps.Trigger) => import("react").JSX.Element;
5
+ var Value: ({ className, children, placeholder, ...props }: SelectProps.Value) => import("react").JSX.Element;
6
6
  var Content: ({ className, children, side, sideOffset, align, alignOffset, alignItemWithTrigger, position, ...props }: SelectProps.Content) => import("react").JSX.Element;
7
7
  var Group: ({ ...props }: SelectProps.Group) => import("react").JSX.Element;
8
8
  var Label: ({ className, ...props }: SelectProps.Label) => import("react").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,iBAAS,MAAM,CAAC,KAAK,GAAG,MAAM,EAAE,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,KAAK,EAAE,EAC7E,aAAa,EACb,GAAG,KAAK,EACR,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,+BAYnC;kBAfQ,MAAM;2DA8BZ,WAAW,CAAC,OAAO;8BATO,WAAW,CAAC,KAAK;2HA+D3C,WAAW,CAAC,OAAO;8BAnEO,WAAW,CAAC,KAAK;yCAoGN,WAAW,CAAC,KAAK;kDAUR,WAAW,CAAC,IAAI;oDAjE9D,WAAW,CAAC,gBAAgB;kDAfkB,WAAW,CAAC,cAAc;6CAoG/B,WAAW,CAAC,SAAS;;AAoBjE,YAAY,EAAE,WAAW,EAAE,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAS3C,iBAAS,MAAM,CAAC,KAAK,GAAG,MAAM,EAAE,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,KAAK,EAAE,EAC7E,YAAY,EACZ,QAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACL,QAAQ,EACR,aAAa,EACb,KAAK,EAAE,SAAS,EAChB,GAAG,KAAK,EACR,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,+BA+BnC;kBAzCQ,MAAM;mEA8FZ,WAAW,CAAC,OAAO;gEA1CnB,WAAW,CAAC,KAAK;2HAkGjB,WAAW,CAAC,OAAO;8BA3GO,WAAW,CAAC,KAAK;yCA4IN,WAAW,CAAC,KAAK;kDAUR,WAAW,CAAC,IAAI;oDAjE9D,WAAW,CAAC,gBAAgB;kDAfkB,WAAW,CAAC,cAAc;6CAoG/B,WAAW,CAAC,SAAS;;AAoGjE,YAAY,EAAE,WAAW,EAAE,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -1,4 +1,10 @@
1
1
  export declare const trigger: string;
2
+ export declare const value: string;
3
+ export declare const chipsValue: string;
4
+ export declare const chipsMeasure: string;
5
+ export declare const chip: string;
6
+ export declare const chipLabel: string;
7
+ export declare const chipRemove: string;
2
8
  export declare const scrollButton: string;
3
9
  export declare const positioner: string;
4
10
  export declare const content: string;
@@ -1 +1 @@
1
- {"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../../../src/components/Select/styles.css.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,OAAO,QAwClB,CAAC;AAQH,eAAO,MAAM,YAAY,QAMvB,CAAC;AAEH,eAAO,MAAM,UAAU,QAGrB,CAAC;AAEH,eAAO,MAAM,OAAO,QAgClB,CAAC;AAEH,eAAO,MAAM,QAAQ,QAInB,CAAC;AAEH,eAAO,MAAM,KAAK,QAIhB,CAAC;AAEH,eAAO,MAAM,IAAI,QAsBf,CAAC;AAEH,eAAO,MAAM,oBAAoB,QAQ/B,CAAC;AAEH,eAAO,MAAM,SAAS,QAIpB,CAAC;AAEH,eAAO,MAAM,IAAI,QAGf,CAAC;AAEH,eAAO,MAAM,OAAO,QAIlB,CAAC"}
1
+ {"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../../../src/components/Select/styles.css.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,OAAO,QA4ClB,CAAC;AAQH,eAAO,MAAM,KAAK,QAMhB,CAAC;AAEH,eAAO,MAAM,UAAU,QAQrB,CAAC;AAEH,eAAO,MAAM,YAAY,QASvB,CAAC;AAEH,eAAO,MAAM,IAAI,QAef,CAAC;AAEH,eAAO,MAAM,SAAS,QAIpB,CAAC;AAEH,eAAO,MAAM,UAAU,QAwBrB,CAAC;AAQH,eAAO,MAAM,YAAY,QAMvB,CAAC;AAEH,eAAO,MAAM,UAAU,QAGrB,CAAC;AAEH,eAAO,MAAM,OAAO,QAgClB,CAAC;AAEH,eAAO,MAAM,QAAQ,QAInB,CAAC;AAEH,eAAO,MAAM,KAAK,QAIhB,CAAC;AAEH,eAAO,MAAM,IAAI,QAsBf,CAAC;AAEH,eAAO,MAAM,oBAAoB,QAQ/B,CAAC;AAEH,eAAO,MAAM,SAAS,QAIpB,CAAC;AAEH,eAAO,MAAM,IAAI,QAGf,CAAC;AAEH,eAAO,MAAM,OAAO,QAIlB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './useLogic';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/useLogic/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { Select as SelectPrimitive } from '@base-ui/react/select';
2
+ import { type MouseEvent, type ReactNode } from 'react';
3
+ import type { SelectProps } from '../types';
4
+ type SelectContextValue = {
5
+ disabled: boolean;
6
+ getLabel: (value: unknown) => ReactNode;
7
+ multiple: boolean;
8
+ removeValue: (value: unknown, event: MouseEvent<HTMLButtonElement>) => void;
9
+ value: unknown;
10
+ };
11
+ declare const SelectContext: import("react").Context<SelectContextValue | null>;
12
+ export declare function getValueKey(value: unknown): string;
13
+ export declare function useSelectContext(): SelectContextValue;
14
+ export declare function useRootLogic<Value = string, Multiple extends boolean | undefined = false>({ defaultValue, disabled, isItemEqualToValue, itemToStringLabel, items, multiple, onValueChange, value: valueProp, }: SelectProps.Root<Value, Multiple>): {
15
+ contextValue: SelectContextValue;
16
+ handleValueChange: (nextValue: unknown, eventDetails: SelectPrimitive.Root.ChangeEventDetails) => void;
17
+ value: unknown;
18
+ };
19
+ export declare function useChipsValueLogic(values: unknown[]): {
20
+ containerRef: import("react").RefObject<HTMLSpanElement | null>;
21
+ getLabel: (value: unknown) => ReactNode;
22
+ hiddenCount: number;
23
+ measureRef: import("react").RefObject<HTMLSpanElement | null>;
24
+ overflowMeasureRef: import("react").RefObject<HTMLSpanElement | null>;
25
+ visibleValues: unknown[];
26
+ };
27
+ export { SelectContext };
28
+ //# sourceMappingURL=useLogic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLogic.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/useLogic/useLogic.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAEN,KAAK,UAAU,EACf,KAAK,SAAS,EAQd,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,KAAK,kBAAkB,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,SAAS,CAAC;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC5E,KAAK,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,QAAA,MAAM,aAAa,oDAAiD,CAAC;AAUrE,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,UAEzC;AAED,wBAAgB,gBAAgB,uBAQ/B;AAED,wBAAgB,YAAY,CAC3B,KAAK,GAAG,MAAM,EACd,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,KAAK,EAC3C,EACD,YAAY,EACZ,QAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACL,QAAQ,EACR,aAAa,EACb,KAAK,EAAE,SAAS,GAChB,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC;;mCAStB,OAAO,gBACJ,eAAe,CAAC,IAAI,CAAC,kBAAkB;;EAyDvD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE;;sBA/GjC,OAAO,KAAK,SAAS;;;;;EAwLvC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
package/lib/index.mjs CHANGED
@@ -25,7 +25,10 @@ import { Toaster, toast } from "sonner";
25
25
  import { RadioGroup as radio_group_RadioGroup } from "@base-ui/react/radio-group";
26
26
  import { Radio } from "@base-ui/react/radio";
27
27
  import { Slider } from "@base-ui/react/slider";
28
+ import { resolveSelectedLabel, stringifyAsLabel } from "@base-ui/react/internals/resolveValueLabel";
28
29
  import { Select } from "@base-ui/react/select";
30
+ import { createChangeEventDetails } from "@base-ui/react/internals/createBaseUIEventDetails";
31
+ import { REASONS } from "@base-ui/react/internals/reasons";
29
32
  import { Tabs } from "@base-ui/react/tabs";
30
33
  import * as __rspack_external_react from "react";
31
34
  var __webpack_require__ = {};
@@ -2095,7 +2098,7 @@ function Row({ row, rowHeight, onRowClick, columns, rowIndex, rowId }) {
2095
2098
  })
2096
2099
  });
2097
2100
  }
2098
- var container = 'style__15m2ib80';
2101
+ var styles_css_container = 'style__15m2ib80';
2099
2102
  var loader = 'style__15m2ib81';
2100
2103
  function State({ isLoading, isEmpty, columnsLength, emptyState = {
2101
2104
  text: 'Нет данных'
@@ -2103,7 +2106,7 @@ function State({ isLoading, isEmpty, columnsLength, emptyState = {
2103
2106
  text: 'Произошла ошибка'
2104
2107
  }, isError, onRetry }) {
2105
2108
  const Container = ({ children })=>/*#__PURE__*/ jsx("tr", {
2106
- className: container,
2109
+ className: styles_css_container,
2107
2110
  children: /*#__PURE__*/ jsx("td", {
2108
2111
  colSpan: columnsLength,
2109
2112
  align: "center",
@@ -2143,12 +2146,12 @@ function State({ isLoading, isEmpty, columnsLength, emptyState = {
2143
2146
  }
2144
2147
  return null;
2145
2148
  }
2146
- var styles_css_container = 'style__82af400';
2149
+ var Body_styles_css_container = 'style__82af400';
2147
2150
  function Body({ isError, isLoading, emptyState, errorState, columns, rows, rowHeight, keyId, onRowClick }) {
2148
2151
  const isEmpty = 0 === rows.length;
2149
2152
  const isStateVisible = isError || isLoading || isEmpty;
2150
2153
  return isStateVisible ? /*#__PURE__*/ jsx("tbody", {
2151
- className: styles_css_container,
2154
+ className: Body_styles_css_container,
2152
2155
  children: /*#__PURE__*/ jsx(State, {
2153
2156
  emptyState: emptyState,
2154
2157
  errorState: errorState,
@@ -2158,7 +2161,7 @@ function Body({ isError, isLoading, emptyState, errorState, columns, rows, rowHe
2158
2161
  columnsLength: columns.length
2159
2162
  })
2160
2163
  }) : /*#__PURE__*/ jsx("tbody", {
2161
- className: styles_css_container,
2164
+ className: Body_styles_css_container,
2162
2165
  children: rows.map((row, index)=>{
2163
2166
  const rowId = String(row[keyId]);
2164
2167
  return /*#__PURE__*/ jsx(Row, {
@@ -4274,24 +4277,161 @@ function ScrollTopButton({ onClick, variant = 'outline', ...props }) {
4274
4277
  children: /*#__PURE__*/ jsx(ChevronUp, {})
4275
4278
  });
4276
4279
  }
4277
- var chevron = 'style__5ilg7oc';
4278
- var Select_styles_css_content = 'style__5ilg7o5';
4279
- var Select_styles_css_icon = 'style__5ilg7ob';
4280
- var Select_styles_css_item = 'style__5ilg7o8';
4281
- var itemIndicatorWrapper = 'style__5ilg7o9';
4282
- var Select_styles_css_label = 'style__5ilg7o7';
4283
- var Select_styles_css_positioner = 'style__5ilg7o4';
4284
- var scrollButton = 'style__5ilg7o3';
4285
- var Select_styles_css_separator = 'style__5ilg7oa';
4280
+ var chevron = 'style__5ilg7oi';
4281
+ var styles_css_chip = 'style__5ilg7o6';
4282
+ var chipLabel = 'style__5ilg7o7';
4283
+ var styles_css_chipRemove = 'style__5ilg7o8';
4284
+ var chipsMeasure = 'style__5ilg7o5';
4285
+ var chipsValue = 'style__5ilg7o4';
4286
+ var Select_styles_css_content = 'style__5ilg7ob';
4287
+ var Select_styles_css_icon = 'style__5ilg7oh';
4288
+ var Select_styles_css_item = 'style__5ilg7oe';
4289
+ var itemIndicatorWrapper = 'style__5ilg7of';
4290
+ var Select_styles_css_label = 'style__5ilg7od';
4291
+ var Select_styles_css_positioner = 'style__5ilg7oa';
4292
+ var scrollButton = 'style__5ilg7o9';
4293
+ var Select_styles_css_separator = 'style__5ilg7og';
4286
4294
  var Select_styles_css_trigger = 'style__5ilg7o2';
4287
- var Select_styles_css_viewport = 'style__5ilg7o6';
4288
- function Select_Select({ onValueChange, ...props }) {
4289
- return /*#__PURE__*/ jsx(Select.Root, {
4290
- "data-slot": "select",
4291
- ...props,
4292
- onValueChange: (value, eventDetails)=>{
4293
- if (null !== value) onValueChange?.(value, eventDetails);
4295
+ var styles_css_value = 'style__5ilg7o3';
4296
+ var Select_styles_css_viewport = 'style__5ilg7oc';
4297
+ const SelectContext = createContext(null);
4298
+ function getInitialValue({ defaultValue, multiple }) {
4299
+ if (void 0 !== defaultValue) return defaultValue;
4300
+ return multiple ? [] : null;
4301
+ }
4302
+ function getValueKey(value) {
4303
+ return stringifyAsLabel(value);
4304
+ }
4305
+ function useSelectContext() {
4306
+ const context = useContext(SelectContext);
4307
+ if (!context) throw new Error('useSelectContext must be used within a <Select />');
4308
+ return context;
4309
+ }
4310
+ function useRootLogic({ defaultValue, disabled = false, isItemEqualToValue, itemToStringLabel, items, multiple, onValueChange, value: valueProp }) {
4311
+ const isControlled = void 0 !== valueProp;
4312
+ const [internalValue, setInternalValue] = useState(()=>getInitialValue({
4313
+ defaultValue,
4314
+ multiple
4315
+ }));
4316
+ const value = isControlled ? valueProp : internalValue;
4317
+ const handleValueChange = useCallback((nextValue, eventDetails)=>{
4318
+ if (!isControlled) setInternalValue(nextValue);
4319
+ onValueChange?.(nextValue, eventDetails);
4320
+ }, [
4321
+ isControlled,
4322
+ onValueChange
4323
+ ]);
4324
+ const contextValue = useMemo(()=>({
4325
+ disabled,
4326
+ getLabel: (itemValue)=>resolveSelectedLabel(itemValue, items, itemToStringLabel),
4327
+ multiple: Boolean(multiple),
4328
+ removeValue: (itemValue, event)=>{
4329
+ event.preventDefault();
4330
+ event.stopPropagation();
4331
+ const currentValue = Array.isArray(value) ? value : [];
4332
+ const nextValue = currentValue.filter((selectedValue)=>{
4333
+ const isEqual = isItemEqualToValue ?? Object.is;
4334
+ return !isEqual(itemValue, selectedValue);
4335
+ });
4336
+ handleValueChange(nextValue, createChangeEventDetails(REASONS.chipRemovePress, event.nativeEvent, event.currentTarget));
4337
+ },
4338
+ value
4339
+ }), [
4340
+ disabled,
4341
+ handleValueChange,
4342
+ isItemEqualToValue,
4343
+ itemToStringLabel,
4344
+ items,
4345
+ multiple,
4346
+ value
4347
+ ]);
4348
+ return {
4349
+ contextValue,
4350
+ handleValueChange,
4351
+ value
4352
+ };
4353
+ }
4354
+ function useChipsValueLogic(values) {
4355
+ const { getLabel } = useSelectContext();
4356
+ const containerRef = useRef(null);
4357
+ const measureRef = useRef(null);
4358
+ const overflowMeasureRef = useRef(null);
4359
+ const [visibleCount, setVisibleCount] = useState(values.length);
4360
+ const updateVisibleCount = useCallback(()=>{
4361
+ const container = containerRef.current;
4362
+ const measure = measureRef.current;
4363
+ const overflowMeasure = overflowMeasureRef.current;
4364
+ if (!container || !measure || !overflowMeasure) return;
4365
+ const chipElements = Array.from(measure.querySelectorAll('[data-chip-measure="chip"]'));
4366
+ const stylesDeclaration = window.getComputedStyle(measure);
4367
+ const gap = Number.parseFloat(stylesDeclaration.columnGap || '0') || 0;
4368
+ const availableWidth = container.clientWidth;
4369
+ const chipWidths = chipElements.map((element)=>element.offsetWidth);
4370
+ const totalWidth = chipWidths.reduce((total, width, index)=>total + width + (index > 0 ? gap : 0), 0);
4371
+ if (totalWidth <= availableWidth) return void setVisibleCount(values.length);
4372
+ const overflowWidth = overflowMeasure.offsetWidth;
4373
+ const availableForChips = Math.max(0, availableWidth - overflowWidth - gap);
4374
+ let nextVisibleCount = 0;
4375
+ let usedWidth = 0;
4376
+ for (const chipWidth of chipWidths){
4377
+ const nextWidth = usedWidth + chipWidth + (nextVisibleCount > 0 ? gap : 0);
4378
+ if (nextWidth > availableForChips) break;
4379
+ usedWidth = nextWidth;
4380
+ nextVisibleCount += 1;
4294
4381
  }
4382
+ setVisibleCount(nextVisibleCount);
4383
+ }, [
4384
+ values.length
4385
+ ]);
4386
+ useLayoutEffect(()=>{
4387
+ updateVisibleCount();
4388
+ }, [
4389
+ updateVisibleCount
4390
+ ]);
4391
+ useEffect(()=>{
4392
+ const container = containerRef.current;
4393
+ if (!container || "u" < typeof ResizeObserver) return;
4394
+ const observer = new ResizeObserver(updateVisibleCount);
4395
+ observer.observe(container);
4396
+ return ()=>observer.disconnect();
4397
+ }, [
4398
+ updateVisibleCount
4399
+ ]);
4400
+ return {
4401
+ containerRef,
4402
+ getLabel,
4403
+ hiddenCount: Math.max(0, values.length - visibleCount),
4404
+ measureRef,
4405
+ overflowMeasureRef,
4406
+ visibleValues: values.slice(0, visibleCount)
4407
+ };
4408
+ }
4409
+ function Select_Select({ defaultValue, disabled = false, isItemEqualToValue, itemToStringLabel, items, multiple, onValueChange, value: valueProp, ...props }) {
4410
+ const { contextValue, handleValueChange, value } = useRootLogic({
4411
+ defaultValue,
4412
+ disabled,
4413
+ isItemEqualToValue,
4414
+ itemToStringLabel,
4415
+ items,
4416
+ multiple,
4417
+ onValueChange,
4418
+ value: valueProp
4419
+ });
4420
+ return /*#__PURE__*/ jsx(SelectContext.Provider, {
4421
+ value: contextValue,
4422
+ children: /*#__PURE__*/ jsx(Select.Root, {
4423
+ "data-slot": "select",
4424
+ disabled: disabled,
4425
+ isItemEqualToValue: isItemEqualToValue,
4426
+ itemToStringLabel: itemToStringLabel,
4427
+ items: items,
4428
+ multiple: multiple,
4429
+ value: value,
4430
+ ...props,
4431
+ onValueChange: (nextValue, eventDetails)=>{
4432
+ if (null !== nextValue) handleValueChange(nextValue, eventDetails);
4433
+ }
4434
+ })
4295
4435
  });
4296
4436
  }
4297
4437
  function Select_Group({ ...props }) {
@@ -4300,16 +4440,35 @@ function Select_Group({ ...props }) {
4300
4440
  ...props
4301
4441
  });
4302
4442
  }
4303
- function Select_Value({ ...props }) {
4443
+ function Select_Value({ className, children, placeholder, ...props }) {
4444
+ const context = useSelectContext();
4445
+ if (!context.multiple || children) return /*#__PURE__*/ jsx(Select.Value, {
4446
+ "data-slot": "select-value",
4447
+ className: clsx(styles_css_value, className),
4448
+ placeholder: placeholder,
4449
+ ...props,
4450
+ children: children
4451
+ });
4304
4452
  return /*#__PURE__*/ jsx(Select.Value, {
4305
4453
  "data-slot": "select-value",
4306
- ...props
4454
+ className: clsx(styles_css_value, className),
4455
+ placeholder: placeholder,
4456
+ ...props,
4457
+ children: (selectedValue)=>{
4458
+ const values = Array.isArray(selectedValue) ? selectedValue : [];
4459
+ if (0 === values.length) return placeholder;
4460
+ return /*#__PURE__*/ jsx(ChipsValue, {
4461
+ values: values
4462
+ });
4463
+ }
4307
4464
  });
4308
4465
  }
4309
- function Select_Trigger({ className, children, size = 'medium', ...props }) {
4466
+ function Select_Trigger({ className, children, render, size = 'medium', ...props }) {
4310
4467
  return /*#__PURE__*/ jsxs(Select.Trigger, {
4311
4468
  "data-slot": "select-trigger",
4312
4469
  "data-size": size,
4470
+ nativeButton: false,
4471
+ render: render ?? /*#__PURE__*/ jsx("div", {}),
4313
4472
  className: clsx(Select_styles_css_trigger, className),
4314
4473
  ...props,
4315
4474
  children: [
@@ -4405,6 +4564,82 @@ function Select_Separator({ className, ...props }) {
4405
4564
  ...props
4406
4565
  });
4407
4566
  }
4567
+ function Select_Chip({ count, value }) {
4568
+ const { disabled, getLabel, removeValue } = useSelectContext();
4569
+ const label = count ? `+${count}` : getLabel(value);
4570
+ const removeLabel = stringifyAsLabel(value);
4571
+ const handlePointerDown = (event)=>{
4572
+ event.preventDefault();
4573
+ event.stopPropagation();
4574
+ };
4575
+ return /*#__PURE__*/ jsxs("span", {
4576
+ className: styles_css_chip,
4577
+ "data-slot": "select-value-chip",
4578
+ children: [
4579
+ /*#__PURE__*/ jsx("span", {
4580
+ className: chipLabel,
4581
+ children: label
4582
+ }),
4583
+ !count && /*#__PURE__*/ jsx("button", {
4584
+ "aria-label": `Remove ${removeLabel}`,
4585
+ className: styles_css_chipRemove,
4586
+ "data-slot": "select-value-chip-remove",
4587
+ disabled: disabled,
4588
+ onClick: (event)=>removeValue(value, event),
4589
+ onPointerDown: handlePointerDown,
4590
+ type: "button",
4591
+ children: /*#__PURE__*/ jsx(XIcon, {})
4592
+ })
4593
+ ]
4594
+ });
4595
+ }
4596
+ function ChipsValue({ values }) {
4597
+ const { containerRef, getLabel, hiddenCount, measureRef, overflowMeasureRef, visibleValues } = useChipsValueLogic(values);
4598
+ return /*#__PURE__*/ jsxs("span", {
4599
+ className: chipsValue,
4600
+ "data-slot": "select-value-chips",
4601
+ ref: containerRef,
4602
+ children: [
4603
+ /*#__PURE__*/ jsxs("span", {
4604
+ "aria-hidden": "true",
4605
+ className: chipsMeasure,
4606
+ "data-slot": "select-value-chips-measure",
4607
+ ref: measureRef,
4608
+ children: [
4609
+ values.map((value)=>/*#__PURE__*/ jsxs("span", {
4610
+ className: styles_css_chip,
4611
+ "data-chip-measure": "chip",
4612
+ children: [
4613
+ /*#__PURE__*/ jsx("span", {
4614
+ className: chipLabel,
4615
+ children: getLabel(value)
4616
+ }),
4617
+ /*#__PURE__*/ jsx("span", {
4618
+ className: styles_css_chipRemove,
4619
+ children: /*#__PURE__*/ jsx(XIcon, {})
4620
+ })
4621
+ ]
4622
+ }, getValueKey(value))),
4623
+ /*#__PURE__*/ jsxs("span", {
4624
+ className: styles_css_chip,
4625
+ "data-chip-measure": "overflow",
4626
+ ref: overflowMeasureRef,
4627
+ children: [
4628
+ "+",
4629
+ values.length
4630
+ ]
4631
+ })
4632
+ ]
4633
+ }),
4634
+ visibleValues.map((value)=>/*#__PURE__*/ jsx(Select_Chip, {
4635
+ value: value
4636
+ }, getValueKey(value))),
4637
+ hiddenCount > 0 && /*#__PURE__*/ jsx(Select_Chip, {
4638
+ count: hiddenCount
4639
+ })
4640
+ ]
4641
+ });
4642
+ }
4408
4643
  Select_Select.Trigger = Select_Trigger;
4409
4644
  Select_Select.Value = Select_Value;
4410
4645
  Select_Select.Content = Select_Content;
@@ -4526,7 +4761,7 @@ var Sidebar_styles_css_container = 'style__1xiua9n4';
4526
4761
  var Sidebar_styles_css_content = 'style__1xiua9nh';
4527
4762
  var desktopSidebar = 'style__1xiua9n2';
4528
4763
  var Sidebar_styles_css_footer = 'style__1xiua9nf';
4529
- var gap = 'style__1xiua9n3';
4764
+ var styles_css_gap = 'style__1xiua9n3';
4530
4765
  var Sidebar_styles_css_group = 'style__1xiua9ni';
4531
4766
  var groupAction = 'style__1xiua9nk';
4532
4767
  var groupContent = 'style__1xiua9nl';
@@ -4692,7 +4927,7 @@ function SidebarRoot({ side = 'left', variant = 'sidebar', collapsible = 'offcan
4692
4927
  children: [
4693
4928
  /*#__PURE__*/ jsx("div", {
4694
4929
  "data-slot": "sidebar-gap",
4695
- className: gap
4930
+ className: styles_css_gap
4696
4931
  }),
4697
4932
  /*#__PURE__*/ jsx("div", {
4698
4933
  "data-slot": "sidebar-container",
@@ -11,6 +11,7 @@ export default _default;
11
11
  export declare function Demo(): import("react").JSX.Element;
12
12
  export declare function Sizes(): import("react").JSX.Element;
13
13
  export declare function Multiple(): import("react").JSX.Element;
14
+ export declare function MultipleOverflow(): import("react").JSX.Element;
14
15
  export declare function MultipleControlled(): import("react").JSX.Element;
15
16
  export declare function Scrollable(): import("react").JSX.Element;
16
17
  //# sourceMappingURL=Select.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select.stories.d.ts","sourceRoot":"","sources":["../../src/stories/Select.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;;;;;;;;;AAsBtC,wBAOgC;AAehC,wBAAgB,IAAI,gCAWnB;AAED,wBAAgB,KAAK,gCAepB;AAED,wBAAgB,QAAQ,gCAiBvB;AAED,wBAAgB,kBAAkB,gCA4BjC;AAED,wBAAgB,UAAU,gCAgEzB"}
1
+ {"version":3,"file":"Select.stories.d.ts","sourceRoot":"","sources":["../../src/stories/Select.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;;;;;;;;;AAkBtC,wBAOgC;AAehC,wBAAgB,IAAI,gCAWnB;AAED,wBAAgB,KAAK,gCAepB;AAED,wBAAgB,QAAQ,gCAWvB;AAED,wBAAgB,gBAAgB,gCAe/B;AAED,wBAAgB,kBAAkB,gCAoBjC;AAED,wBAAgB,UAAU,gCAgEzB"}
package/lib/styles.css CHANGED
@@ -4262,7 +4262,7 @@ a.outline__1af895x4:hover {
4262
4262
  outline: none;
4263
4263
  }
4264
4264
 
4265
- .style__5ilg7o2:disabled {
4265
+ .style__5ilg7o2:disabled, .style__5ilg7o2[aria-disabled="true"] {
4266
4266
  cursor: not-allowed;
4267
4267
  opacity: .5;
4268
4268
  }
@@ -4292,6 +4292,89 @@ a.outline__1af895x4:hover {
4292
4292
  }
4293
4293
 
4294
4294
  .style__5ilg7o3 {
4295
+ flex: 1;
4296
+ align-items: center;
4297
+ min-width: 0;
4298
+ display: flex;
4299
+ overflow: hidden;
4300
+ }
4301
+
4302
+ .style__5ilg7o4 {
4303
+ align-items: center;
4304
+ gap: var(--spacing-1);
4305
+ width: 100%;
4306
+ min-width: 0;
4307
+ display: flex;
4308
+ position: relative;
4309
+ overflow: hidden;
4310
+ }
4311
+
4312
+ .style__5ilg7o5 {
4313
+ gap: var(--spacing-1);
4314
+ visibility: hidden;
4315
+ pointer-events: none;
4316
+ white-space: nowrap;
4317
+ display: flex;
4318
+ position: absolute;
4319
+ top: 0;
4320
+ left: 0;
4321
+ }
4322
+
4323
+ .style__5ilg7o6 {
4324
+ width: fit-content;
4325
+ height: var(--spacing-5);
4326
+ justify-content: center;
4327
+ align-items: center;
4328
+ gap: var(--spacing-1);
4329
+ border-radius: var(--borderRadius-sm);
4330
+ background-color: var(--colors-background-element);
4331
+ padding: 0 var(--spacing-2);
4332
+ color: var(--colors-text-primary);
4333
+ font-size: var(--fontSize-xs);
4334
+ font-weight: var(--fontWeight-medium);
4335
+ white-space: nowrap;
4336
+ flex-shrink: 0;
4337
+ display: inline-flex;
4338
+ }
4339
+
4340
+ .style__5ilg7o7 {
4341
+ text-overflow: ellipsis;
4342
+ min-width: 0;
4343
+ overflow: hidden;
4344
+ }
4345
+
4346
+ .style__5ilg7o8 {
4347
+ width: var(--spacing-5);
4348
+ height: var(--spacing-5);
4349
+ margin-right: -var(--spacing-2);
4350
+ border-radius: var(--borderRadius-sm);
4351
+ color: inherit;
4352
+ cursor: pointer;
4353
+ opacity: .5;
4354
+ background-color: #0000;
4355
+ border: 0;
4356
+ flex-shrink: 0;
4357
+ justify-content: center;
4358
+ align-items: center;
4359
+ padding: 0;
4360
+ display: inline-flex;
4361
+ }
4362
+
4363
+ .style__5ilg7o8:hover {
4364
+ opacity: 1;
4365
+ }
4366
+
4367
+ .style__5ilg7o8:disabled {
4368
+ cursor: not-allowed;
4369
+ }
4370
+
4371
+ .style__5ilg7o8 svg {
4372
+ width: var(--spacing-3);
4373
+ height: var(--spacing-3);
4374
+ pointer-events: none;
4375
+ }
4376
+
4377
+ .style__5ilg7o9 {
4295
4378
  cursor: default;
4296
4379
  padding: var(--spacing-1) 0;
4297
4380
  justify-content: center;
@@ -4299,12 +4382,12 @@ a.outline__1af895x4:hover {
4299
4382
  display: flex;
4300
4383
  }
4301
4384
 
4302
- .style__5ilg7o4 {
4385
+ .style__5ilg7oa {
4303
4386
  isolation: isolate;
4304
4387
  z-index: 5000;
4305
4388
  }
4306
4389
 
4307
- .style__5ilg7o5 {
4390
+ .style__5ilg7ob {
4308
4391
  z-index: 5000;
4309
4392
  max-height: var(--available-height, 24rem);
4310
4393
  border-radius: var(--borderRadius-md);
@@ -4317,43 +4400,43 @@ a.outline__1af895x4:hover {
4317
4400
  box-shadow: 0 2px 4px #0000001a;
4318
4401
  }
4319
4402
 
4320
- .style__5ilg7o5[data-open] {
4403
+ .style__5ilg7ob[data-open] {
4321
4404
  animation: .15s ease-out style__5ilg7o0;
4322
4405
  }
4323
4406
 
4324
- .style__5ilg7o5[data-closed] {
4407
+ .style__5ilg7ob[data-closed] {
4325
4408
  animation: .15s ease-in style__5ilg7o1;
4326
4409
  }
4327
4410
 
4328
- .style__5ilg7o5[data-side="bottom"] {
4411
+ .style__5ilg7ob[data-side="bottom"] {
4329
4412
  transform: translateY(4px);
4330
4413
  }
4331
4414
 
4332
- .style__5ilg7o5[data-side="top"] {
4415
+ .style__5ilg7ob[data-side="top"] {
4333
4416
  transform: translateY(-4px);
4334
4417
  }
4335
4418
 
4336
- .style__5ilg7o5[data-side="left"] {
4419
+ .style__5ilg7ob[data-side="left"] {
4337
4420
  transform: translateX(-4px);
4338
4421
  }
4339
4422
 
4340
- .style__5ilg7o5[data-side="right"] {
4423
+ .style__5ilg7ob[data-side="right"] {
4341
4424
  transform: translateX(4px);
4342
4425
  }
4343
4426
 
4344
- .style__5ilg7o6 {
4427
+ .style__5ilg7oc {
4345
4428
  padding: var(--spacing-1);
4346
4429
  width: 100%;
4347
4430
  min-width: var(--anchor-width, 100%);
4348
4431
  }
4349
4432
 
4350
- .style__5ilg7o7 {
4433
+ .style__5ilg7od {
4351
4434
  padding: var(--spacing-1) var(--spacing-2);
4352
4435
  font-size: var(--fontSize-sm);
4353
4436
  font-weight: var(--fontWeight-semibold);
4354
4437
  }
4355
4438
 
4356
- .style__5ilg7o8 {
4439
+ .style__5ilg7oe {
4357
4440
  cursor: default;
4358
4441
  -webkit-user-select: none;
4359
4442
  user-select: none;
@@ -4367,17 +4450,17 @@ a.outline__1af895x4:hover {
4367
4450
  position: relative;
4368
4451
  }
4369
4452
 
4370
- .style__5ilg7o8[data-highlighted] {
4453
+ .style__5ilg7oe[data-highlighted] {
4371
4454
  background-color: var(--colors-background-elementHover);
4372
4455
  color: var(--colors-text-primary);
4373
4456
  }
4374
4457
 
4375
- .style__5ilg7o8[data-disabled] {
4458
+ .style__5ilg7oe[data-disabled] {
4376
4459
  pointer-events: none;
4377
4460
  opacity: .5;
4378
4461
  }
4379
4462
 
4380
- .style__5ilg7o9 {
4463
+ .style__5ilg7of {
4381
4464
  right: var(--spacing-2);
4382
4465
  justify-content: center;
4383
4466
  align-items: center;
@@ -4387,18 +4470,18 @@ a.outline__1af895x4:hover {
4387
4470
  position: absolute;
4388
4471
  }
4389
4472
 
4390
- .style__5ilg7oa {
4473
+ .style__5ilg7og {
4391
4474
  margin: var(--spacing-1) calc(-1 * var(--spacing-1));
4392
4475
  background-color: var(--colors-background-element);
4393
4476
  height: 1px;
4394
4477
  }
4395
4478
 
4396
- .style__5ilg7ob {
4479
+ .style__5ilg7oh {
4397
4480
  width: 1rem;
4398
4481
  height: 1rem;
4399
4482
  }
4400
4483
 
4401
- .style__5ilg7oc {
4484
+ .style__5ilg7oi {
4402
4485
  opacity: .5;
4403
4486
  width: 1rem;
4404
4487
  height: 1rem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@max-ts/kit",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./lib/index.mjs",
6
6
  "types": "./lib/index.d.ts",