@takeoff-ui/react-spar 0.1.0-beta.1 → 0.1.0-beta.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.
- package/README.md +10 -6
- package/dist/index.cjs +33 -32
- package/dist/index.d.cts +19 -30
- package/dist/index.d.ts +19 -30
- package/dist/index.mjs +35 -34
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -35,15 +35,19 @@ gaps are resolved.
|
|
|
35
35
|
|
|
36
36
|
`@takeoff-ui/react-spar` currently targets React 19.x only.
|
|
37
37
|
|
|
38
|
+
`@takeoff-design/tokens` is a **peer dependency** — install it alongside
|
|
39
|
+
`@takeoff-ui/react-spar`. Keeping tokens out of `dependencies` ensures a single
|
|
40
|
+
tokens copy in your tree and lets you upgrade tokens independently of this
|
|
41
|
+
wrapper.
|
|
42
|
+
|
|
38
43
|
```bash
|
|
39
|
-
pnpm add @takeoff-ui/react-spar
|
|
44
|
+
pnpm add @takeoff-ui/react-spar @takeoff-design/tokens
|
|
40
45
|
```
|
|
41
46
|
|
|
42
|
-
`@
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
when using Spar primitives that `react-spar` does not re-export).
|
|
47
|
+
`@turkish-technology/spar` is still a regular dependency of
|
|
48
|
+
`@takeoff-ui/react-spar` and is installed automatically. Add it to your own
|
|
49
|
+
`package.json` only if your app imports from it directly (for example, when
|
|
50
|
+
using Spar primitives that `react-spar` does not re-export).
|
|
47
51
|
|
|
48
52
|
`@takeoff-ui/react-spar` does not bundle component CSS. Import the token
|
|
49
53
|
stylesheet once at the app shell or entrypoint:
|
package/dist/index.cjs
CHANGED
|
@@ -1116,11 +1116,6 @@ var SelectTriggerBase = createComponentBase({
|
|
|
1116
1116
|
slots: ["root"],
|
|
1117
1117
|
classes: { root: "tk-select-trigger" }
|
|
1118
1118
|
});
|
|
1119
|
-
var SelectValueBase = createComponentBase({
|
|
1120
|
-
name: "SelectValue",
|
|
1121
|
-
slots: ["root"],
|
|
1122
|
-
classes: { root: "tk-select-value" }
|
|
1123
|
-
});
|
|
1124
1119
|
var SelectContentBase = createComponentBase({
|
|
1125
1120
|
name: "SelectContent",
|
|
1126
1121
|
slots: ["root"],
|
|
@@ -1141,11 +1136,6 @@ var SelectLabelBase = createComponentBase({
|
|
|
1141
1136
|
slots: ["root"],
|
|
1142
1137
|
classes: { root: "tk-select-label" }
|
|
1143
1138
|
});
|
|
1144
|
-
var SelectItemTextBase = createComponentBase({
|
|
1145
|
-
name: "SelectItemText",
|
|
1146
|
-
slots: ["root"],
|
|
1147
|
-
classes: { root: "tk-select-item-text" }
|
|
1148
|
-
});
|
|
1149
1139
|
var SelectSeparatorBase = createComponentBase({
|
|
1150
1140
|
name: "SelectSeparator",
|
|
1151
1141
|
slots: ["root"],
|
|
@@ -1157,6 +1147,7 @@ var [SelectProvider, useSelectOwnContext] = createSafeContext("SelectProvider");
|
|
|
1157
1147
|
|
|
1158
1148
|
// src/components/select/defaults.ts
|
|
1159
1149
|
var DEFAULT_SIZE7 = "base";
|
|
1150
|
+
var DEFAULT_CONTENT_WIDTH = "trigger";
|
|
1160
1151
|
var Select = (props) => {
|
|
1161
1152
|
const theme = useComponentTheme("Select");
|
|
1162
1153
|
const { rootAttrs, rest } = composeRootAttrs(SelectBase, props, theme, {
|
|
@@ -1165,8 +1156,8 @@ var Select = (props) => {
|
|
|
1165
1156
|
"data-invalid": invalid2 ? "" : void 0
|
|
1166
1157
|
})
|
|
1167
1158
|
});
|
|
1168
|
-
const { size = DEFAULT_SIZE7, invalid = false, children, ref, ...sparProps } = rest;
|
|
1169
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SelectProvider, { value: { size, invalid }, children: /* @__PURE__ */ jsxRuntime.jsx(spar.Select, { ...sparProps, ref, ...rootAttrs, children }) });
|
|
1159
|
+
const { size = DEFAULT_SIZE7, invalid = false, contentWidth = DEFAULT_CONTENT_WIDTH, children, ref, ...sparProps } = rest;
|
|
1160
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectProvider, { value: { size, invalid, contentWidth }, children: /* @__PURE__ */ jsxRuntime.jsx(spar.Select, { ...sparProps, ref, ...rootAttrs, children }) });
|
|
1170
1161
|
};
|
|
1171
1162
|
Select.displayName = "Select";
|
|
1172
1163
|
var SelectTrigger = (props) => {
|
|
@@ -1182,39 +1173,51 @@ var SelectTrigger = (props) => {
|
|
|
1182
1173
|
return /* @__PURE__ */ jsxRuntime.jsx(spar.SelectTrigger, { ...spar$1, ref, ...rootAttrs, children });
|
|
1183
1174
|
};
|
|
1184
1175
|
SelectTrigger.displayName = "Select.Trigger";
|
|
1185
|
-
var
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
const { placeholder, children, ref, ...spar$1 } = rest;
|
|
1189
|
-
return /* @__PURE__ */ jsxRuntime.jsx(spar.SelectValue, { ...spar$1, placeholder, ref, ...rootAttrs, children });
|
|
1176
|
+
var resolveStaticWidth = (mode) => {
|
|
1177
|
+
if (mode === "trigger" || mode === "content") return void 0;
|
|
1178
|
+
return typeof mode === "number" ? `${mode}px` : mode;
|
|
1190
1179
|
};
|
|
1191
|
-
SelectValue.displayName = "Select.Value";
|
|
1192
1180
|
var SelectContent = (props) => {
|
|
1193
1181
|
const theme = useComponentTheme("SelectContent");
|
|
1194
|
-
const { size } = useSelectOwnContext("Select.Content");
|
|
1182
|
+
const { size, contentWidth } = useSelectOwnContext("Select.Content");
|
|
1183
|
+
const { triggerRef } = spar.useSelectContext();
|
|
1184
|
+
const [triggerWidth, setTriggerWidth] = react.useState(null);
|
|
1185
|
+
react.useEffect(() => {
|
|
1186
|
+
if (contentWidth !== "trigger") return;
|
|
1187
|
+
const node = triggerRef.current;
|
|
1188
|
+
if (!node) return;
|
|
1189
|
+
setTriggerWidth(node.offsetWidth);
|
|
1190
|
+
const observer = new ResizeObserver((entries) => {
|
|
1191
|
+
const entry = entries[0];
|
|
1192
|
+
if (entry) setTriggerWidth(Math.round(entry.contentRect.width + 2));
|
|
1193
|
+
});
|
|
1194
|
+
observer.observe(node);
|
|
1195
|
+
return () => observer.disconnect();
|
|
1196
|
+
}, [contentWidth, triggerRef]);
|
|
1195
1197
|
const { rootAttrs, rest } = composeRootAttrs(SelectContentBase, props, theme, {
|
|
1196
1198
|
stateAttrs: () => ({
|
|
1197
1199
|
"data-size": size
|
|
1198
1200
|
})
|
|
1199
1201
|
});
|
|
1200
|
-
const { children, ref, ...spar$1 } = rest;
|
|
1201
|
-
|
|
1202
|
+
const { children, ref, style: userStyle, ...spar$1 } = rest;
|
|
1203
|
+
const widthStyle = react.useMemo(() => {
|
|
1204
|
+
if (contentWidth === "trigger") {
|
|
1205
|
+
return triggerWidth != null ? { width: triggerWidth } : void 0;
|
|
1206
|
+
}
|
|
1207
|
+
const staticWidth = resolveStaticWidth(contentWidth);
|
|
1208
|
+
return staticWidth != null ? { width: staticWidth } : void 0;
|
|
1209
|
+
}, [contentWidth, triggerWidth]);
|
|
1210
|
+
const mergedStyle = widthStyle || userStyle ? { ...widthStyle, ...userStyle } : void 0;
|
|
1211
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.SelectContent, { ...spar$1, ref, style: mergedStyle, ...rootAttrs, children });
|
|
1202
1212
|
};
|
|
1203
1213
|
SelectContent.displayName = "Select.Content";
|
|
1204
1214
|
var SelectItem = (props) => {
|
|
1205
1215
|
const theme = useComponentTheme("SelectItem");
|
|
1206
1216
|
const { rootAttrs, rest } = composeRootAttrs(SelectItemBase, props, theme);
|
|
1207
|
-
const { value, disabled,
|
|
1208
|
-
return /* @__PURE__ */ jsxRuntime.jsx(spar.SelectItem, { ...spar$1, value, disabled,
|
|
1217
|
+
const { value, disabled, label, children, ref, ...spar$1 } = rest;
|
|
1218
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.SelectItem, { ...spar$1, value, disabled, label, ref, ...rootAttrs, children });
|
|
1209
1219
|
};
|
|
1210
1220
|
SelectItem.displayName = "Select.Item";
|
|
1211
|
-
var SelectItemText = (props) => {
|
|
1212
|
-
const theme = useComponentTheme("SelectItemText");
|
|
1213
|
-
const { rootAttrs, rest } = composeRootAttrs(SelectItemTextBase, props, theme);
|
|
1214
|
-
const { children, ref, ...spar$1 } = rest;
|
|
1215
|
-
return /* @__PURE__ */ jsxRuntime.jsx(spar.SelectItemText, { ...spar$1, ref, ...rootAttrs, children });
|
|
1216
|
-
};
|
|
1217
|
-
SelectItemText.displayName = "Select.ItemText";
|
|
1218
1221
|
var SelectGroup = (props) => {
|
|
1219
1222
|
const theme = useComponentTheme("SelectGroup");
|
|
1220
1223
|
const { rootAttrs, rest } = composeRootAttrs(SelectGroupBase, props, theme);
|
|
@@ -1240,10 +1243,8 @@ SelectSeparator.displayName = "Select.Separator";
|
|
|
1240
1243
|
// src/components/select/index.ts
|
|
1241
1244
|
var Select2 = Object.assign(Select, {
|
|
1242
1245
|
Trigger: SelectTrigger,
|
|
1243
|
-
Value: SelectValue,
|
|
1244
1246
|
Content: SelectContent,
|
|
1245
1247
|
Item: SelectItem,
|
|
1246
|
-
ItemText: SelectItemText,
|
|
1247
1248
|
Group: SelectGroup,
|
|
1248
1249
|
Label: SelectLabel,
|
|
1249
1250
|
Separator: SelectSeparator
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { HTMLAttributes, ElementType, ComponentPropsWithoutRef, ReactNode, Ref } from 'react';
|
|
4
|
-
import { PolymorphicProps, AccordionProps as AccordionProps$1, AccordionItemProps as AccordionItemProps$1, AccordionHeaderProps as AccordionHeaderProps$1, AccordionContentProps as AccordionContentProps$1, ButtonProps as ButtonProps$1, CheckboxRenderProps as CheckboxRenderProps$1, CheckboxProps as CheckboxProps$1, DialogProps, DialogTriggerProps, DialogOverlayProps, DialogContentProps, DialogTitleProps, DialogCloseProps, FieldProps as FieldProps$1, FieldLabelProps as FieldLabelProps$1, FieldDescriptionProps as FieldDescriptionProps$1, FieldErrorMessageProps as FieldErrorMessageProps$1, InputProps as InputProps$1, InputFieldProps as InputFieldProps$1, RadioProps as RadioProps$1, RadioItemRenderProps, RadioItemProps as RadioItemProps$1, PopoverProps as PopoverProps$1, PopoverTriggerProps as PopoverTriggerProps$1, PopoverContentProps as PopoverContentProps$1, PopoverCloseProps as PopoverCloseProps$1, SelectProps as SelectProps$1, SelectTriggerProps as SelectTriggerProps$1,
|
|
4
|
+
import { PolymorphicProps, AccordionProps as AccordionProps$1, AccordionItemProps as AccordionItemProps$1, AccordionHeaderProps as AccordionHeaderProps$1, AccordionContentProps as AccordionContentProps$1, ButtonProps as ButtonProps$1, CheckboxRenderProps as CheckboxRenderProps$1, CheckboxProps as CheckboxProps$1, DialogProps, DialogTriggerProps, DialogOverlayProps, DialogContentProps, DialogTitleProps, DialogCloseProps, FieldProps as FieldProps$1, FieldLabelProps as FieldLabelProps$1, FieldDescriptionProps as FieldDescriptionProps$1, FieldErrorMessageProps as FieldErrorMessageProps$1, InputProps as InputProps$1, InputFieldProps as InputFieldProps$1, RadioProps as RadioProps$1, RadioItemRenderProps, RadioItemProps as RadioItemProps$1, PopoverProps as PopoverProps$1, PopoverTriggerProps as PopoverTriggerProps$1, PopoverContentProps as PopoverContentProps$1, PopoverCloseProps as PopoverCloseProps$1, SelectProps as SelectProps$1, SelectTriggerProps as SelectTriggerProps$1, SelectContentProps as SelectContentProps$1, SelectItemProps as SelectItemProps$1, SelectGroupProps as SelectGroupProps$1, SelectLabelProps as SelectLabelProps$1, SelectSeparatorProps as SelectSeparatorProps$1, SwitchRenderProps as SwitchRenderProps$1, SwitchProps as SwitchProps$1, TooltipTriggerProps as TooltipTriggerProps$1, TooltipContentProps as TooltipContentProps$1, TooltipProps as TooltipProps$1, TooltipProviderProps as TooltipProviderProps$1 } from '@turkish-technology/spar';
|
|
5
5
|
|
|
6
6
|
/** Per-slot class map declared by a component base. Every slot is required. */
|
|
7
7
|
type SlotClassNames<TSlot extends string> = Record<TSlot, string>;
|
|
@@ -1026,14 +1026,21 @@ declare const Popover: {
|
|
|
1026
1026
|
};
|
|
1027
1027
|
|
|
1028
1028
|
type SelectSize = 'small' | 'base' | 'large';
|
|
1029
|
+
/**
|
|
1030
|
+
* Controls the panel's render width.
|
|
1031
|
+
*
|
|
1032
|
+
* - `'trigger'`: panel matches the trigger's measured width (form-aligned default)
|
|
1033
|
+
* - `'content'`: panel shrink-wraps the longest item, only enforcing the CSS min-width
|
|
1034
|
+
* - `number`: explicit pixel width
|
|
1035
|
+
* - `string`: any CSS width value (`'20rem'`, `'min(40ch, 100%)'`, etc.)
|
|
1036
|
+
*/
|
|
1037
|
+
type SelectContentWidth = 'trigger' | 'content' | number | string;
|
|
1029
1038
|
type SelectSlot = 'root';
|
|
1030
1039
|
type SelectTriggerSlot = 'root';
|
|
1031
|
-
type SelectValueSlot = 'root';
|
|
1032
1040
|
type SelectContentSlot = 'root';
|
|
1033
1041
|
type SelectItemSlot = 'root';
|
|
1034
1042
|
type SelectGroupSlot = 'root';
|
|
1035
1043
|
type SelectLabelSlot = 'root';
|
|
1036
|
-
type SelectItemTextSlot = 'root';
|
|
1037
1044
|
type SelectSeparatorSlot = 'root';
|
|
1038
1045
|
/**
|
|
1039
1046
|
* Visual + slot props owned by takeoff-v2 for the Select root. `size` and
|
|
@@ -1051,6 +1058,12 @@ interface SelectOwnProps {
|
|
|
1051
1058
|
* @defaultValue false
|
|
1052
1059
|
*/
|
|
1053
1060
|
invalid?: boolean;
|
|
1061
|
+
/**
|
|
1062
|
+
* How the portalled SelectContent panel computes its width. See
|
|
1063
|
+
* {@link SelectContentWidth}.
|
|
1064
|
+
* @defaultValue 'trigger'
|
|
1065
|
+
*/
|
|
1066
|
+
contentWidth?: SelectContentWidth;
|
|
1054
1067
|
/** Per-slot class name overrides. */
|
|
1055
1068
|
classNames?: ClassNamesMap<SelectSlot>;
|
|
1056
1069
|
/** Per-slot HTML attribute overrides. */
|
|
@@ -1068,14 +1081,7 @@ interface SelectTriggerOwnProps {
|
|
|
1068
1081
|
/** Per-slot HTML attribute overrides. */
|
|
1069
1082
|
slotProps?: SlotPropsMap<SelectTriggerSlot>;
|
|
1070
1083
|
}
|
|
1071
|
-
type SelectTriggerProps<T extends ElementType = 'button'> = PolymorphicProps<'button', T, SelectTriggerOwnProps & Pick<SelectTriggerProps$1, 'children'>>;
|
|
1072
|
-
interface SelectValueOwnProps {
|
|
1073
|
-
/** Per-slot class name overrides. */
|
|
1074
|
-
classNames?: ClassNamesMap<SelectValueSlot>;
|
|
1075
|
-
/** Per-slot HTML attribute overrides. */
|
|
1076
|
-
slotProps?: SlotPropsMap<SelectValueSlot>;
|
|
1077
|
-
}
|
|
1078
|
-
type SelectValueProps<T extends ElementType = 'span'> = PolymorphicProps<'span', T, SelectValueOwnProps & Pick<SelectValueProps$1, 'placeholder'>>;
|
|
1084
|
+
type SelectTriggerProps<T extends ElementType = 'button'> = PolymorphicProps<'button', T, SelectTriggerOwnProps & Pick<SelectTriggerProps$1, 'children' | 'placeholder'>>;
|
|
1079
1085
|
interface SelectContentOwnProps {
|
|
1080
1086
|
/** Per-slot class name overrides. */
|
|
1081
1087
|
classNames?: ClassNamesMap<SelectContentSlot>;
|
|
@@ -1089,7 +1095,7 @@ interface SelectItemOwnProps {
|
|
|
1089
1095
|
/** Per-slot HTML attribute overrides. */
|
|
1090
1096
|
slotProps?: SlotPropsMap<SelectItemSlot>;
|
|
1091
1097
|
}
|
|
1092
|
-
type SelectItemProps<T extends ElementType = 'div'> = PolymorphicProps<'div', T, SelectItemOwnProps & Pick<SelectItemProps$1, 'value' | 'disabled' | '
|
|
1098
|
+
type SelectItemProps<T extends ElementType = 'div'> = PolymorphicProps<'div', T, SelectItemOwnProps & Pick<SelectItemProps$1, 'value' | 'disabled' | 'label' | 'children'>>;
|
|
1093
1099
|
interface SelectGroupOwnProps {
|
|
1094
1100
|
/** Per-slot class name overrides. */
|
|
1095
1101
|
classNames?: ClassNamesMap<SelectGroupSlot>;
|
|
@@ -1104,13 +1110,6 @@ interface SelectLabelOwnProps {
|
|
|
1104
1110
|
slotProps?: SlotPropsMap<SelectLabelSlot>;
|
|
1105
1111
|
}
|
|
1106
1112
|
type SelectLabelProps<T extends ElementType = 'label'> = PolymorphicProps<'label', T, SelectLabelOwnProps & Pick<SelectLabelProps$1, 'children'>>;
|
|
1107
|
-
interface SelectItemTextOwnProps {
|
|
1108
|
-
/** Per-slot class name overrides. */
|
|
1109
|
-
classNames?: ClassNamesMap<SelectItemTextSlot>;
|
|
1110
|
-
/** Per-slot HTML attribute overrides. */
|
|
1111
|
-
slotProps?: SlotPropsMap<SelectItemTextSlot>;
|
|
1112
|
-
}
|
|
1113
|
-
type SelectItemTextProps<T extends ElementType = 'span'> = PolymorphicProps<'span', T, SelectItemTextOwnProps & Pick<SelectItemTextProps$1, 'children'>>;
|
|
1114
1113
|
interface SelectSeparatorOwnProps {
|
|
1115
1114
|
/** Per-slot class name overrides. */
|
|
1116
1115
|
classNames?: ClassNamesMap<SelectSeparatorSlot>;
|
|
@@ -1122,12 +1121,10 @@ declare module '../../core/theme' {
|
|
|
1122
1121
|
interface ComponentThemeRegistry {
|
|
1123
1122
|
Select: ComponentThemeConfig<SelectProps, SelectSlot>;
|
|
1124
1123
|
SelectTrigger: ComponentThemeConfig<SelectTriggerProps, SelectTriggerSlot>;
|
|
1125
|
-
SelectValue: ComponentThemeConfig<SelectValueProps, SelectValueSlot>;
|
|
1126
1124
|
SelectContent: ComponentThemeConfig<SelectContentProps, SelectContentSlot>;
|
|
1127
1125
|
SelectItem: ComponentThemeConfig<SelectItemProps, SelectItemSlot>;
|
|
1128
1126
|
SelectGroup: ComponentThemeConfig<SelectGroupProps, SelectGroupSlot>;
|
|
1129
1127
|
SelectLabel: ComponentThemeConfig<SelectLabelProps, SelectLabelSlot>;
|
|
1130
|
-
SelectItemText: ComponentThemeConfig<SelectItemTextProps, SelectItemTextSlot>;
|
|
1131
1128
|
SelectSeparator: ComponentThemeConfig<SelectSeparatorProps, SelectSeparatorSlot>;
|
|
1132
1129
|
}
|
|
1133
1130
|
}
|
|
@@ -1140,10 +1137,6 @@ declare const Select: {
|
|
|
1140
1137
|
<T extends react.ElementType = "button">(props: SelectTriggerProps<T>): react_jsx_runtime.JSX.Element;
|
|
1141
1138
|
displayName: string;
|
|
1142
1139
|
};
|
|
1143
|
-
Value: {
|
|
1144
|
-
<T extends react.ElementType = "span">(props: SelectValueProps<T>): react_jsx_runtime.JSX.Element;
|
|
1145
|
-
displayName: string;
|
|
1146
|
-
};
|
|
1147
1140
|
Content: {
|
|
1148
1141
|
<T extends react.ElementType = "div">(props: SelectContentProps<T>): react_jsx_runtime.JSX.Element;
|
|
1149
1142
|
displayName: string;
|
|
@@ -1152,10 +1145,6 @@ declare const Select: {
|
|
|
1152
1145
|
<T extends react.ElementType = "div">(props: SelectItemProps<T>): react_jsx_runtime.JSX.Element;
|
|
1153
1146
|
displayName: string;
|
|
1154
1147
|
};
|
|
1155
|
-
ItemText: {
|
|
1156
|
-
<T extends react.ElementType = "span">(props: SelectItemTextProps<T>): react_jsx_runtime.JSX.Element;
|
|
1157
|
-
displayName: string;
|
|
1158
|
-
};
|
|
1159
1148
|
Group: {
|
|
1160
1149
|
<T extends react.ElementType = "div">(props: SelectGroupProps<T>): react_jsx_runtime.JSX.Element;
|
|
1161
1150
|
displayName: string;
|
|
@@ -1349,4 +1338,4 @@ declare const Tooltip: {
|
|
|
1349
1338
|
};
|
|
1350
1339
|
};
|
|
1351
1340
|
|
|
1352
|
-
export { Accordion, type AccordionContentProps, type AccordionCurrentValue, type AccordionHeaderProps, type AccordionHeadingLevel, type AccordionIndicatorProps, type AccordionIndicatorRenderState, type AccordionItemProps, type AccordionMode, type AccordionProps, type AccordionSize, type AccordionTriggerProps, type AccordionType, type AccordionValue, type AccordionValueChangeHandler, Badge, type BadgeAppearance, type BadgeProps, type BadgeSize, type BadgeSlot, type BadgeVariant, Button, type ButtonAppearance, type ButtonProps, type ButtonSize, type ButtonSlot, type ButtonVariant, Checkbox, type CheckboxIndicatorProps, type CheckboxIndicatorRenderProps, type CheckboxProps, type CheckboxRenderProps, type CheckboxSize, type CheckboxSlot, type CheckboxType, type ClassNamesMap, type ColorMode, type ComponentName, type ComponentThemeConfig, type ComponentThemeRegistry, type ComponentsThemeMap, type DataSlotName, Drawer, type DrawerBodyProps, type DrawerCloseButtonProps, type DrawerDescriptionProps, type DrawerFooterProps, type DrawerHeaderProps, type DrawerOverlayProps, type DrawerPanelProps, type DrawerPlacement, type DrawerProps, type DrawerTitleProps, type DrawerTriggerProps, Field, type FieldDescriptionProps, type FieldDescriptionSlot, type FieldErrorMessageProps, type FieldErrorMessageSlot, type FieldLabelProps, type FieldLabelSlot, type FieldProps, type FieldSlot, Input, type InputContainerProps, type InputFieldProps, type InputPrefixProps, type InputProps, type InputSize, type InputSuffixProps, Popover, type PopoverArrowProps, type PopoverArrowSlot, type PopoverCloseProps, type PopoverCloseSlot, type PopoverContentProps, type PopoverContentSlot, type PopoverDescriptionProps, type PopoverDescriptionSlot, type PopoverHeaderProps, type PopoverHeaderSlot, type PopoverProps, type PopoverTriggerProps, type PopoverTriggerSlot, type PopoverVariant, Radio, type RadioIndicatorProps, type RadioItemProps, type RadioItemSlot, type RadioLabelProps, type RadioPosition, type RadioProps, type RadioRenderProps, type RadioSize, type RadioSlot, type RadioType, Select, type SelectContentProps, type SelectGroupProps, type SelectItemProps, type
|
|
1341
|
+
export { Accordion, type AccordionContentProps, type AccordionCurrentValue, type AccordionHeaderProps, type AccordionHeadingLevel, type AccordionIndicatorProps, type AccordionIndicatorRenderState, type AccordionItemProps, type AccordionMode, type AccordionProps, type AccordionSize, type AccordionTriggerProps, type AccordionType, type AccordionValue, type AccordionValueChangeHandler, Badge, type BadgeAppearance, type BadgeProps, type BadgeSize, type BadgeSlot, type BadgeVariant, Button, type ButtonAppearance, type ButtonProps, type ButtonSize, type ButtonSlot, type ButtonVariant, Checkbox, type CheckboxIndicatorProps, type CheckboxIndicatorRenderProps, type CheckboxProps, type CheckboxRenderProps, type CheckboxSize, type CheckboxSlot, type CheckboxType, type ClassNamesMap, type ColorMode, type ComponentName, type ComponentThemeConfig, type ComponentThemeRegistry, type ComponentsThemeMap, type DataSlotName, Drawer, type DrawerBodyProps, type DrawerCloseButtonProps, type DrawerDescriptionProps, type DrawerFooterProps, type DrawerHeaderProps, type DrawerOverlayProps, type DrawerPanelProps, type DrawerPlacement, type DrawerProps, type DrawerTitleProps, type DrawerTriggerProps, Field, type FieldDescriptionProps, type FieldDescriptionSlot, type FieldErrorMessageProps, type FieldErrorMessageSlot, type FieldLabelProps, type FieldLabelSlot, type FieldProps, type FieldSlot, Input, type InputContainerProps, type InputFieldProps, type InputPrefixProps, type InputProps, type InputSize, type InputSuffixProps, Popover, type PopoverArrowProps, type PopoverArrowSlot, type PopoverCloseProps, type PopoverCloseSlot, type PopoverContentProps, type PopoverContentSlot, type PopoverDescriptionProps, type PopoverDescriptionSlot, type PopoverHeaderProps, type PopoverHeaderSlot, type PopoverProps, type PopoverTriggerProps, type PopoverTriggerSlot, type PopoverVariant, Radio, type RadioIndicatorProps, type RadioItemProps, type RadioItemSlot, type RadioLabelProps, type RadioPosition, type RadioProps, type RadioRenderProps, type RadioSize, type RadioSlot, type RadioType, Select, type SelectContentProps, type SelectGroupProps, type SelectItemProps, type SelectLabelProps, type SelectProps, type SelectSeparatorProps, type SelectSize, type SelectTriggerProps, type SlotClassNames, type SlotPropsMap, type StateOnlyComponentThemeConfig$1 as StateOnlyComponentThemeConfig, Switch, type SwitchIndicatorProps, type SwitchIndicatorRenderProps, type SwitchProps, type SwitchRenderProps, type SwitchSize, type SwitchSlot, type SwitchVariant, TakeoffSparProvider, type TakeoffSparProviderProps, type TakeoffSparProviderValue, type ThemeValue, Tooltip, type TooltipArrowProps, type TooltipArrowSlot, type TooltipContentProps, type TooltipContentSlot, type TooltipDescriptionProps, type TooltipDescriptionSlot, type TooltipHeaderProps, type TooltipHeaderSlot, type TooltipProps, type TooltipProviderProps, type TooltipTriggerProps, type TooltipTriggerSlot, type TooltipVariant, useComponentTheme, useTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { HTMLAttributes, ElementType, ComponentPropsWithoutRef, ReactNode, Ref } from 'react';
|
|
4
|
-
import { PolymorphicProps, AccordionProps as AccordionProps$1, AccordionItemProps as AccordionItemProps$1, AccordionHeaderProps as AccordionHeaderProps$1, AccordionContentProps as AccordionContentProps$1, ButtonProps as ButtonProps$1, CheckboxRenderProps as CheckboxRenderProps$1, CheckboxProps as CheckboxProps$1, DialogProps, DialogTriggerProps, DialogOverlayProps, DialogContentProps, DialogTitleProps, DialogCloseProps, FieldProps as FieldProps$1, FieldLabelProps as FieldLabelProps$1, FieldDescriptionProps as FieldDescriptionProps$1, FieldErrorMessageProps as FieldErrorMessageProps$1, InputProps as InputProps$1, InputFieldProps as InputFieldProps$1, RadioProps as RadioProps$1, RadioItemRenderProps, RadioItemProps as RadioItemProps$1, PopoverProps as PopoverProps$1, PopoverTriggerProps as PopoverTriggerProps$1, PopoverContentProps as PopoverContentProps$1, PopoverCloseProps as PopoverCloseProps$1, SelectProps as SelectProps$1, SelectTriggerProps as SelectTriggerProps$1,
|
|
4
|
+
import { PolymorphicProps, AccordionProps as AccordionProps$1, AccordionItemProps as AccordionItemProps$1, AccordionHeaderProps as AccordionHeaderProps$1, AccordionContentProps as AccordionContentProps$1, ButtonProps as ButtonProps$1, CheckboxRenderProps as CheckboxRenderProps$1, CheckboxProps as CheckboxProps$1, DialogProps, DialogTriggerProps, DialogOverlayProps, DialogContentProps, DialogTitleProps, DialogCloseProps, FieldProps as FieldProps$1, FieldLabelProps as FieldLabelProps$1, FieldDescriptionProps as FieldDescriptionProps$1, FieldErrorMessageProps as FieldErrorMessageProps$1, InputProps as InputProps$1, InputFieldProps as InputFieldProps$1, RadioProps as RadioProps$1, RadioItemRenderProps, RadioItemProps as RadioItemProps$1, PopoverProps as PopoverProps$1, PopoverTriggerProps as PopoverTriggerProps$1, PopoverContentProps as PopoverContentProps$1, PopoverCloseProps as PopoverCloseProps$1, SelectProps as SelectProps$1, SelectTriggerProps as SelectTriggerProps$1, SelectContentProps as SelectContentProps$1, SelectItemProps as SelectItemProps$1, SelectGroupProps as SelectGroupProps$1, SelectLabelProps as SelectLabelProps$1, SelectSeparatorProps as SelectSeparatorProps$1, SwitchRenderProps as SwitchRenderProps$1, SwitchProps as SwitchProps$1, TooltipTriggerProps as TooltipTriggerProps$1, TooltipContentProps as TooltipContentProps$1, TooltipProps as TooltipProps$1, TooltipProviderProps as TooltipProviderProps$1 } from '@turkish-technology/spar';
|
|
5
5
|
|
|
6
6
|
/** Per-slot class map declared by a component base. Every slot is required. */
|
|
7
7
|
type SlotClassNames<TSlot extends string> = Record<TSlot, string>;
|
|
@@ -1026,14 +1026,21 @@ declare const Popover: {
|
|
|
1026
1026
|
};
|
|
1027
1027
|
|
|
1028
1028
|
type SelectSize = 'small' | 'base' | 'large';
|
|
1029
|
+
/**
|
|
1030
|
+
* Controls the panel's render width.
|
|
1031
|
+
*
|
|
1032
|
+
* - `'trigger'`: panel matches the trigger's measured width (form-aligned default)
|
|
1033
|
+
* - `'content'`: panel shrink-wraps the longest item, only enforcing the CSS min-width
|
|
1034
|
+
* - `number`: explicit pixel width
|
|
1035
|
+
* - `string`: any CSS width value (`'20rem'`, `'min(40ch, 100%)'`, etc.)
|
|
1036
|
+
*/
|
|
1037
|
+
type SelectContentWidth = 'trigger' | 'content' | number | string;
|
|
1029
1038
|
type SelectSlot = 'root';
|
|
1030
1039
|
type SelectTriggerSlot = 'root';
|
|
1031
|
-
type SelectValueSlot = 'root';
|
|
1032
1040
|
type SelectContentSlot = 'root';
|
|
1033
1041
|
type SelectItemSlot = 'root';
|
|
1034
1042
|
type SelectGroupSlot = 'root';
|
|
1035
1043
|
type SelectLabelSlot = 'root';
|
|
1036
|
-
type SelectItemTextSlot = 'root';
|
|
1037
1044
|
type SelectSeparatorSlot = 'root';
|
|
1038
1045
|
/**
|
|
1039
1046
|
* Visual + slot props owned by takeoff-v2 for the Select root. `size` and
|
|
@@ -1051,6 +1058,12 @@ interface SelectOwnProps {
|
|
|
1051
1058
|
* @defaultValue false
|
|
1052
1059
|
*/
|
|
1053
1060
|
invalid?: boolean;
|
|
1061
|
+
/**
|
|
1062
|
+
* How the portalled SelectContent panel computes its width. See
|
|
1063
|
+
* {@link SelectContentWidth}.
|
|
1064
|
+
* @defaultValue 'trigger'
|
|
1065
|
+
*/
|
|
1066
|
+
contentWidth?: SelectContentWidth;
|
|
1054
1067
|
/** Per-slot class name overrides. */
|
|
1055
1068
|
classNames?: ClassNamesMap<SelectSlot>;
|
|
1056
1069
|
/** Per-slot HTML attribute overrides. */
|
|
@@ -1068,14 +1081,7 @@ interface SelectTriggerOwnProps {
|
|
|
1068
1081
|
/** Per-slot HTML attribute overrides. */
|
|
1069
1082
|
slotProps?: SlotPropsMap<SelectTriggerSlot>;
|
|
1070
1083
|
}
|
|
1071
|
-
type SelectTriggerProps<T extends ElementType = 'button'> = PolymorphicProps<'button', T, SelectTriggerOwnProps & Pick<SelectTriggerProps$1, 'children'>>;
|
|
1072
|
-
interface SelectValueOwnProps {
|
|
1073
|
-
/** Per-slot class name overrides. */
|
|
1074
|
-
classNames?: ClassNamesMap<SelectValueSlot>;
|
|
1075
|
-
/** Per-slot HTML attribute overrides. */
|
|
1076
|
-
slotProps?: SlotPropsMap<SelectValueSlot>;
|
|
1077
|
-
}
|
|
1078
|
-
type SelectValueProps<T extends ElementType = 'span'> = PolymorphicProps<'span', T, SelectValueOwnProps & Pick<SelectValueProps$1, 'placeholder'>>;
|
|
1084
|
+
type SelectTriggerProps<T extends ElementType = 'button'> = PolymorphicProps<'button', T, SelectTriggerOwnProps & Pick<SelectTriggerProps$1, 'children' | 'placeholder'>>;
|
|
1079
1085
|
interface SelectContentOwnProps {
|
|
1080
1086
|
/** Per-slot class name overrides. */
|
|
1081
1087
|
classNames?: ClassNamesMap<SelectContentSlot>;
|
|
@@ -1089,7 +1095,7 @@ interface SelectItemOwnProps {
|
|
|
1089
1095
|
/** Per-slot HTML attribute overrides. */
|
|
1090
1096
|
slotProps?: SlotPropsMap<SelectItemSlot>;
|
|
1091
1097
|
}
|
|
1092
|
-
type SelectItemProps<T extends ElementType = 'div'> = PolymorphicProps<'div', T, SelectItemOwnProps & Pick<SelectItemProps$1, 'value' | 'disabled' | '
|
|
1098
|
+
type SelectItemProps<T extends ElementType = 'div'> = PolymorphicProps<'div', T, SelectItemOwnProps & Pick<SelectItemProps$1, 'value' | 'disabled' | 'label' | 'children'>>;
|
|
1093
1099
|
interface SelectGroupOwnProps {
|
|
1094
1100
|
/** Per-slot class name overrides. */
|
|
1095
1101
|
classNames?: ClassNamesMap<SelectGroupSlot>;
|
|
@@ -1104,13 +1110,6 @@ interface SelectLabelOwnProps {
|
|
|
1104
1110
|
slotProps?: SlotPropsMap<SelectLabelSlot>;
|
|
1105
1111
|
}
|
|
1106
1112
|
type SelectLabelProps<T extends ElementType = 'label'> = PolymorphicProps<'label', T, SelectLabelOwnProps & Pick<SelectLabelProps$1, 'children'>>;
|
|
1107
|
-
interface SelectItemTextOwnProps {
|
|
1108
|
-
/** Per-slot class name overrides. */
|
|
1109
|
-
classNames?: ClassNamesMap<SelectItemTextSlot>;
|
|
1110
|
-
/** Per-slot HTML attribute overrides. */
|
|
1111
|
-
slotProps?: SlotPropsMap<SelectItemTextSlot>;
|
|
1112
|
-
}
|
|
1113
|
-
type SelectItemTextProps<T extends ElementType = 'span'> = PolymorphicProps<'span', T, SelectItemTextOwnProps & Pick<SelectItemTextProps$1, 'children'>>;
|
|
1114
1113
|
interface SelectSeparatorOwnProps {
|
|
1115
1114
|
/** Per-slot class name overrides. */
|
|
1116
1115
|
classNames?: ClassNamesMap<SelectSeparatorSlot>;
|
|
@@ -1122,12 +1121,10 @@ declare module '../../core/theme' {
|
|
|
1122
1121
|
interface ComponentThemeRegistry {
|
|
1123
1122
|
Select: ComponentThemeConfig<SelectProps, SelectSlot>;
|
|
1124
1123
|
SelectTrigger: ComponentThemeConfig<SelectTriggerProps, SelectTriggerSlot>;
|
|
1125
|
-
SelectValue: ComponentThemeConfig<SelectValueProps, SelectValueSlot>;
|
|
1126
1124
|
SelectContent: ComponentThemeConfig<SelectContentProps, SelectContentSlot>;
|
|
1127
1125
|
SelectItem: ComponentThemeConfig<SelectItemProps, SelectItemSlot>;
|
|
1128
1126
|
SelectGroup: ComponentThemeConfig<SelectGroupProps, SelectGroupSlot>;
|
|
1129
1127
|
SelectLabel: ComponentThemeConfig<SelectLabelProps, SelectLabelSlot>;
|
|
1130
|
-
SelectItemText: ComponentThemeConfig<SelectItemTextProps, SelectItemTextSlot>;
|
|
1131
1128
|
SelectSeparator: ComponentThemeConfig<SelectSeparatorProps, SelectSeparatorSlot>;
|
|
1132
1129
|
}
|
|
1133
1130
|
}
|
|
@@ -1140,10 +1137,6 @@ declare const Select: {
|
|
|
1140
1137
|
<T extends react.ElementType = "button">(props: SelectTriggerProps<T>): react_jsx_runtime.JSX.Element;
|
|
1141
1138
|
displayName: string;
|
|
1142
1139
|
};
|
|
1143
|
-
Value: {
|
|
1144
|
-
<T extends react.ElementType = "span">(props: SelectValueProps<T>): react_jsx_runtime.JSX.Element;
|
|
1145
|
-
displayName: string;
|
|
1146
|
-
};
|
|
1147
1140
|
Content: {
|
|
1148
1141
|
<T extends react.ElementType = "div">(props: SelectContentProps<T>): react_jsx_runtime.JSX.Element;
|
|
1149
1142
|
displayName: string;
|
|
@@ -1152,10 +1145,6 @@ declare const Select: {
|
|
|
1152
1145
|
<T extends react.ElementType = "div">(props: SelectItemProps<T>): react_jsx_runtime.JSX.Element;
|
|
1153
1146
|
displayName: string;
|
|
1154
1147
|
};
|
|
1155
|
-
ItemText: {
|
|
1156
|
-
<T extends react.ElementType = "span">(props: SelectItemTextProps<T>): react_jsx_runtime.JSX.Element;
|
|
1157
|
-
displayName: string;
|
|
1158
|
-
};
|
|
1159
1148
|
Group: {
|
|
1160
1149
|
<T extends react.ElementType = "div">(props: SelectGroupProps<T>): react_jsx_runtime.JSX.Element;
|
|
1161
1150
|
displayName: string;
|
|
@@ -1349,4 +1338,4 @@ declare const Tooltip: {
|
|
|
1349
1338
|
};
|
|
1350
1339
|
};
|
|
1351
1340
|
|
|
1352
|
-
export { Accordion, type AccordionContentProps, type AccordionCurrentValue, type AccordionHeaderProps, type AccordionHeadingLevel, type AccordionIndicatorProps, type AccordionIndicatorRenderState, type AccordionItemProps, type AccordionMode, type AccordionProps, type AccordionSize, type AccordionTriggerProps, type AccordionType, type AccordionValue, type AccordionValueChangeHandler, Badge, type BadgeAppearance, type BadgeProps, type BadgeSize, type BadgeSlot, type BadgeVariant, Button, type ButtonAppearance, type ButtonProps, type ButtonSize, type ButtonSlot, type ButtonVariant, Checkbox, type CheckboxIndicatorProps, type CheckboxIndicatorRenderProps, type CheckboxProps, type CheckboxRenderProps, type CheckboxSize, type CheckboxSlot, type CheckboxType, type ClassNamesMap, type ColorMode, type ComponentName, type ComponentThemeConfig, type ComponentThemeRegistry, type ComponentsThemeMap, type DataSlotName, Drawer, type DrawerBodyProps, type DrawerCloseButtonProps, type DrawerDescriptionProps, type DrawerFooterProps, type DrawerHeaderProps, type DrawerOverlayProps, type DrawerPanelProps, type DrawerPlacement, type DrawerProps, type DrawerTitleProps, type DrawerTriggerProps, Field, type FieldDescriptionProps, type FieldDescriptionSlot, type FieldErrorMessageProps, type FieldErrorMessageSlot, type FieldLabelProps, type FieldLabelSlot, type FieldProps, type FieldSlot, Input, type InputContainerProps, type InputFieldProps, type InputPrefixProps, type InputProps, type InputSize, type InputSuffixProps, Popover, type PopoverArrowProps, type PopoverArrowSlot, type PopoverCloseProps, type PopoverCloseSlot, type PopoverContentProps, type PopoverContentSlot, type PopoverDescriptionProps, type PopoverDescriptionSlot, type PopoverHeaderProps, type PopoverHeaderSlot, type PopoverProps, type PopoverTriggerProps, type PopoverTriggerSlot, type PopoverVariant, Radio, type RadioIndicatorProps, type RadioItemProps, type RadioItemSlot, type RadioLabelProps, type RadioPosition, type RadioProps, type RadioRenderProps, type RadioSize, type RadioSlot, type RadioType, Select, type SelectContentProps, type SelectGroupProps, type SelectItemProps, type
|
|
1341
|
+
export { Accordion, type AccordionContentProps, type AccordionCurrentValue, type AccordionHeaderProps, type AccordionHeadingLevel, type AccordionIndicatorProps, type AccordionIndicatorRenderState, type AccordionItemProps, type AccordionMode, type AccordionProps, type AccordionSize, type AccordionTriggerProps, type AccordionType, type AccordionValue, type AccordionValueChangeHandler, Badge, type BadgeAppearance, type BadgeProps, type BadgeSize, type BadgeSlot, type BadgeVariant, Button, type ButtonAppearance, type ButtonProps, type ButtonSize, type ButtonSlot, type ButtonVariant, Checkbox, type CheckboxIndicatorProps, type CheckboxIndicatorRenderProps, type CheckboxProps, type CheckboxRenderProps, type CheckboxSize, type CheckboxSlot, type CheckboxType, type ClassNamesMap, type ColorMode, type ComponentName, type ComponentThemeConfig, type ComponentThemeRegistry, type ComponentsThemeMap, type DataSlotName, Drawer, type DrawerBodyProps, type DrawerCloseButtonProps, type DrawerDescriptionProps, type DrawerFooterProps, type DrawerHeaderProps, type DrawerOverlayProps, type DrawerPanelProps, type DrawerPlacement, type DrawerProps, type DrawerTitleProps, type DrawerTriggerProps, Field, type FieldDescriptionProps, type FieldDescriptionSlot, type FieldErrorMessageProps, type FieldErrorMessageSlot, type FieldLabelProps, type FieldLabelSlot, type FieldProps, type FieldSlot, Input, type InputContainerProps, type InputFieldProps, type InputPrefixProps, type InputProps, type InputSize, type InputSuffixProps, Popover, type PopoverArrowProps, type PopoverArrowSlot, type PopoverCloseProps, type PopoverCloseSlot, type PopoverContentProps, type PopoverContentSlot, type PopoverDescriptionProps, type PopoverDescriptionSlot, type PopoverHeaderProps, type PopoverHeaderSlot, type PopoverProps, type PopoverTriggerProps, type PopoverTriggerSlot, type PopoverVariant, Radio, type RadioIndicatorProps, type RadioItemProps, type RadioItemSlot, type RadioLabelProps, type RadioPosition, type RadioProps, type RadioRenderProps, type RadioSize, type RadioSlot, type RadioType, Select, type SelectContentProps, type SelectGroupProps, type SelectItemProps, type SelectLabelProps, type SelectProps, type SelectSeparatorProps, type SelectSize, type SelectTriggerProps, type SlotClassNames, type SlotPropsMap, type StateOnlyComponentThemeConfig$1 as StateOnlyComponentThemeConfig, Switch, type SwitchIndicatorProps, type SwitchIndicatorRenderProps, type SwitchProps, type SwitchRenderProps, type SwitchSize, type SwitchSlot, type SwitchVariant, TakeoffSparProvider, type TakeoffSparProviderProps, type TakeoffSparProviderValue, type ThemeValue, Tooltip, type TooltipArrowProps, type TooltipArrowSlot, type TooltipContentProps, type TooltipContentSlot, type TooltipDescriptionProps, type TooltipDescriptionSlot, type TooltipHeaderProps, type TooltipHeaderSlot, type TooltipProps, type TooltipProviderProps, type TooltipTriggerProps, type TooltipTriggerSlot, type TooltipVariant, useComponentTheme, useTheme };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createContext, Children, isValidElement,
|
|
1
|
+
import { createContext, Children, isValidElement, useState, useEffect, useMemo, createElement, useContext } from 'react';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { Accordion as Accordion$1, AccordionContent as AccordionContent$1, useAccordionItemContext, AccordionTrigger as AccordionTrigger$1, AccordionHeader as AccordionHeader$1, AccordionItem as AccordionItem$1, Checkbox as Checkbox$1, Dialog, DialogClose, DialogDescription, DialogTitle, DialogContent, DialogOverlay, DialogTrigger, Field as Field$1, FieldErrorMessage as FieldErrorMessage$1, FieldDescription as FieldDescription$1, useFieldContext, FieldLabel as FieldLabel$1, Input as Input$1, InputField as InputField$1, useInputContext, Radio as Radio$1, RadioItem as RadioItem$1, Popover as Popover$1, PopoverClose as PopoverClose$1, PopoverArrow as PopoverArrow$1, PopoverContent as PopoverContent$1, PopoverTrigger as PopoverTrigger$1, Select as Select$1, SelectSeparator as SelectSeparator$1, SelectLabel as SelectLabel$1, SelectGroup as SelectGroup$1,
|
|
3
|
+
import { Accordion as Accordion$1, AccordionContent as AccordionContent$1, useAccordionItemContext, AccordionTrigger as AccordionTrigger$1, AccordionHeader as AccordionHeader$1, AccordionItem as AccordionItem$1, Checkbox as Checkbox$1, Dialog, DialogClose, DialogDescription, DialogTitle, DialogContent, DialogOverlay, DialogTrigger, Field as Field$1, FieldErrorMessage as FieldErrorMessage$1, FieldDescription as FieldDescription$1, useFieldContext, FieldLabel as FieldLabel$1, Input as Input$1, InputField as InputField$1, useInputContext, Radio as Radio$1, RadioItem as RadioItem$1, Popover as Popover$1, PopoverClose as PopoverClose$1, PopoverArrow as PopoverArrow$1, PopoverContent as PopoverContent$1, PopoverTrigger as PopoverTrigger$1, Select as Select$1, SelectSeparator as SelectSeparator$1, SelectLabel as SelectLabel$1, SelectGroup as SelectGroup$1, SelectItem as SelectItem$1, useSelectContext, SelectContent as SelectContent$1, SelectTrigger as SelectTrigger$1, Switch as Switch$1, Tooltip as Tooltip$1, TooltipArrow as TooltipArrow$1, TooltipContent as TooltipContent$1, TooltipTrigger as TooltipTrigger$1, TooltipProvider as TooltipProvider$1, Button as Button$1 } from '@turkish-technology/spar';
|
|
4
4
|
import { clsx } from 'clsx';
|
|
5
5
|
|
|
6
6
|
// src/provider.tsx
|
|
@@ -1114,11 +1114,6 @@ var SelectTriggerBase = createComponentBase({
|
|
|
1114
1114
|
slots: ["root"],
|
|
1115
1115
|
classes: { root: "tk-select-trigger" }
|
|
1116
1116
|
});
|
|
1117
|
-
var SelectValueBase = createComponentBase({
|
|
1118
|
-
name: "SelectValue",
|
|
1119
|
-
slots: ["root"],
|
|
1120
|
-
classes: { root: "tk-select-value" }
|
|
1121
|
-
});
|
|
1122
1117
|
var SelectContentBase = createComponentBase({
|
|
1123
1118
|
name: "SelectContent",
|
|
1124
1119
|
slots: ["root"],
|
|
@@ -1139,11 +1134,6 @@ var SelectLabelBase = createComponentBase({
|
|
|
1139
1134
|
slots: ["root"],
|
|
1140
1135
|
classes: { root: "tk-select-label" }
|
|
1141
1136
|
});
|
|
1142
|
-
var SelectItemTextBase = createComponentBase({
|
|
1143
|
-
name: "SelectItemText",
|
|
1144
|
-
slots: ["root"],
|
|
1145
|
-
classes: { root: "tk-select-item-text" }
|
|
1146
|
-
});
|
|
1147
1137
|
var SelectSeparatorBase = createComponentBase({
|
|
1148
1138
|
name: "SelectSeparator",
|
|
1149
1139
|
slots: ["root"],
|
|
@@ -1155,6 +1145,7 @@ var [SelectProvider, useSelectOwnContext] = createSafeContext("SelectProvider");
|
|
|
1155
1145
|
|
|
1156
1146
|
// src/components/select/defaults.ts
|
|
1157
1147
|
var DEFAULT_SIZE7 = "base";
|
|
1148
|
+
var DEFAULT_CONTENT_WIDTH = "trigger";
|
|
1158
1149
|
var Select = (props) => {
|
|
1159
1150
|
const theme = useComponentTheme("Select");
|
|
1160
1151
|
const { rootAttrs, rest } = composeRootAttrs(SelectBase, props, theme, {
|
|
@@ -1163,8 +1154,8 @@ var Select = (props) => {
|
|
|
1163
1154
|
"data-invalid": invalid2 ? "" : void 0
|
|
1164
1155
|
})
|
|
1165
1156
|
});
|
|
1166
|
-
const { size = DEFAULT_SIZE7, invalid = false, children, ref, ...sparProps } = rest;
|
|
1167
|
-
return /* @__PURE__ */ jsx(SelectProvider, { value: { size, invalid }, children: /* @__PURE__ */ jsx(Select$1, { ...sparProps, ref, ...rootAttrs, children }) });
|
|
1157
|
+
const { size = DEFAULT_SIZE7, invalid = false, contentWidth = DEFAULT_CONTENT_WIDTH, children, ref, ...sparProps } = rest;
|
|
1158
|
+
return /* @__PURE__ */ jsx(SelectProvider, { value: { size, invalid, contentWidth }, children: /* @__PURE__ */ jsx(Select$1, { ...sparProps, ref, ...rootAttrs, children }) });
|
|
1168
1159
|
};
|
|
1169
1160
|
Select.displayName = "Select";
|
|
1170
1161
|
var SelectTrigger = (props) => {
|
|
@@ -1180,39 +1171,51 @@ var SelectTrigger = (props) => {
|
|
|
1180
1171
|
return /* @__PURE__ */ jsx(SelectTrigger$1, { ...spar, ref, ...rootAttrs, children });
|
|
1181
1172
|
};
|
|
1182
1173
|
SelectTrigger.displayName = "Select.Trigger";
|
|
1183
|
-
var
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
const { placeholder, children, ref, ...spar } = rest;
|
|
1187
|
-
return /* @__PURE__ */ jsx(SelectValue$1, { ...spar, placeholder, ref, ...rootAttrs, children });
|
|
1174
|
+
var resolveStaticWidth = (mode) => {
|
|
1175
|
+
if (mode === "trigger" || mode === "content") return void 0;
|
|
1176
|
+
return typeof mode === "number" ? `${mode}px` : mode;
|
|
1188
1177
|
};
|
|
1189
|
-
SelectValue.displayName = "Select.Value";
|
|
1190
1178
|
var SelectContent = (props) => {
|
|
1191
1179
|
const theme = useComponentTheme("SelectContent");
|
|
1192
|
-
const { size } = useSelectOwnContext("Select.Content");
|
|
1180
|
+
const { size, contentWidth } = useSelectOwnContext("Select.Content");
|
|
1181
|
+
const { triggerRef } = useSelectContext();
|
|
1182
|
+
const [triggerWidth, setTriggerWidth] = useState(null);
|
|
1183
|
+
useEffect(() => {
|
|
1184
|
+
if (contentWidth !== "trigger") return;
|
|
1185
|
+
const node = triggerRef.current;
|
|
1186
|
+
if (!node) return;
|
|
1187
|
+
setTriggerWidth(node.offsetWidth);
|
|
1188
|
+
const observer = new ResizeObserver((entries) => {
|
|
1189
|
+
const entry = entries[0];
|
|
1190
|
+
if (entry) setTriggerWidth(Math.round(entry.contentRect.width + 2));
|
|
1191
|
+
});
|
|
1192
|
+
observer.observe(node);
|
|
1193
|
+
return () => observer.disconnect();
|
|
1194
|
+
}, [contentWidth, triggerRef]);
|
|
1193
1195
|
const { rootAttrs, rest } = composeRootAttrs(SelectContentBase, props, theme, {
|
|
1194
1196
|
stateAttrs: () => ({
|
|
1195
1197
|
"data-size": size
|
|
1196
1198
|
})
|
|
1197
1199
|
});
|
|
1198
|
-
const { children, ref, ...spar } = rest;
|
|
1199
|
-
|
|
1200
|
+
const { children, ref, style: userStyle, ...spar } = rest;
|
|
1201
|
+
const widthStyle = useMemo(() => {
|
|
1202
|
+
if (contentWidth === "trigger") {
|
|
1203
|
+
return triggerWidth != null ? { width: triggerWidth } : void 0;
|
|
1204
|
+
}
|
|
1205
|
+
const staticWidth = resolveStaticWidth(contentWidth);
|
|
1206
|
+
return staticWidth != null ? { width: staticWidth } : void 0;
|
|
1207
|
+
}, [contentWidth, triggerWidth]);
|
|
1208
|
+
const mergedStyle = widthStyle || userStyle ? { ...widthStyle, ...userStyle } : void 0;
|
|
1209
|
+
return /* @__PURE__ */ jsx(SelectContent$1, { ...spar, ref, style: mergedStyle, ...rootAttrs, children });
|
|
1200
1210
|
};
|
|
1201
1211
|
SelectContent.displayName = "Select.Content";
|
|
1202
1212
|
var SelectItem = (props) => {
|
|
1203
1213
|
const theme = useComponentTheme("SelectItem");
|
|
1204
1214
|
const { rootAttrs, rest } = composeRootAttrs(SelectItemBase, props, theme);
|
|
1205
|
-
const { value, disabled,
|
|
1206
|
-
return /* @__PURE__ */ jsx(SelectItem$1, { ...spar, value, disabled,
|
|
1215
|
+
const { value, disabled, label, children, ref, ...spar } = rest;
|
|
1216
|
+
return /* @__PURE__ */ jsx(SelectItem$1, { ...spar, value, disabled, label, ref, ...rootAttrs, children });
|
|
1207
1217
|
};
|
|
1208
1218
|
SelectItem.displayName = "Select.Item";
|
|
1209
|
-
var SelectItemText = (props) => {
|
|
1210
|
-
const theme = useComponentTheme("SelectItemText");
|
|
1211
|
-
const { rootAttrs, rest } = composeRootAttrs(SelectItemTextBase, props, theme);
|
|
1212
|
-
const { children, ref, ...spar } = rest;
|
|
1213
|
-
return /* @__PURE__ */ jsx(SelectItemText$1, { ...spar, ref, ...rootAttrs, children });
|
|
1214
|
-
};
|
|
1215
|
-
SelectItemText.displayName = "Select.ItemText";
|
|
1216
1219
|
var SelectGroup = (props) => {
|
|
1217
1220
|
const theme = useComponentTheme("SelectGroup");
|
|
1218
1221
|
const { rootAttrs, rest } = composeRootAttrs(SelectGroupBase, props, theme);
|
|
@@ -1238,10 +1241,8 @@ SelectSeparator.displayName = "Select.Separator";
|
|
|
1238
1241
|
// src/components/select/index.ts
|
|
1239
1242
|
var Select2 = Object.assign(Select, {
|
|
1240
1243
|
Trigger: SelectTrigger,
|
|
1241
|
-
Value: SelectValue,
|
|
1242
1244
|
Content: SelectContent,
|
|
1243
1245
|
Item: SelectItem,
|
|
1244
|
-
ItemText: SelectItemText,
|
|
1245
1246
|
Group: SelectGroup,
|
|
1246
1247
|
Label: SelectLabel,
|
|
1247
1248
|
Separator: SelectSeparator
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeoff-ui/react-spar",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.2",
|
|
4
4
|
"description": "React-first Takeoff wrappers built on top of @turkish-technology/spar.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Turkish Technology Frontend Infrastructure Team <takeoffui@thy.com>",
|
|
7
|
-
"homepage": "https://
|
|
7
|
+
"homepage": "https://takeoff-v2.app.turkishtechlab.com",
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"sideEffects": false,
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@turkish-technology/spar": "0.2.0-beta.
|
|
45
|
+
"@turkish-technology/spar": "0.2.0-beta.1",
|
|
46
46
|
"clsx": "^2.1.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|