@cerberus-design/react 0.15.0-next-e5dbdbd → 0.15.0-next-b2ad645
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/build/legacy/_tsup-dts-rollup.d.cts +99 -0
- package/build/legacy/components/Select.cjs +48 -32
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/Select.server.cjs +78 -0
- package/build/legacy/components/Select.server.cjs.map +1 -0
- package/build/legacy/index.cjs +159 -113
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +99 -0
- package/build/modern/chunk-FV4UITYD.js +97 -0
- package/build/modern/chunk-FV4UITYD.js.map +1 -0
- package/build/modern/chunk-YWMPB2JR.js +41 -0
- package/build/modern/chunk-YWMPB2JR.js.map +1 -0
- package/build/modern/components/Select.js +2 -1
- package/build/modern/components/Select.server.js +33 -0
- package/build/modern/components/Select.server.js.map +1 -0
- package/build/modern/index.js +41 -11
- package/build/modern/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/Select.server.tsx +80 -0
- package/src/components/Select.tsx +37 -28
- package/src/index.ts +1 -0
- package/build/modern/chunk-X6WFDKKJ.js +0 -90
- package/build/modern/chunk-X6WFDKKJ.js.map +0 -1
|
@@ -20,6 +20,21 @@ import { useCerberusContext } from '../context/cerberus'
|
|
|
20
20
|
import { Portal } from './Portal'
|
|
21
21
|
import { Show } from './Show'
|
|
22
22
|
import { Text } from './Text'
|
|
23
|
+
import {
|
|
24
|
+
SelectContent,
|
|
25
|
+
SelectControl,
|
|
26
|
+
SelectIndicator,
|
|
27
|
+
SelectItem,
|
|
28
|
+
SelectItemGroup,
|
|
29
|
+
SelectItemGroupLabel,
|
|
30
|
+
SelectItemIndicator,
|
|
31
|
+
SelectItemText,
|
|
32
|
+
SelectLabel,
|
|
33
|
+
SelectPositioner,
|
|
34
|
+
SelectRoot,
|
|
35
|
+
SelectTrigger,
|
|
36
|
+
SelectValueText,
|
|
37
|
+
} from './Select.server'
|
|
23
38
|
|
|
24
39
|
/**
|
|
25
40
|
* This module contains the Select components.
|
|
@@ -102,45 +117,41 @@ export function Select(props: SelectProps) {
|
|
|
102
117
|
const styles = select({ size })
|
|
103
118
|
|
|
104
119
|
return (
|
|
105
|
-
<
|
|
106
|
-
className={styles.
|
|
107
|
-
collection={collection}
|
|
108
|
-
{...rootProps}
|
|
109
|
-
>
|
|
110
|
-
<ArkSelect.Label className={styles.label}>
|
|
120
|
+
<SelectRoot className={styles.root} collection={collection} {...rootProps}>
|
|
121
|
+
<SelectLabel className={styles.label}>
|
|
111
122
|
{label}
|
|
112
123
|
<Show when={props.required}>
|
|
113
124
|
<Text as="span" color="page.text.100">
|
|
114
125
|
(required)
|
|
115
126
|
</Text>
|
|
116
127
|
</Show>
|
|
117
|
-
</
|
|
128
|
+
</SelectLabel>
|
|
118
129
|
|
|
119
|
-
<
|
|
120
|
-
<
|
|
121
|
-
<
|
|
130
|
+
<SelectControl className={styles.control}>
|
|
131
|
+
<SelectTrigger className={styles.trigger}>
|
|
132
|
+
<SelectValueText placeholder={placeholder} />
|
|
122
133
|
|
|
123
134
|
<HStack>
|
|
124
135
|
<Show when={props.invalid}>
|
|
125
136
|
<InvalidIcon data-part="invalid-icon" />
|
|
126
137
|
</Show>
|
|
127
|
-
<
|
|
138
|
+
<SelectIndicator className={styles.indicator}>
|
|
128
139
|
<SelectArrow />
|
|
129
|
-
</
|
|
140
|
+
</SelectIndicator>
|
|
130
141
|
</HStack>
|
|
131
|
-
</
|
|
132
|
-
</
|
|
142
|
+
</SelectTrigger>
|
|
143
|
+
</SelectControl>
|
|
133
144
|
|
|
134
145
|
<Portal>
|
|
135
|
-
<
|
|
136
|
-
<
|
|
146
|
+
<SelectPositioner className={styles.positioner}>
|
|
147
|
+
<SelectContent className={styles.content}>
|
|
137
148
|
{props.children}
|
|
138
|
-
</
|
|
139
|
-
</
|
|
149
|
+
</SelectContent>
|
|
150
|
+
</SelectPositioner>
|
|
140
151
|
</Portal>
|
|
141
152
|
|
|
142
153
|
<ArkSelect.HiddenSelect />
|
|
143
|
-
</
|
|
154
|
+
</SelectRoot>
|
|
144
155
|
)
|
|
145
156
|
}
|
|
146
157
|
|
|
@@ -160,14 +171,12 @@ export function Option(props: OptionProps) {
|
|
|
160
171
|
const styles = select()
|
|
161
172
|
|
|
162
173
|
return (
|
|
163
|
-
<
|
|
164
|
-
<
|
|
165
|
-
|
|
166
|
-
</ArkSelect.ItemText>
|
|
167
|
-
<ArkSelect.ItemIndicator className={styles.itemIndicator}>
|
|
174
|
+
<SelectItem {...itemProps} item={item} className={styles.item}>
|
|
175
|
+
<SelectItemText className={styles.itemText}>{item?.label}</SelectItemText>
|
|
176
|
+
<SelectItemIndicator className={styles.itemIndicator}>
|
|
168
177
|
<CheckedIcon />
|
|
169
|
-
</
|
|
170
|
-
</
|
|
178
|
+
</SelectItemIndicator>
|
|
179
|
+
</SelectItem>
|
|
171
180
|
)
|
|
172
181
|
}
|
|
173
182
|
|
|
@@ -184,7 +193,7 @@ export function Option(props: OptionProps) {
|
|
|
184
193
|
* ```
|
|
185
194
|
*/
|
|
186
195
|
export function OptionGroup(props: SelectItemGroupProps) {
|
|
187
|
-
return <
|
|
196
|
+
return <SelectItemGroup {...props} />
|
|
188
197
|
}
|
|
189
198
|
|
|
190
199
|
/**
|
|
@@ -199,7 +208,7 @@ export function OptionGroup(props: SelectItemGroupProps) {
|
|
|
199
208
|
export function OptionGroupLabel(props: SelectItemGroupLabelProps) {
|
|
200
209
|
const styles = select()
|
|
201
210
|
return (
|
|
202
|
-
<
|
|
211
|
+
<SelectItemGroupLabel
|
|
203
212
|
{...props}
|
|
204
213
|
className={cx(props.className, styles.itemGroupLabel)}
|
|
205
214
|
/>
|
package/src/index.ts
CHANGED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Text
|
|
3
|
-
} from "./chunk-RU5LOXWI.js";
|
|
4
|
-
import {
|
|
5
|
-
Portal
|
|
6
|
-
} from "./chunk-IQJDVFPP.js";
|
|
7
|
-
import {
|
|
8
|
-
Show
|
|
9
|
-
} from "./chunk-BUVVRQLZ.js";
|
|
10
|
-
import {
|
|
11
|
-
useCerberusContext
|
|
12
|
-
} from "./chunk-GITT5645.js";
|
|
13
|
-
|
|
14
|
-
// src/components/Select.tsx
|
|
15
|
-
import {
|
|
16
|
-
Select as ArkSelect,
|
|
17
|
-
createListCollection
|
|
18
|
-
} from "@ark-ui/react/select";
|
|
19
|
-
import {
|
|
20
|
-
select
|
|
21
|
-
} from "@cerberus/styled-system/recipes";
|
|
22
|
-
import { cx } from "@cerberus/styled-system/css";
|
|
23
|
-
import { HStack } from "@cerberus/styled-system/jsx";
|
|
24
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
25
|
-
function Select(props) {
|
|
26
|
-
const { collection, label, placeholder, size, ...rootProps } = props;
|
|
27
|
-
const { icons } = useCerberusContext();
|
|
28
|
-
const { selectArrow: SelectArrow, invalid: InvalidIcon } = icons;
|
|
29
|
-
const styles = select({ size });
|
|
30
|
-
return /* @__PURE__ */ jsxs(
|
|
31
|
-
ArkSelect.Root,
|
|
32
|
-
{
|
|
33
|
-
className: styles.root,
|
|
34
|
-
collection,
|
|
35
|
-
...rootProps,
|
|
36
|
-
children: [
|
|
37
|
-
/* @__PURE__ */ jsxs(ArkSelect.Label, { className: styles.label, children: [
|
|
38
|
-
label,
|
|
39
|
-
/* @__PURE__ */ jsx(Show, { when: props.required, children: /* @__PURE__ */ jsx(Text, { as: "span", color: "page.text.100", children: "(required)" }) })
|
|
40
|
-
] }),
|
|
41
|
-
/* @__PURE__ */ jsx(ArkSelect.Control, { className: styles.control, children: /* @__PURE__ */ jsxs(ArkSelect.Trigger, { className: styles.trigger, children: [
|
|
42
|
-
/* @__PURE__ */ jsx(ArkSelect.ValueText, { placeholder }),
|
|
43
|
-
/* @__PURE__ */ jsxs(HStack, { children: [
|
|
44
|
-
/* @__PURE__ */ jsx(Show, { when: props.invalid, children: /* @__PURE__ */ jsx(InvalidIcon, { "data-part": "invalid-icon" }) }),
|
|
45
|
-
/* @__PURE__ */ jsx(ArkSelect.Indicator, { className: styles.indicator, children: /* @__PURE__ */ jsx(SelectArrow, {}) })
|
|
46
|
-
] })
|
|
47
|
-
] }) }),
|
|
48
|
-
/* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(ArkSelect.Positioner, { className: styles.positioner, children: /* @__PURE__ */ jsx(ArkSelect.Content, { className: styles.content, children: props.children }) }) }),
|
|
49
|
-
/* @__PURE__ */ jsx(ArkSelect.HiddenSelect, {})
|
|
50
|
-
]
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
function Option(props) {
|
|
55
|
-
const { item, ...itemProps } = props;
|
|
56
|
-
const { icons } = useCerberusContext();
|
|
57
|
-
const { selectChecked: CheckedIcon } = icons;
|
|
58
|
-
const styles = select();
|
|
59
|
-
return /* @__PURE__ */ jsxs(ArkSelect.Item, { ...itemProps, item, className: styles.item, children: [
|
|
60
|
-
/* @__PURE__ */ jsx(ArkSelect.ItemText, { className: styles.itemText, children: item?.label }),
|
|
61
|
-
/* @__PURE__ */ jsx(ArkSelect.ItemIndicator, { className: styles.itemIndicator, children: /* @__PURE__ */ jsx(CheckedIcon, {}) })
|
|
62
|
-
] });
|
|
63
|
-
}
|
|
64
|
-
function OptionGroup(props) {
|
|
65
|
-
return /* @__PURE__ */ jsx(ArkSelect.ItemGroup, { ...props });
|
|
66
|
-
}
|
|
67
|
-
function OptionGroupLabel(props) {
|
|
68
|
-
const styles = select();
|
|
69
|
-
return /* @__PURE__ */ jsx(
|
|
70
|
-
ArkSelect.ItemGroupLabel,
|
|
71
|
-
{
|
|
72
|
-
...props,
|
|
73
|
-
className: cx(props.className, styles.itemGroupLabel)
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
function createSelectCollection(collection) {
|
|
78
|
-
return createListCollection({
|
|
79
|
-
items: collection
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
Select,
|
|
85
|
-
Option,
|
|
86
|
-
OptionGroup,
|
|
87
|
-
OptionGroupLabel,
|
|
88
|
-
createSelectCollection
|
|
89
|
-
};
|
|
90
|
-
//# sourceMappingURL=chunk-X6WFDKKJ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Select.tsx"],"sourcesContent":["'use client'\n\nimport {\n Select as ArkSelect,\n createListCollection,\n type SelectRootProps,\n type SelectItemProps,\n type SelectItemGroupProps,\n type SelectItemGroupLabelProps,\n type ListCollection,\n type SelectValueChangeDetails,\n} from '@ark-ui/react/select'\nimport {\n select,\n type SelectVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { cx } from '@cerberus/styled-system/css'\nimport { HStack } from '@cerberus/styled-system/jsx'\nimport { useCerberusContext } from '../context/cerberus'\nimport { Portal } from './Portal'\nimport { Show } from './Show'\nimport { Text } from './Text'\n\n/**\n * This module contains the Select components.\n * @module 'react/select'\n */\n\nexport interface SelectCollectionItem {\n /**\n * What is displayed in the dropdown list.\n */\n label: string\n /**\n * The value of the selected item used in the form.\n */\n value: string\n /**\n * If the item is disabled.\n */\n disabled?: boolean\n}\n\nexport interface SelectCollection {\n /**\n * The items to be displayed in the dropdown list.\n */\n items: SelectCollectionItem[]\n}\n\nexport interface BaseSelectProps {\n /**\n * The placeholder text when no option is selected.\n */\n placeholder?: string\n /**\n * The label of the select.\n */\n label: string\n}\n\nexport type SelectProps = SelectRootProps<SelectCollectionItem> &\n BaseSelectProps &\n SelectVariantProps\n\n/**\n * The Select component is a dropdown list that allows users to select an\n * option from a list.\n * @definition [Select docs](https://cerberus.digitalu.design/react/select)\n * @definition [ARK docs](https://ark-ui.com/react/docs/components/select)\n * @example\n * ```tsx\n * import { Select, Option, createListCollection } from '@cerberus-design/react'\n *\n * export function SelectBasicPreview() {\n * const collection = createListCollection({\n * items: [\n * { label: 'Hades', value: 'hades' },\n * { label: 'Persephone', value: 'persephone' },\n * { label: 'Zeus', value: 'zeus', disabled: true },\n * ]\n * })\n *\n * return (\n * <Select\n * collection={collection}\n * label=\"Select Relative\"\n * placeholder=\"Choose option\"\n * >\n * {collection.items.map((item) => (\n * <Option key={item.value} item={item} />\n * ))}\n * </Select>\n * )\n * }\n */\nexport function Select(props: SelectProps) {\n const { collection, label, placeholder, size, ...rootProps } = props\n const { icons } = useCerberusContext()\n const { selectArrow: SelectArrow, invalid: InvalidIcon } = icons\n\n const styles = select({ size })\n\n return (\n <ArkSelect.Root\n className={styles.root}\n collection={collection}\n {...rootProps}\n >\n <ArkSelect.Label className={styles.label}>\n {label}\n <Show when={props.required}>\n <Text as=\"span\" color=\"page.text.100\">\n (required)\n </Text>\n </Show>\n </ArkSelect.Label>\n\n <ArkSelect.Control className={styles.control}>\n <ArkSelect.Trigger className={styles.trigger}>\n <ArkSelect.ValueText placeholder={placeholder} />\n\n <HStack>\n <Show when={props.invalid}>\n <InvalidIcon data-part=\"invalid-icon\" />\n </Show>\n <ArkSelect.Indicator className={styles.indicator}>\n <SelectArrow />\n </ArkSelect.Indicator>\n </HStack>\n </ArkSelect.Trigger>\n </ArkSelect.Control>\n\n <Portal>\n <ArkSelect.Positioner className={styles.positioner}>\n <ArkSelect.Content className={styles.content}>\n {props.children}\n </ArkSelect.Content>\n </ArkSelect.Positioner>\n </Portal>\n\n <ArkSelect.HiddenSelect />\n </ArkSelect.Root>\n )\n}\n\nexport interface OptionProps extends SelectItemProps {\n /**\n * The CollectionListItem to be displayed in the dropdown list.\n */\n item: SelectCollectionItem\n}\n\nexport function Option(props: OptionProps) {\n const { item, ...itemProps } = props\n\n const { icons } = useCerberusContext()\n const { selectChecked: CheckedIcon } = icons\n\n const styles = select()\n\n return (\n <ArkSelect.Item {...itemProps} item={item} className={styles.item}>\n <ArkSelect.ItemText className={styles.itemText}>\n {item?.label}\n </ArkSelect.ItemText>\n <ArkSelect.ItemIndicator className={styles.itemIndicator}>\n <CheckedIcon />\n </ArkSelect.ItemIndicator>\n </ArkSelect.Item>\n )\n}\n\n/**\n * The OptionGroup component is a group of options in the dropdown list.\n * @definition [Select docs](https://cerberus.digitalu.design/react/select)\n * @definition [ARK docs](https://ark-ui.com/react/docs/components/select)\n * @example\n * ```tsx\n * <OptionGroup>\n * <OptionGroupLabel>Greek gods</OptionGroupLabel>\n * ...\n * </OptionGroup>\n * ```\n */\nexport function OptionGroup(props: SelectItemGroupProps) {\n return <ArkSelect.ItemGroup {...props} />\n}\n\n/**\n * The OptionGroupLabel component is the label of the OptionGroup.\n * @definition [Select docs](https://cerberus.digitalu.design/react/select)\n * @definition [ARK docs](https://ark-ui.com/react/docs/components/select)\n * @example\n * ```tsx\n * <OptionGroupLabel>Greek gods</OptionGroupLabel>\n * ```\n */\nexport function OptionGroupLabel(props: SelectItemGroupLabelProps) {\n const styles = select()\n return (\n <ArkSelect.ItemGroupLabel\n {...props}\n className={cx(props.className, styles.itemGroupLabel)}\n />\n )\n}\n\n/**\n * A helper function to create a SelectCollection object.\n * @param collection - An array of SelectCollectionItem objects that matches\n * the following shape:\n * ```ts\n * [{ label: 'Hades', value: 'hades', disabled?: true }]\n * ```\n */\nexport function createSelectCollection(\n collection: SelectCollectionItem[],\n): ListCollection<SelectCollectionItem> {\n return createListCollection({\n items: collection,\n })\n}\n\nexport type { SelectValueChangeDetails, ListCollection }\n"],"mappings":";;;;;;;;;;;;;;AAEA;AAAA,EACE,UAAU;AAAA,EACV;AAAA,OAOK;AACP;AAAA,EACE;AAAA,OAEK;AACP,SAAS,UAAU;AACnB,SAAS,cAAc;AA4FjB,SAGI,KAHJ;AAbC,SAAS,OAAO,OAAoB;AACzC,QAAM,EAAE,YAAY,OAAO,aAAa,MAAM,GAAG,UAAU,IAAI;AAC/D,QAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,QAAM,EAAE,aAAa,aAAa,SAAS,YAAY,IAAI;AAE3D,QAAM,SAAS,OAAO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