@cerberus-design/react 0.6.1-next-bda4df1 → 0.6.1-next-f9a7124
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.ts +77 -0
- package/build/legacy/chunk-4CAT3FHV.js +11 -0
- package/build/legacy/chunk-4CAT3FHV.js.map +1 -0
- package/build/legacy/{chunk-5XNLWIZO.js → chunk-EVEEQRH6.js} +2 -2
- package/build/legacy/chunk-EVEEQRH6.js.map +1 -0
- package/build/legacy/chunk-JDRWQFCE.js +22 -0
- package/build/legacy/chunk-JDRWQFCE.js.map +1 -0
- package/build/legacy/{chunk-HE3HFKYU.js → chunk-JJGZRBIR.js} +2 -2
- package/build/legacy/{chunk-HE3HFKYU.js.map → chunk-JJGZRBIR.js.map} +1 -1
- package/build/legacy/{chunk-G2QMBSK5.js → chunk-PMCYXRAH.js} +2 -2
- package/build/legacy/chunk-PMCYXRAH.js.map +1 -0
- package/build/legacy/chunk-ZVNBWU4J.js +18 -0
- package/build/legacy/chunk-ZVNBWU4J.js.map +1 -0
- package/build/legacy/components/FeatureFlag.js +10 -0
- package/build/legacy/components/FeatureFlag.js.map +1 -0
- package/build/legacy/components/Label.js +1 -1
- package/build/legacy/components/NavMenuList.js +1 -1
- package/build/legacy/components/Portal.js +7 -0
- package/build/legacy/components/Portal.js.map +1 -0
- package/build/legacy/components/Tag.js +1 -1
- package/build/legacy/context/feature-flags.js +10 -0
- package/build/legacy/context/feature-flags.js.map +1 -0
- package/build/legacy/index.js +26 -12
- package/build/modern/_tsup-dts-rollup.d.ts +77 -0
- package/build/modern/chunk-4CAT3FHV.js +11 -0
- package/build/modern/chunk-4CAT3FHV.js.map +1 -0
- package/build/modern/chunk-JDRWQFCE.js +22 -0
- package/build/modern/chunk-JDRWQFCE.js.map +1 -0
- package/build/modern/{chunk-HE3HFKYU.js → chunk-JJGZRBIR.js} +2 -2
- package/build/modern/{chunk-HE3HFKYU.js.map → chunk-JJGZRBIR.js.map} +1 -1
- package/build/modern/{chunk-G2QMBSK5.js → chunk-PMCYXRAH.js} +2 -2
- package/build/modern/chunk-PMCYXRAH.js.map +1 -0
- package/build/modern/{chunk-SLIOCQBZ.js → chunk-Z6IWNVPN.js} +2 -2
- package/build/modern/chunk-Z6IWNVPN.js.map +1 -0
- package/build/modern/chunk-ZVNBWU4J.js +18 -0
- package/build/modern/chunk-ZVNBWU4J.js.map +1 -0
- package/build/modern/components/FeatureFlag.js +10 -0
- package/build/modern/components/FeatureFlag.js.map +1 -0
- package/build/modern/components/Label.js +1 -1
- package/build/modern/components/NavMenuList.js +1 -1
- package/build/modern/components/Portal.js +7 -0
- package/build/modern/components/Portal.js.map +1 -0
- package/build/modern/components/Tag.js +1 -1
- package/build/modern/context/feature-flags.js +10 -0
- package/build/modern/context/feature-flags.js.map +1 -0
- package/build/modern/index.js +26 -12
- package/package.json +3 -2
- package/src/components/FeatureFlag.tsx +14 -0
- package/src/components/Label.tsx +1 -1
- package/src/components/NavMenuList.tsx +1 -1
- package/src/components/Portal.tsx +22 -0
- package/src/components/Tag.tsx +1 -1
- package/src/context/feature-flags.tsx +60 -0
- package/src/index.ts +3 -0
- package/build/legacy/chunk-5XNLWIZO.js.map +0 -1
- package/build/legacy/chunk-G2QMBSK5.js.map +0 -1
- package/build/modern/chunk-G2QMBSK5.js.map +0 -1
- package/build/modern/chunk-SLIOCQBZ.js.map +0 -1
|
@@ -17,6 +17,7 @@ import type { Pretty } from '@cerberus-design/styled-system/types';
|
|
|
17
17
|
import { PropsWithChildren } from 'react';
|
|
18
18
|
import { radio } from '@cerberus-design/styled-system/recipes';
|
|
19
19
|
import { ReactNode } from 'react';
|
|
20
|
+
import { ReactPortal } from 'react';
|
|
20
21
|
import { RecipeVariantProps } from '@cerberus/styled-system/css';
|
|
21
22
|
import type { RecipeVariantProps as RecipeVariantProps_2 } from '@cerberus-design/styled-system/types';
|
|
22
23
|
import type { RecipeVariantProps as RecipeVariantProps_3 } from '@cerberus/styled-system/types';
|
|
@@ -83,6 +84,58 @@ declare function defineIcons(icons: DefinedIcons): DefinedIcons;
|
|
|
83
84
|
export { defineIcons }
|
|
84
85
|
export { defineIcons as defineIcons_alias_1 }
|
|
85
86
|
|
|
87
|
+
declare function FeatureFlag(props: PropsWithChildren<FeatureFlagProps>): JSX_2.Element;
|
|
88
|
+
export { FeatureFlag }
|
|
89
|
+
export { FeatureFlag as FeatureFlag_alias_1 }
|
|
90
|
+
|
|
91
|
+
declare interface FeatureFlagProps {
|
|
92
|
+
flag: string;
|
|
93
|
+
}
|
|
94
|
+
export { FeatureFlagProps }
|
|
95
|
+
export { FeatureFlagProps as FeatureFlagProps_alias_1 }
|
|
96
|
+
|
|
97
|
+
declare interface FeatureFlagProviderProps {
|
|
98
|
+
flags: FeatureFlagValue;
|
|
99
|
+
}
|
|
100
|
+
export { FeatureFlagProviderProps }
|
|
101
|
+
export { FeatureFlagProviderProps as FeatureFlagProviderProps_alias_1 }
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Provides feature flags to the application.
|
|
105
|
+
* @param flags - The flags data for the provider.
|
|
106
|
+
* @example
|
|
107
|
+
* ```tsx
|
|
108
|
+
* // This should be a JSON file or a server response.
|
|
109
|
+
* const flags = {
|
|
110
|
+
* featureOne: true,
|
|
111
|
+
* featureTwo: false
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
* // Wrap the Provider around the root of your application.
|
|
115
|
+
* <FeatureFlagProvider flags={flags}>
|
|
116
|
+
* <FeatureFlag flag="featureOne">
|
|
117
|
+
* This is visible.
|
|
118
|
+
* </FeatureFlag>
|
|
119
|
+
* <FeatureFlag flag="featureTwo">
|
|
120
|
+
* This is hidden.
|
|
121
|
+
* </FeatureFlag>
|
|
122
|
+
* </FeatureFlagProvider>
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
declare function FeatureFlags(props: PropsWithChildren<FeatureFlagProviderProps>): JSX_2.Element;
|
|
126
|
+
export { FeatureFlags }
|
|
127
|
+
export { FeatureFlags as FeatureFlags_alias_1 }
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* This module provides a context and hook for feature flags.
|
|
131
|
+
* @module
|
|
132
|
+
*/
|
|
133
|
+
declare interface FeatureFlagValue {
|
|
134
|
+
[key: string]: boolean;
|
|
135
|
+
}
|
|
136
|
+
export { FeatureFlagValue }
|
|
137
|
+
export { FeatureFlagValue as FeatureFlagValue_alias_1 }
|
|
138
|
+
|
|
86
139
|
declare function Field(props: PropsWithChildren<FieldContextValue>): JSX.Element;
|
|
87
140
|
export { Field }
|
|
88
141
|
export { Field as Field_alias_1 }
|
|
@@ -318,6 +371,26 @@ declare type NavTriggerRef = RefObject<HTMLButtonElement>;
|
|
|
318
371
|
export { NavTriggerRef }
|
|
319
372
|
export { NavTriggerRef as NavTriggerRef_alias_1 }
|
|
320
373
|
|
|
374
|
+
/**
|
|
375
|
+
* The Portal component is used to render children into a DOM node that exists outside the DOM hierarchy of the parent component.
|
|
376
|
+
* @param container - The props for the Portal component.
|
|
377
|
+
* @returns ReactPortal
|
|
378
|
+
*/
|
|
379
|
+
declare function Portal(props: PropsWithChildren<PortalProps>): ReactPortal;
|
|
380
|
+
export { Portal }
|
|
381
|
+
export { Portal as Portal_alias_1 }
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* This module is the Portal component.
|
|
385
|
+
* @module
|
|
386
|
+
*/
|
|
387
|
+
declare interface PortalProps {
|
|
388
|
+
container?: Element | DocumentFragment;
|
|
389
|
+
key?: null | string;
|
|
390
|
+
}
|
|
391
|
+
export { PortalProps }
|
|
392
|
+
export { PortalProps as PortalProps_alias_1 }
|
|
393
|
+
|
|
321
394
|
declare type Positions = 'top' | 'right' | 'bottom' | 'left';
|
|
322
395
|
export { Positions }
|
|
323
396
|
export { Positions as Positions_alias_1 }
|
|
@@ -587,6 +660,10 @@ declare type ToggleProps = ToggleBase & ToggleVariantProps;
|
|
|
587
660
|
export { ToggleProps }
|
|
588
661
|
export { ToggleProps as ToggleProps_alias_1 }
|
|
589
662
|
|
|
663
|
+
declare function useFeatureFlags(key: string): boolean;
|
|
664
|
+
export { useFeatureFlags }
|
|
665
|
+
export { useFeatureFlags as useFeatureFlags_alias_1 }
|
|
666
|
+
|
|
590
667
|
declare function useFieldContext(): FieldContextValue;
|
|
591
668
|
export { useFieldContext }
|
|
592
669
|
export { useFieldContext as useFieldContext_alias_1 }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/components/Portal.tsx
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
function Portal(props) {
|
|
4
|
+
const container = props.container || document.body;
|
|
5
|
+
return createPortal(props.children, container, props.key);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
Portal
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=chunk-4CAT3FHV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Portal.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react'\nimport { createPortal } from 'react-dom'\n\n/**\n * This module is the Portal component.\n * @module\n */\n\nexport interface PortalProps {\n container?: Element | DocumentFragment\n key?: null | string\n}\n\n/**\n * The Portal component is used to render children into a DOM node that exists outside the DOM hierarchy of the parent component.\n * @param container - The props for the Portal component.\n * @returns ReactPortal\n */\nexport function Portal(props: PropsWithChildren<PortalProps>) {\n const container = props.container || document.body\n return createPortal(props.children, container, props.key)\n}\n"],"mappings":";AACA,SAAS,oBAAoB;AAiBtB,SAAS,OAAO,OAAuC;AAC5D,QAAM,YAAY,MAAM,aAAa,SAAS;AAC9C,SAAO,aAAa,MAAM,UAAU,WAAW,MAAM,GAAG;AAC1D;","names":[]}
|
|
@@ -9,7 +9,7 @@ import { iconButton, tag } from "@cerberus/styled-system/recipes";
|
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
function Tag(props) {
|
|
11
11
|
const { shape: initShape, gradient, onClick, usage, ...nativeProps } = props;
|
|
12
|
-
const palette = (props == null ? void 0 : props.palette) ?? "
|
|
12
|
+
const palette = (props == null ? void 0 : props.palette) ?? "page";
|
|
13
13
|
const isClosable = Boolean(onClick);
|
|
14
14
|
const shape = isClosable ? "pill" : initShape;
|
|
15
15
|
const closableStyles = isClosable ? closableCss : "";
|
|
@@ -55,4 +55,4 @@ var closableCss = css({
|
|
|
55
55
|
export {
|
|
56
56
|
Tag
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-EVEEQRH6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Tag.tsx"],"sourcesContent":["import type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { Close } from '@cerberus/icons'\nimport { Show } from './Show'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { iconButton, tag } from '@cerberus/styled-system/recipes'\nimport type { RecipeVariantProps } from '@cerberus/styled-system/types'\n\n/**\n * This module contains the tag component.\n * @module\n */\n\nexport type TagRecipeProps = RecipeVariantProps<typeof tag>\n\nexport type StaticTagProps = HTMLAttributes<HTMLSpanElement> &\n TagRecipeProps & {\n onClick?: never\n }\n\nexport type ClickableTagProps = HTMLAttributes<HTMLSpanElement> & {\n gradient?: never\n palette?: never\n onClick: () => void\n shape: 'pill'\n usage: 'filled'\n}\n\nexport type TagProps = StaticTagProps | ClickableTagProps\n\n/**\n * The Tag component is used to display a meta descriptions.\n * @definition [Tag docs](https://cerberus.digitalu.design/react/tags)\n * @example\n * ```tsx\n * <Tag>Tag</Tag>\n * ```\n */\nexport function Tag(props: PropsWithChildren<TagProps>): JSX.Element {\n const { shape: initShape, gradient, onClick, usage, ...nativeProps } = props\n const palette = props?.palette ?? 'page'\n const isClosable = Boolean(onClick)\n const shape = isClosable ? 'pill' : initShape\n const closableStyles = isClosable ? closableCss : ''\n\n return (\n <span\n {...nativeProps}\n className={cx(\n nativeProps.className,\n tag({\n gradient,\n palette,\n shape,\n usage,\n }),\n closableStyles,\n )}\n >\n {props.children}\n\n <Show when={isClosable}>\n <button\n aria-label=\"Close\"\n className={iconButton({\n palette: 'action',\n usage: 'filled',\n size: 'sm',\n })}\n onClick={onClick}\n >\n <Close />\n </button>\n </Show>\n </span>\n )\n}\n\nconst closableCss = css({\n bgColor: 'action.bg.active',\n color: 'action.text.initial',\n paddingInlineEnd: '0',\n})\n"],"mappings":";;;;;AACA,SAAS,aAAa;AAEtB,SAAS,KAAK,UAAU;AACxB,SAAS,YAAY,WAAW;AAyC5B,SAyBM,KAzBN;AARG,SAAS,IAAI,OAAiD;AACnE,QAAM,EAAE,OAAO,WAAW,UAAU,SAAS,OAAO,GAAG,YAAY,IAAI;AACvE,QAAM,WAAU,+BAAO,YAAW;AAClC,QAAM,aAAa,QAAQ,OAAO;AAClC,QAAM,QAAQ,aAAa,SAAS;AACpC,QAAM,iBAAiB,aAAa,cAAc;AAElD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,IAAI;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD;AAAA,MACF;AAAA,MAEC;AAAA,cAAM;AAAA,QAEP,oBAAC,QAAK,MAAM,YACV;AAAA,UAAC;AAAA;AAAA,YACC,cAAW;AAAA,YACX,WAAW,WAAW;AAAA,cACpB,SAAS;AAAA,cACT,OAAO;AAAA,cACP,MAAM;AAAA,YACR,CAAC;AAAA,YACD;AAAA,YAEA,8BAAC,SAAM;AAAA;AAAA,QACT,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAM,cAAc,IAAI;AAAA,EACtB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,kBAAkB;AACpB,CAAC;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/context/feature-flags.tsx
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var FeatureFlagContext = createContext(null);
|
|
5
|
+
function FeatureFlags(props) {
|
|
6
|
+
return /* @__PURE__ */ jsx(FeatureFlagContext.Provider, { value: props.flags, children: props.children });
|
|
7
|
+
}
|
|
8
|
+
function useFeatureFlags(key) {
|
|
9
|
+
const context = useContext(FeatureFlagContext);
|
|
10
|
+
if (context === null) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"useFeatureFlag must be used within a FeatureFlags Provider"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
return context[key] ?? false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
FeatureFlags,
|
|
20
|
+
useFeatureFlags
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=chunk-JDRWQFCE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/feature-flags.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, useContext, type PropsWithChildren } from 'react'\n\n/**\n * This module provides a context and hook for feature flags.\n * @module\n */\n\nexport interface FeatureFlagValue {\n [key: string]: boolean\n}\n\nconst FeatureFlagContext = createContext<FeatureFlagValue | null>(null)\n\nexport interface FeatureFlagProviderProps {\n flags: FeatureFlagValue\n}\n\n/**\n * Provides feature flags to the application.\n * @param flags - The flags data for the provider.\n * @example\n * ```tsx\n * // This should be a JSON file or a server response.\n * const flags = {\n * featureOne: true,\n * featureTwo: false\n * }\n *\n * // Wrap the Provider around the root of your application.\n * <FeatureFlagProvider flags={flags}>\n * <FeatureFlag flag=\"featureOne\">\n * This is visible.\n * </FeatureFlag>\n * <FeatureFlag flag=\"featureTwo\">\n * This is hidden.\n * </FeatureFlag>\n * </FeatureFlagProvider>\n * ```\n */\nexport function FeatureFlags(\n props: PropsWithChildren<FeatureFlagProviderProps>,\n) {\n return (\n <FeatureFlagContext.Provider value={props.flags}>\n {props.children}\n </FeatureFlagContext.Provider>\n )\n}\n\nexport function useFeatureFlags(key: string): boolean {\n const context = useContext(FeatureFlagContext)\n if (context === null) {\n throw new Error(\n 'useFeatureFlag must be used within a FeatureFlags Provider',\n )\n }\n return context[key] ?? false\n}\n"],"mappings":";AAEA,SAAS,eAAe,kBAA0C;AA2C9D;AAhCJ,IAAM,qBAAqB,cAAuC,IAAI;AA4B/D,SAAS,aACd,OACA;AACA,SACE,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,MAAM,OACvC,gBAAM,UACT;AAEJ;AAEO,SAAS,gBAAgB,KAAsB;AACpD,QAAM,UAAU,WAAW,kBAAkB;AAC7C,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,QAAQ,GAAG,KAAK;AACzB;","names":[]}
|
|
@@ -32,7 +32,7 @@ function Label(props) {
|
|
|
32
32
|
"span",
|
|
33
33
|
{
|
|
34
34
|
className: css({
|
|
35
|
-
color: "
|
|
35
|
+
color: "page.text.100",
|
|
36
36
|
fontSize: "inherit"
|
|
37
37
|
}),
|
|
38
38
|
children: "(required)"
|
|
@@ -46,4 +46,4 @@ function Label(props) {
|
|
|
46
46
|
export {
|
|
47
47
|
Label
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-JJGZRBIR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Label.tsx"],"sourcesContent":["'use client'\n\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { label } from '@cerberus/styled-system/recipes'\nimport { css, cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { hstack } from '@cerberus/styled-system/patterns'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\n\n/**\n * This module contains the Label component.\n * @module\n */\n\nexport type LabelRecipeProps = RecipeVariantProps<typeof label>\nexport interface LabelBaseProps extends HTMLAttributes<HTMLLabelElement> {\n htmlFor: string\n hidden?: boolean\n}\nexport type LabelProps = LabelBaseProps & LabelRecipeProps\n\n/**\n * A screen ready friendly label component.\n * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)\n * @definition [Label docs](https://cerberus.digitalu.design/react/label)\n * @example\n * ```tsx\n * <Field required>\n * <Label htmlFor=\"test\">Test Label</Label>\n * </Field>\n * ```\n */\nexport function Label(props: PropsWithChildren<LabelProps>) {\n const { hidden, size, ...nativeProps } = props\n const { required, disabled } = useFieldContext()\n const usage = hidden ? 'hidden' : 'visible'\n\n return (\n <label\n {...nativeProps}\n data-disabled={disabled}\n className={cx(\n nativeProps.className,\n label({ size, usage }),\n hstack({\n justify: 'space-between',\n }),\n )}\n >\n {props.children}\n <Show when={required}>\n <span\n className={css({\n color: '
|
|
1
|
+
{"version":3,"sources":["../../src/components/Label.tsx"],"sourcesContent":["'use client'\n\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { label } from '@cerberus/styled-system/recipes'\nimport { css, cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { hstack } from '@cerberus/styled-system/patterns'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\n\n/**\n * This module contains the Label component.\n * @module\n */\n\nexport type LabelRecipeProps = RecipeVariantProps<typeof label>\nexport interface LabelBaseProps extends HTMLAttributes<HTMLLabelElement> {\n htmlFor: string\n hidden?: boolean\n}\nexport type LabelProps = LabelBaseProps & LabelRecipeProps\n\n/**\n * A screen ready friendly label component.\n * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)\n * @definition [Label docs](https://cerberus.digitalu.design/react/label)\n * @example\n * ```tsx\n * <Field required>\n * <Label htmlFor=\"test\">Test Label</Label>\n * </Field>\n * ```\n */\nexport function Label(props: PropsWithChildren<LabelProps>) {\n const { hidden, size, ...nativeProps } = props\n const { required, disabled } = useFieldContext()\n const usage = hidden ? 'hidden' : 'visible'\n\n return (\n <label\n {...nativeProps}\n data-disabled={disabled}\n className={cx(\n nativeProps.className,\n label({ size, usage }),\n hstack({\n justify: 'space-between',\n }),\n )}\n >\n {props.children}\n <Show when={required}>\n <span\n className={css({\n color: 'page.text.100',\n fontSize: 'inherit',\n })}\n >\n (required)\n </span>\n </Show>\n </label>\n )\n}\n"],"mappings":";;;;;;;;AAGA,SAAS,aAAa;AACtB,SAAS,KAAK,UAAmC;AACjD,SAAS,cAAc;AAiCnB,SAaI,KAbJ;AANG,SAAS,MAAM,OAAsC;AAC1D,QAAM,EAAE,QAAQ,MAAM,GAAG,YAAY,IAAI;AACzC,QAAM,EAAE,UAAU,SAAS,IAAI,gBAAgB;AAC/C,QAAM,QAAQ,SAAS,WAAW;AAElC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,iBAAe;AAAA,MACf,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,MAAM,EAAE,MAAM,MAAM,CAAC;AAAA,QACrB,OAAO;AAAA,UACL,SAAS;AAAA,QACX,CAAC;AAAA,MACH;AAAA,MAEC;AAAA,cAAM;AAAA,QACP,oBAAC,QAAK,MAAM,UACV;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,IAAI;AAAA,cACb,OAAO;AAAA,cACP,UAAU;AAAA,YACZ,CAAC;AAAA,YACF;AAAA;AAAA,QAED,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -32,7 +32,7 @@ function getPosition(position) {
|
|
|
32
32
|
}
|
|
33
33
|
var navListStyles = vstack({
|
|
34
34
|
alignItems: "flex-start",
|
|
35
|
-
bgColor: "
|
|
35
|
+
bgColor: "page.surface.100",
|
|
36
36
|
boxShadow: "lg",
|
|
37
37
|
gap: "2",
|
|
38
38
|
opacity: "0",
|
|
@@ -83,4 +83,4 @@ export {
|
|
|
83
83
|
getPosition,
|
|
84
84
|
NavMenuList
|
|
85
85
|
};
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
86
|
+
//# sourceMappingURL=chunk-PMCYXRAH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/NavMenuList.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo, type HTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { useNavMenuContext } from '../context/navMenu'\nimport type { Positions } from '../types'\nimport { Show } from './Show'\n\ninterface GetPositionResult {\n left: string\n right: string\n top: string\n bottom: string\n}\n\nexport function getPosition(position: Positions): GetPositionResult {\n const defaultPositions = {\n left: 'auto',\n right: 'auto',\n top: 'auto',\n bottom: 'auto',\n }\n switch (position) {\n case 'right':\n return { ...defaultPositions, top: '0%', left: '105%' }\n case 'left':\n return { ...defaultPositions, top: '0%', right: '105%' }\n case 'bottom':\n return { ...defaultPositions, top: '110%' }\n case 'top':\n return { ...defaultPositions, bottom: '110%' }\n default:\n return defaultPositions\n }\n}\n\nconst navListStyles = vstack({\n alignItems: 'flex-start',\n bgColor: 'page.surface.100',\n boxShadow: 'lg',\n gap: '2',\n opacity: '0',\n p: '4',\n position: 'absolute',\n rounded: 'md',\n zIndex: 'dropdown',\n _motionSafe: {\n animationName: 'zoomIn',\n animationDelay: '100ms',\n animationDuration: '150ms',\n animationFillMode: 'both',\n animationTimingFunction: 'ease-in-out',\n },\n _positionBottom: {\n transformOrigin: 'top left',\n },\n _positionTop: {\n transformOrigin: 'bottom left',\n },\n _positionLeft: {\n transformOrigin: 'top right',\n },\n _positionRight: {\n transformOrigin: 'top left',\n },\n})\n\nexport interface NavMenuListProps extends HTMLAttributes<HTMLUListElement> {\n id: string\n position?: Positions\n}\n\n/**\n * A component that allows the user to display a menu of navigation links.\n * @definition [Disclosure Nav](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/)\n * @definition [NavMenu Docs](https://cerberus.digitalu.design/react/nav-menu)\n *\n * @example\n * ```tsx\n * <NavMenuList id=\"nav-menu-list\" position=\"bottom\">\n * <NavMenuLink href=\"/home\">Home</NavMenuLink>\n * <NavMenuLink href=\"/about\">About</NavMenuLink>\n * </NavMenuList>\n * ```\n **/\nexport function NavMenuList(props: NavMenuListProps): JSX.Element {\n const { position, ...nativeProps } = props\n const { menuRef, expanded } = useNavMenuContext()\n const locationStyles = useMemo(\n () => getPosition(position ?? 'bottom'),\n [position],\n )\n\n return (\n <Show when={expanded}>\n <ul\n {...nativeProps}\n data-position={position ?? 'bottom'}\n className={cx(nativeProps.className, navListStyles)}\n ref={menuRef}\n style={locationStyles}\n />\n </Show>\n )\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,eAAoC;AAC7C,SAAS,UAAU;AACnB,SAAS,cAAc;AA4FjB;AAhFC,SAAS,YAAY,UAAwC;AAClE,QAAM,mBAAmB;AAAA,IACvB,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AACA,UAAQ,UAAU;AAAA,IAChB,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,MAAM,OAAO;AAAA,IACxD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,OAAO,OAAO;AAAA,IACzD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,OAAO;AAAA,IAC5C,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,QAAQ,OAAO;AAAA,IAC/C;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,gBAAgB,OAAO;AAAA,EAC3B,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAK;AAAA,EACL,SAAS;AAAA,EACT,GAAG;AAAA,EACH,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,aAAa;AAAA,IACX,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,EAC3B;AAAA,EACA,iBAAiB;AAAA,IACf,iBAAiB;AAAA,EACnB;AAAA,EACA,cAAc;AAAA,IACZ,iBAAiB;AAAA,EACnB;AAAA,EACA,eAAe;AAAA,IACb,iBAAiB;AAAA,EACnB;AAAA,EACA,gBAAgB;AAAA,IACd,iBAAiB;AAAA,EACnB;AACF,CAAC;AAoBM,SAAS,YAAY,OAAsC;AAChE,QAAM,EAAE,UAAU,GAAG,YAAY,IAAI;AACrC,QAAM,EAAE,SAAS,SAAS,IAAI,kBAAkB;AAChD,QAAM,iBAAiB;AAAA,IACrB,MAAM,YAAY,YAAY,QAAQ;AAAA,IACtC,CAAC,QAAQ;AAAA,EACX;AAEA,SACE,oBAAC,QAAK,MAAM,UACV;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,iBAAe,YAAY;AAAA,MAC3B,WAAW,GAAG,YAAY,WAAW,aAAa;AAAA,MAClD,KAAK;AAAA,MACL,OAAO;AAAA;AAAA,EACT,GACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFeatureFlags
|
|
3
|
+
} from "./chunk-JDRWQFCE.js";
|
|
4
|
+
import {
|
|
5
|
+
Show
|
|
6
|
+
} from "./chunk-4O4QFF4S.js";
|
|
7
|
+
|
|
8
|
+
// src/components/FeatureFlag.tsx
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
function FeatureFlag(props) {
|
|
11
|
+
const showContent = useFeatureFlags(props.flag);
|
|
12
|
+
return /* @__PURE__ */ jsx(Show, { when: showContent, children: props.children });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
FeatureFlag
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=chunk-ZVNBWU4J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/FeatureFlag.tsx"],"sourcesContent":["'use client'\n\nimport type { PropsWithChildren } from 'react'\nimport { useFeatureFlags } from '../context/feature-flags'\nimport { Show } from './Show'\n\nexport interface FeatureFlagProps {\n flag: string\n}\n\nexport function FeatureFlag(props: PropsWithChildren<FeatureFlagProps>) {\n const showContent = useFeatureFlags(props.flag)\n return <Show when={showContent}>{props.children}</Show>\n}\n"],"mappings":";;;;;;;;AAYS;AAFF,SAAS,YAAY,OAA4C;AACtE,QAAM,cAAc,gBAAgB,MAAM,IAAI;AAC9C,SAAO,oBAAC,QAAK,MAAM,aAAc,gBAAM,UAAS;AAClD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/build/legacy/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Textarea
|
|
3
|
+
} from "./chunk-TCO46FK7.js";
|
|
4
|
+
import {
|
|
5
|
+
Toggle
|
|
6
|
+
} from "./chunk-734PGVLT.js";
|
|
7
|
+
import {
|
|
8
|
+
NavMenuTrigger
|
|
9
|
+
} from "./chunk-RPZAPUCF.js";
|
|
10
|
+
import {
|
|
11
|
+
Portal
|
|
12
|
+
} from "./chunk-4CAT3FHV.js";
|
|
1
13
|
import {
|
|
2
14
|
Radio
|
|
3
15
|
} from "./chunk-WE3JNSNO.js";
|
|
@@ -12,16 +24,17 @@ import {
|
|
|
12
24
|
} from "./chunk-67S42J4B.js";
|
|
13
25
|
import {
|
|
14
26
|
Tag
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import {
|
|
17
|
-
Textarea
|
|
18
|
-
} from "./chunk-TCO46FK7.js";
|
|
19
|
-
import {
|
|
20
|
-
Toggle
|
|
21
|
-
} from "./chunk-734PGVLT.js";
|
|
27
|
+
} from "./chunk-EVEEQRH6.js";
|
|
22
28
|
import {
|
|
23
29
|
Button
|
|
24
30
|
} from "./chunk-2ATICEW3.js";
|
|
31
|
+
import {
|
|
32
|
+
FeatureFlag
|
|
33
|
+
} from "./chunk-ZVNBWU4J.js";
|
|
34
|
+
import {
|
|
35
|
+
FeatureFlags,
|
|
36
|
+
useFeatureFlags
|
|
37
|
+
} from "./chunk-JDRWQFCE.js";
|
|
25
38
|
import {
|
|
26
39
|
FieldMessage
|
|
27
40
|
} from "./chunk-VGHVH2T3.js";
|
|
@@ -33,7 +46,7 @@ import {
|
|
|
33
46
|
} from "./chunk-X4YQ27D5.js";
|
|
34
47
|
import {
|
|
35
48
|
Label
|
|
36
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-JJGZRBIR.js";
|
|
37
50
|
import {
|
|
38
51
|
Field,
|
|
39
52
|
useFieldContext
|
|
@@ -44,10 +57,7 @@ import {
|
|
|
44
57
|
import {
|
|
45
58
|
NavMenuList,
|
|
46
59
|
getPosition
|
|
47
|
-
} from "./chunk-
|
|
48
|
-
import {
|
|
49
|
-
NavMenuTrigger
|
|
50
|
-
} from "./chunk-RPZAPUCF.js";
|
|
60
|
+
} from "./chunk-PMCYXRAH.js";
|
|
51
61
|
import {
|
|
52
62
|
NavMenu,
|
|
53
63
|
useNavMenuContext
|
|
@@ -85,6 +95,8 @@ import {
|
|
|
85
95
|
export {
|
|
86
96
|
$cerberusIcons,
|
|
87
97
|
Button,
|
|
98
|
+
FeatureFlag,
|
|
99
|
+
FeatureFlags,
|
|
88
100
|
Field,
|
|
89
101
|
FieldMessage,
|
|
90
102
|
IconButton,
|
|
@@ -95,6 +107,7 @@ export {
|
|
|
95
107
|
NavMenuLink,
|
|
96
108
|
NavMenuList,
|
|
97
109
|
NavMenuTrigger,
|
|
110
|
+
Portal,
|
|
98
111
|
Radio,
|
|
99
112
|
Show,
|
|
100
113
|
THEME_KEY,
|
|
@@ -110,6 +123,7 @@ export {
|
|
|
110
123
|
createNavTriggerProps,
|
|
111
124
|
defineIcons,
|
|
112
125
|
getPosition,
|
|
126
|
+
useFeatureFlags,
|
|
113
127
|
useFieldContext,
|
|
114
128
|
useNavMenuContext,
|
|
115
129
|
useTabsContext,
|
|
@@ -17,6 +17,7 @@ import type { Pretty } from '@cerberus-design/styled-system/types';
|
|
|
17
17
|
import { PropsWithChildren } from 'react';
|
|
18
18
|
import { radio } from '@cerberus-design/styled-system/recipes';
|
|
19
19
|
import { ReactNode } from 'react';
|
|
20
|
+
import { ReactPortal } from 'react';
|
|
20
21
|
import { RecipeVariantProps } from '@cerberus/styled-system/css';
|
|
21
22
|
import type { RecipeVariantProps as RecipeVariantProps_2 } from '@cerberus-design/styled-system/types';
|
|
22
23
|
import type { RecipeVariantProps as RecipeVariantProps_3 } from '@cerberus/styled-system/types';
|
|
@@ -83,6 +84,58 @@ declare function defineIcons(icons: DefinedIcons): DefinedIcons;
|
|
|
83
84
|
export { defineIcons }
|
|
84
85
|
export { defineIcons as defineIcons_alias_1 }
|
|
85
86
|
|
|
87
|
+
declare function FeatureFlag(props: PropsWithChildren<FeatureFlagProps>): JSX_2.Element;
|
|
88
|
+
export { FeatureFlag }
|
|
89
|
+
export { FeatureFlag as FeatureFlag_alias_1 }
|
|
90
|
+
|
|
91
|
+
declare interface FeatureFlagProps {
|
|
92
|
+
flag: string;
|
|
93
|
+
}
|
|
94
|
+
export { FeatureFlagProps }
|
|
95
|
+
export { FeatureFlagProps as FeatureFlagProps_alias_1 }
|
|
96
|
+
|
|
97
|
+
declare interface FeatureFlagProviderProps {
|
|
98
|
+
flags: FeatureFlagValue;
|
|
99
|
+
}
|
|
100
|
+
export { FeatureFlagProviderProps }
|
|
101
|
+
export { FeatureFlagProviderProps as FeatureFlagProviderProps_alias_1 }
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Provides feature flags to the application.
|
|
105
|
+
* @param flags - The flags data for the provider.
|
|
106
|
+
* @example
|
|
107
|
+
* ```tsx
|
|
108
|
+
* // This should be a JSON file or a server response.
|
|
109
|
+
* const flags = {
|
|
110
|
+
* featureOne: true,
|
|
111
|
+
* featureTwo: false
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
* // Wrap the Provider around the root of your application.
|
|
115
|
+
* <FeatureFlagProvider flags={flags}>
|
|
116
|
+
* <FeatureFlag flag="featureOne">
|
|
117
|
+
* This is visible.
|
|
118
|
+
* </FeatureFlag>
|
|
119
|
+
* <FeatureFlag flag="featureTwo">
|
|
120
|
+
* This is hidden.
|
|
121
|
+
* </FeatureFlag>
|
|
122
|
+
* </FeatureFlagProvider>
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
declare function FeatureFlags(props: PropsWithChildren<FeatureFlagProviderProps>): JSX_2.Element;
|
|
126
|
+
export { FeatureFlags }
|
|
127
|
+
export { FeatureFlags as FeatureFlags_alias_1 }
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* This module provides a context and hook for feature flags.
|
|
131
|
+
* @module
|
|
132
|
+
*/
|
|
133
|
+
declare interface FeatureFlagValue {
|
|
134
|
+
[key: string]: boolean;
|
|
135
|
+
}
|
|
136
|
+
export { FeatureFlagValue }
|
|
137
|
+
export { FeatureFlagValue as FeatureFlagValue_alias_1 }
|
|
138
|
+
|
|
86
139
|
declare function Field(props: PropsWithChildren<FieldContextValue>): JSX.Element;
|
|
87
140
|
export { Field }
|
|
88
141
|
export { Field as Field_alias_1 }
|
|
@@ -318,6 +371,26 @@ declare type NavTriggerRef = RefObject<HTMLButtonElement>;
|
|
|
318
371
|
export { NavTriggerRef }
|
|
319
372
|
export { NavTriggerRef as NavTriggerRef_alias_1 }
|
|
320
373
|
|
|
374
|
+
/**
|
|
375
|
+
* The Portal component is used to render children into a DOM node that exists outside the DOM hierarchy of the parent component.
|
|
376
|
+
* @param container - The props for the Portal component.
|
|
377
|
+
* @returns ReactPortal
|
|
378
|
+
*/
|
|
379
|
+
declare function Portal(props: PropsWithChildren<PortalProps>): ReactPortal;
|
|
380
|
+
export { Portal }
|
|
381
|
+
export { Portal as Portal_alias_1 }
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* This module is the Portal component.
|
|
385
|
+
* @module
|
|
386
|
+
*/
|
|
387
|
+
declare interface PortalProps {
|
|
388
|
+
container?: Element | DocumentFragment;
|
|
389
|
+
key?: null | string;
|
|
390
|
+
}
|
|
391
|
+
export { PortalProps }
|
|
392
|
+
export { PortalProps as PortalProps_alias_1 }
|
|
393
|
+
|
|
321
394
|
declare type Positions = 'top' | 'right' | 'bottom' | 'left';
|
|
322
395
|
export { Positions }
|
|
323
396
|
export { Positions as Positions_alias_1 }
|
|
@@ -587,6 +660,10 @@ declare type ToggleProps = ToggleBase & ToggleVariantProps;
|
|
|
587
660
|
export { ToggleProps }
|
|
588
661
|
export { ToggleProps as ToggleProps_alias_1 }
|
|
589
662
|
|
|
663
|
+
declare function useFeatureFlags(key: string): boolean;
|
|
664
|
+
export { useFeatureFlags }
|
|
665
|
+
export { useFeatureFlags as useFeatureFlags_alias_1 }
|
|
666
|
+
|
|
590
667
|
declare function useFieldContext(): FieldContextValue;
|
|
591
668
|
export { useFieldContext }
|
|
592
669
|
export { useFieldContext as useFieldContext_alias_1 }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/components/Portal.tsx
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
function Portal(props) {
|
|
4
|
+
const container = props.container || document.body;
|
|
5
|
+
return createPortal(props.children, container, props.key);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
Portal
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=chunk-4CAT3FHV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Portal.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react'\nimport { createPortal } from 'react-dom'\n\n/**\n * This module is the Portal component.\n * @module\n */\n\nexport interface PortalProps {\n container?: Element | DocumentFragment\n key?: null | string\n}\n\n/**\n * The Portal component is used to render children into a DOM node that exists outside the DOM hierarchy of the parent component.\n * @param container - The props for the Portal component.\n * @returns ReactPortal\n */\nexport function Portal(props: PropsWithChildren<PortalProps>) {\n const container = props.container || document.body\n return createPortal(props.children, container, props.key)\n}\n"],"mappings":";AACA,SAAS,oBAAoB;AAiBtB,SAAS,OAAO,OAAuC;AAC5D,QAAM,YAAY,MAAM,aAAa,SAAS;AAC9C,SAAO,aAAa,MAAM,UAAU,WAAW,MAAM,GAAG;AAC1D;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/context/feature-flags.tsx
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var FeatureFlagContext = createContext(null);
|
|
5
|
+
function FeatureFlags(props) {
|
|
6
|
+
return /* @__PURE__ */ jsx(FeatureFlagContext.Provider, { value: props.flags, children: props.children });
|
|
7
|
+
}
|
|
8
|
+
function useFeatureFlags(key) {
|
|
9
|
+
const context = useContext(FeatureFlagContext);
|
|
10
|
+
if (context === null) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"useFeatureFlag must be used within a FeatureFlags Provider"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
return context[key] ?? false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
FeatureFlags,
|
|
20
|
+
useFeatureFlags
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=chunk-JDRWQFCE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/feature-flags.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, useContext, type PropsWithChildren } from 'react'\n\n/**\n * This module provides a context and hook for feature flags.\n * @module\n */\n\nexport interface FeatureFlagValue {\n [key: string]: boolean\n}\n\nconst FeatureFlagContext = createContext<FeatureFlagValue | null>(null)\n\nexport interface FeatureFlagProviderProps {\n flags: FeatureFlagValue\n}\n\n/**\n * Provides feature flags to the application.\n * @param flags - The flags data for the provider.\n * @example\n * ```tsx\n * // This should be a JSON file or a server response.\n * const flags = {\n * featureOne: true,\n * featureTwo: false\n * }\n *\n * // Wrap the Provider around the root of your application.\n * <FeatureFlagProvider flags={flags}>\n * <FeatureFlag flag=\"featureOne\">\n * This is visible.\n * </FeatureFlag>\n * <FeatureFlag flag=\"featureTwo\">\n * This is hidden.\n * </FeatureFlag>\n * </FeatureFlagProvider>\n * ```\n */\nexport function FeatureFlags(\n props: PropsWithChildren<FeatureFlagProviderProps>,\n) {\n return (\n <FeatureFlagContext.Provider value={props.flags}>\n {props.children}\n </FeatureFlagContext.Provider>\n )\n}\n\nexport function useFeatureFlags(key: string): boolean {\n const context = useContext(FeatureFlagContext)\n if (context === null) {\n throw new Error(\n 'useFeatureFlag must be used within a FeatureFlags Provider',\n )\n }\n return context[key] ?? false\n}\n"],"mappings":";AAEA,SAAS,eAAe,kBAA0C;AA2C9D;AAhCJ,IAAM,qBAAqB,cAAuC,IAAI;AA4B/D,SAAS,aACd,OACA;AACA,SACE,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,MAAM,OACvC,gBAAM,UACT;AAEJ;AAEO,SAAS,gBAAgB,KAAsB;AACpD,QAAM,UAAU,WAAW,kBAAkB;AAC7C,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,QAAQ,GAAG,KAAK;AACzB;","names":[]}
|
|
@@ -32,7 +32,7 @@ function Label(props) {
|
|
|
32
32
|
"span",
|
|
33
33
|
{
|
|
34
34
|
className: css({
|
|
35
|
-
color: "
|
|
35
|
+
color: "page.text.100",
|
|
36
36
|
fontSize: "inherit"
|
|
37
37
|
}),
|
|
38
38
|
children: "(required)"
|
|
@@ -46,4 +46,4 @@ function Label(props) {
|
|
|
46
46
|
export {
|
|
47
47
|
Label
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-JJGZRBIR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Label.tsx"],"sourcesContent":["'use client'\n\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { label } from '@cerberus/styled-system/recipes'\nimport { css, cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { hstack } from '@cerberus/styled-system/patterns'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\n\n/**\n * This module contains the Label component.\n * @module\n */\n\nexport type LabelRecipeProps = RecipeVariantProps<typeof label>\nexport interface LabelBaseProps extends HTMLAttributes<HTMLLabelElement> {\n htmlFor: string\n hidden?: boolean\n}\nexport type LabelProps = LabelBaseProps & LabelRecipeProps\n\n/**\n * A screen ready friendly label component.\n * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)\n * @definition [Label docs](https://cerberus.digitalu.design/react/label)\n * @example\n * ```tsx\n * <Field required>\n * <Label htmlFor=\"test\">Test Label</Label>\n * </Field>\n * ```\n */\nexport function Label(props: PropsWithChildren<LabelProps>) {\n const { hidden, size, ...nativeProps } = props\n const { required, disabled } = useFieldContext()\n const usage = hidden ? 'hidden' : 'visible'\n\n return (\n <label\n {...nativeProps}\n data-disabled={disabled}\n className={cx(\n nativeProps.className,\n label({ size, usage }),\n hstack({\n justify: 'space-between',\n }),\n )}\n >\n {props.children}\n <Show when={required}>\n <span\n className={css({\n color: '
|
|
1
|
+
{"version":3,"sources":["../../src/components/Label.tsx"],"sourcesContent":["'use client'\n\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { label } from '@cerberus/styled-system/recipes'\nimport { css, cx, type RecipeVariantProps } from '@cerberus/styled-system/css'\nimport { hstack } from '@cerberus/styled-system/patterns'\nimport { useFieldContext } from '../context/field'\nimport { Show } from './Show'\n\n/**\n * This module contains the Label component.\n * @module\n */\n\nexport type LabelRecipeProps = RecipeVariantProps<typeof label>\nexport interface LabelBaseProps extends HTMLAttributes<HTMLLabelElement> {\n htmlFor: string\n hidden?: boolean\n}\nexport type LabelProps = LabelBaseProps & LabelRecipeProps\n\n/**\n * A screen ready friendly label component.\n * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)\n * @definition [Label docs](https://cerberus.digitalu.design/react/label)\n * @example\n * ```tsx\n * <Field required>\n * <Label htmlFor=\"test\">Test Label</Label>\n * </Field>\n * ```\n */\nexport function Label(props: PropsWithChildren<LabelProps>) {\n const { hidden, size, ...nativeProps } = props\n const { required, disabled } = useFieldContext()\n const usage = hidden ? 'hidden' : 'visible'\n\n return (\n <label\n {...nativeProps}\n data-disabled={disabled}\n className={cx(\n nativeProps.className,\n label({ size, usage }),\n hstack({\n justify: 'space-between',\n }),\n )}\n >\n {props.children}\n <Show when={required}>\n <span\n className={css({\n color: 'page.text.100',\n fontSize: 'inherit',\n })}\n >\n (required)\n </span>\n </Show>\n </label>\n )\n}\n"],"mappings":";;;;;;;;AAGA,SAAS,aAAa;AACtB,SAAS,KAAK,UAAmC;AACjD,SAAS,cAAc;AAiCnB,SAaI,KAbJ;AANG,SAAS,MAAM,OAAsC;AAC1D,QAAM,EAAE,QAAQ,MAAM,GAAG,YAAY,IAAI;AACzC,QAAM,EAAE,UAAU,SAAS,IAAI,gBAAgB;AAC/C,QAAM,QAAQ,SAAS,WAAW;AAElC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,iBAAe;AAAA,MACf,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,MAAM,EAAE,MAAM,MAAM,CAAC;AAAA,QACrB,OAAO;AAAA,UACL,SAAS;AAAA,QACX,CAAC;AAAA,MACH;AAAA,MAEC;AAAA,cAAM;AAAA,QACP,oBAAC,QAAK,MAAM,UACV;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,IAAI;AAAA,cACb,OAAO;AAAA,cACP,UAAU;AAAA,YACZ,CAAC;AAAA,YACF;AAAA;AAAA,QAED,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -32,7 +32,7 @@ function getPosition(position) {
|
|
|
32
32
|
}
|
|
33
33
|
var navListStyles = vstack({
|
|
34
34
|
alignItems: "flex-start",
|
|
35
|
-
bgColor: "
|
|
35
|
+
bgColor: "page.surface.100",
|
|
36
36
|
boxShadow: "lg",
|
|
37
37
|
gap: "2",
|
|
38
38
|
opacity: "0",
|
|
@@ -83,4 +83,4 @@ export {
|
|
|
83
83
|
getPosition,
|
|
84
84
|
NavMenuList
|
|
85
85
|
};
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
86
|
+
//# sourceMappingURL=chunk-PMCYXRAH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/NavMenuList.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo, type HTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { useNavMenuContext } from '../context/navMenu'\nimport type { Positions } from '../types'\nimport { Show } from './Show'\n\ninterface GetPositionResult {\n left: string\n right: string\n top: string\n bottom: string\n}\n\nexport function getPosition(position: Positions): GetPositionResult {\n const defaultPositions = {\n left: 'auto',\n right: 'auto',\n top: 'auto',\n bottom: 'auto',\n }\n switch (position) {\n case 'right':\n return { ...defaultPositions, top: '0%', left: '105%' }\n case 'left':\n return { ...defaultPositions, top: '0%', right: '105%' }\n case 'bottom':\n return { ...defaultPositions, top: '110%' }\n case 'top':\n return { ...defaultPositions, bottom: '110%' }\n default:\n return defaultPositions\n }\n}\n\nconst navListStyles = vstack({\n alignItems: 'flex-start',\n bgColor: 'page.surface.100',\n boxShadow: 'lg',\n gap: '2',\n opacity: '0',\n p: '4',\n position: 'absolute',\n rounded: 'md',\n zIndex: 'dropdown',\n _motionSafe: {\n animationName: 'zoomIn',\n animationDelay: '100ms',\n animationDuration: '150ms',\n animationFillMode: 'both',\n animationTimingFunction: 'ease-in-out',\n },\n _positionBottom: {\n transformOrigin: 'top left',\n },\n _positionTop: {\n transformOrigin: 'bottom left',\n },\n _positionLeft: {\n transformOrigin: 'top right',\n },\n _positionRight: {\n transformOrigin: 'top left',\n },\n})\n\nexport interface NavMenuListProps extends HTMLAttributes<HTMLUListElement> {\n id: string\n position?: Positions\n}\n\n/**\n * A component that allows the user to display a menu of navigation links.\n * @definition [Disclosure Nav](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/)\n * @definition [NavMenu Docs](https://cerberus.digitalu.design/react/nav-menu)\n *\n * @example\n * ```tsx\n * <NavMenuList id=\"nav-menu-list\" position=\"bottom\">\n * <NavMenuLink href=\"/home\">Home</NavMenuLink>\n * <NavMenuLink href=\"/about\">About</NavMenuLink>\n * </NavMenuList>\n * ```\n **/\nexport function NavMenuList(props: NavMenuListProps): JSX.Element {\n const { position, ...nativeProps } = props\n const { menuRef, expanded } = useNavMenuContext()\n const locationStyles = useMemo(\n () => getPosition(position ?? 'bottom'),\n [position],\n )\n\n return (\n <Show when={expanded}>\n <ul\n {...nativeProps}\n data-position={position ?? 'bottom'}\n className={cx(nativeProps.className, navListStyles)}\n ref={menuRef}\n style={locationStyles}\n />\n </Show>\n )\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,eAAoC;AAC7C,SAAS,UAAU;AACnB,SAAS,cAAc;AA4FjB;AAhFC,SAAS,YAAY,UAAwC;AAClE,QAAM,mBAAmB;AAAA,IACvB,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AACA,UAAQ,UAAU;AAAA,IAChB,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,MAAM,OAAO;AAAA,IACxD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,OAAO,OAAO;AAAA,IACzD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,OAAO;AAAA,IAC5C,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,QAAQ,OAAO;AAAA,IAC/C;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,gBAAgB,OAAO;AAAA,EAC3B,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAK;AAAA,EACL,SAAS;AAAA,EACT,GAAG;AAAA,EACH,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,aAAa;AAAA,IACX,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,EAC3B;AAAA,EACA,iBAAiB;AAAA,IACf,iBAAiB;AAAA,EACnB;AAAA,EACA,cAAc;AAAA,IACZ,iBAAiB;AAAA,EACnB;AAAA,EACA,eAAe;AAAA,IACb,iBAAiB;AAAA,EACnB;AAAA,EACA,gBAAgB;AAAA,IACd,iBAAiB;AAAA,EACnB;AACF,CAAC;AAoBM,SAAS,YAAY,OAAsC;AAChE,QAAM,EAAE,UAAU,GAAG,YAAY,IAAI;AACrC,QAAM,EAAE,SAAS,SAAS,IAAI,kBAAkB;AAChD,QAAM,iBAAiB;AAAA,IACrB,MAAM,YAAY,YAAY,QAAQ;AAAA,IACtC,CAAC,QAAQ;AAAA,EACX;AAEA,SACE,oBAAC,QAAK,MAAM,UACV;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,iBAAe,YAAY;AAAA,MAC3B,WAAW,GAAG,YAAY,WAAW,aAAa;AAAA,MAClD,KAAK;AAAA,MACL,OAAO;AAAA;AAAA,EACT,GACF;AAEJ;","names":[]}
|
|
@@ -9,7 +9,7 @@ import { iconButton, tag } from "@cerberus/styled-system/recipes";
|
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
function Tag(props) {
|
|
11
11
|
const { shape: initShape, gradient, onClick, usage, ...nativeProps } = props;
|
|
12
|
-
const palette = props?.palette ?? "
|
|
12
|
+
const palette = props?.palette ?? "page";
|
|
13
13
|
const isClosable = Boolean(onClick);
|
|
14
14
|
const shape = isClosable ? "pill" : initShape;
|
|
15
15
|
const closableStyles = isClosable ? closableCss : "";
|
|
@@ -55,4 +55,4 @@ var closableCss = css({
|
|
|
55
55
|
export {
|
|
56
56
|
Tag
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-Z6IWNVPN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Tag.tsx"],"sourcesContent":["import type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { Close } from '@cerberus/icons'\nimport { Show } from './Show'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { iconButton, tag } from '@cerberus/styled-system/recipes'\nimport type { RecipeVariantProps } from '@cerberus/styled-system/types'\n\n/**\n * This module contains the tag component.\n * @module\n */\n\nexport type TagRecipeProps = RecipeVariantProps<typeof tag>\n\nexport type StaticTagProps = HTMLAttributes<HTMLSpanElement> &\n TagRecipeProps & {\n onClick?: never\n }\n\nexport type ClickableTagProps = HTMLAttributes<HTMLSpanElement> & {\n gradient?: never\n palette?: never\n onClick: () => void\n shape: 'pill'\n usage: 'filled'\n}\n\nexport type TagProps = StaticTagProps | ClickableTagProps\n\n/**\n * The Tag component is used to display a meta descriptions.\n * @definition [Tag docs](https://cerberus.digitalu.design/react/tags)\n * @example\n * ```tsx\n * <Tag>Tag</Tag>\n * ```\n */\nexport function Tag(props: PropsWithChildren<TagProps>): JSX.Element {\n const { shape: initShape, gradient, onClick, usage, ...nativeProps } = props\n const palette = props?.palette ?? 'page'\n const isClosable = Boolean(onClick)\n const shape = isClosable ? 'pill' : initShape\n const closableStyles = isClosable ? closableCss : ''\n\n return (\n <span\n {...nativeProps}\n className={cx(\n nativeProps.className,\n tag({\n gradient,\n palette,\n shape,\n usage,\n }),\n closableStyles,\n )}\n >\n {props.children}\n\n <Show when={isClosable}>\n <button\n aria-label=\"Close\"\n className={iconButton({\n palette: 'action',\n usage: 'filled',\n size: 'sm',\n })}\n onClick={onClick}\n >\n <Close />\n </button>\n </Show>\n </span>\n )\n}\n\nconst closableCss = css({\n bgColor: 'action.bg.active',\n color: 'action.text.initial',\n paddingInlineEnd: '0',\n})\n"],"mappings":";;;;;AACA,SAAS,aAAa;AAEtB,SAAS,KAAK,UAAU;AACxB,SAAS,YAAY,WAAW;AAyC5B,SAyBM,KAzBN;AARG,SAAS,IAAI,OAAiD;AACnE,QAAM,EAAE,OAAO,WAAW,UAAU,SAAS,OAAO,GAAG,YAAY,IAAI;AACvE,QAAM,UAAU,OAAO,WAAW;AAClC,QAAM,aAAa,QAAQ,OAAO;AAClC,QAAM,QAAQ,aAAa,SAAS;AACpC,QAAM,iBAAiB,aAAa,cAAc;AAElD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,IAAI;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD;AAAA,MACF;AAAA,MAEC;AAAA,cAAM;AAAA,QAEP,oBAAC,QAAK,MAAM,YACV;AAAA,UAAC;AAAA;AAAA,YACC,cAAW;AAAA,YACX,WAAW,WAAW;AAAA,cACpB,SAAS;AAAA,cACT,OAAO;AAAA,cACP,MAAM;AAAA,YACR,CAAC;AAAA,YACD;AAAA,YAEA,8BAAC,SAAM;AAAA;AAAA,QACT,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAM,cAAc,IAAI;AAAA,EACtB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,kBAAkB;AACpB,CAAC;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFeatureFlags
|
|
3
|
+
} from "./chunk-JDRWQFCE.js";
|
|
4
|
+
import {
|
|
5
|
+
Show
|
|
6
|
+
} from "./chunk-4O4QFF4S.js";
|
|
7
|
+
|
|
8
|
+
// src/components/FeatureFlag.tsx
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
function FeatureFlag(props) {
|
|
11
|
+
const showContent = useFeatureFlags(props.flag);
|
|
12
|
+
return /* @__PURE__ */ jsx(Show, { when: showContent, children: props.children });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
FeatureFlag
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=chunk-ZVNBWU4J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/FeatureFlag.tsx"],"sourcesContent":["'use client'\n\nimport type { PropsWithChildren } from 'react'\nimport { useFeatureFlags } from '../context/feature-flags'\nimport { Show } from './Show'\n\nexport interface FeatureFlagProps {\n flag: string\n}\n\nexport function FeatureFlag(props: PropsWithChildren<FeatureFlagProps>) {\n const showContent = useFeatureFlags(props.flag)\n return <Show when={showContent}>{props.children}</Show>\n}\n"],"mappings":";;;;;;;;AAYS;AAFF,SAAS,YAAY,OAA4C;AACtE,QAAM,cAAc,gBAAgB,MAAM,IAAI;AAC9C,SAAO,oBAAC,QAAK,MAAM,aAAc,gBAAM,UAAS;AAClD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/build/modern/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Textarea
|
|
3
|
+
} from "./chunk-TCO46FK7.js";
|
|
4
|
+
import {
|
|
5
|
+
Toggle
|
|
6
|
+
} from "./chunk-734PGVLT.js";
|
|
7
|
+
import {
|
|
8
|
+
NavMenuTrigger
|
|
9
|
+
} from "./chunk-RPZAPUCF.js";
|
|
10
|
+
import {
|
|
11
|
+
Portal
|
|
12
|
+
} from "./chunk-4CAT3FHV.js";
|
|
1
13
|
import {
|
|
2
14
|
Radio
|
|
3
15
|
} from "./chunk-WE3JNSNO.js";
|
|
@@ -12,16 +24,17 @@ import {
|
|
|
12
24
|
} from "./chunk-67S42J4B.js";
|
|
13
25
|
import {
|
|
14
26
|
Tag
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import {
|
|
17
|
-
Textarea
|
|
18
|
-
} from "./chunk-TCO46FK7.js";
|
|
19
|
-
import {
|
|
20
|
-
Toggle
|
|
21
|
-
} from "./chunk-734PGVLT.js";
|
|
27
|
+
} from "./chunk-Z6IWNVPN.js";
|
|
22
28
|
import {
|
|
23
29
|
Button
|
|
24
30
|
} from "./chunk-2ATICEW3.js";
|
|
31
|
+
import {
|
|
32
|
+
FeatureFlag
|
|
33
|
+
} from "./chunk-ZVNBWU4J.js";
|
|
34
|
+
import {
|
|
35
|
+
FeatureFlags,
|
|
36
|
+
useFeatureFlags
|
|
37
|
+
} from "./chunk-JDRWQFCE.js";
|
|
25
38
|
import {
|
|
26
39
|
FieldMessage
|
|
27
40
|
} from "./chunk-VGHVH2T3.js";
|
|
@@ -33,7 +46,7 @@ import {
|
|
|
33
46
|
} from "./chunk-X4YQ27D5.js";
|
|
34
47
|
import {
|
|
35
48
|
Label
|
|
36
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-JJGZRBIR.js";
|
|
37
50
|
import {
|
|
38
51
|
Field,
|
|
39
52
|
useFieldContext
|
|
@@ -44,10 +57,7 @@ import {
|
|
|
44
57
|
import {
|
|
45
58
|
NavMenuList,
|
|
46
59
|
getPosition
|
|
47
|
-
} from "./chunk-
|
|
48
|
-
import {
|
|
49
|
-
NavMenuTrigger
|
|
50
|
-
} from "./chunk-RPZAPUCF.js";
|
|
60
|
+
} from "./chunk-PMCYXRAH.js";
|
|
51
61
|
import {
|
|
52
62
|
NavMenu,
|
|
53
63
|
useNavMenuContext
|
|
@@ -85,6 +95,8 @@ import {
|
|
|
85
95
|
export {
|
|
86
96
|
$cerberusIcons,
|
|
87
97
|
Button,
|
|
98
|
+
FeatureFlag,
|
|
99
|
+
FeatureFlags,
|
|
88
100
|
Field,
|
|
89
101
|
FieldMessage,
|
|
90
102
|
IconButton,
|
|
@@ -95,6 +107,7 @@ export {
|
|
|
95
107
|
NavMenuLink,
|
|
96
108
|
NavMenuList,
|
|
97
109
|
NavMenuTrigger,
|
|
110
|
+
Portal,
|
|
98
111
|
Radio,
|
|
99
112
|
Show,
|
|
100
113
|
THEME_KEY,
|
|
@@ -110,6 +123,7 @@ export {
|
|
|
110
123
|
createNavTriggerProps,
|
|
111
124
|
defineIcons,
|
|
112
125
|
getPosition,
|
|
126
|
+
useFeatureFlags,
|
|
113
127
|
useFieldContext,
|
|
114
128
|
useNavMenuContext,
|
|
115
129
|
useTabsContext,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerberus-design/react",
|
|
3
|
-
"version": "0.6.1-next-
|
|
3
|
+
"version": "0.6.1-next-f9a7124",
|
|
4
4
|
"description": "The Cerberus Design React component library.",
|
|
5
5
|
"browserslist": "> 0.25%, not dead",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@microsoft/api-extractor": "^7.46.2",
|
|
20
20
|
"@types/react": "^18",
|
|
21
|
+
"@types/react-dom": "^18",
|
|
21
22
|
"react": "^18",
|
|
22
23
|
"react-dom": "^18",
|
|
23
24
|
"tsup": "^8.1.0",
|
|
24
25
|
"@cerberus-design/configs": "0.0.0",
|
|
25
|
-
"@cerberus-design/styled-system": "0.6.1-next-
|
|
26
|
+
"@cerberus-design/styled-system": "0.6.1-next-f9a7124"
|
|
26
27
|
},
|
|
27
28
|
"publishConfig": {
|
|
28
29
|
"access": "public"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import type { PropsWithChildren } from 'react'
|
|
4
|
+
import { useFeatureFlags } from '../context/feature-flags'
|
|
5
|
+
import { Show } from './Show'
|
|
6
|
+
|
|
7
|
+
export interface FeatureFlagProps {
|
|
8
|
+
flag: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function FeatureFlag(props: PropsWithChildren<FeatureFlagProps>) {
|
|
12
|
+
const showContent = useFeatureFlags(props.flag)
|
|
13
|
+
return <Show when={showContent}>{props.children}</Show>
|
|
14
|
+
}
|
package/src/components/Label.tsx
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PropsWithChildren } from 'react'
|
|
2
|
+
import { createPortal } from 'react-dom'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This module is the Portal component.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface PortalProps {
|
|
10
|
+
container?: Element | DocumentFragment
|
|
11
|
+
key?: null | string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The Portal component is used to render children into a DOM node that exists outside the DOM hierarchy of the parent component.
|
|
16
|
+
* @param container - The props for the Portal component.
|
|
17
|
+
* @returns ReactPortal
|
|
18
|
+
*/
|
|
19
|
+
export function Portal(props: PropsWithChildren<PortalProps>) {
|
|
20
|
+
const container = props.container || document.body
|
|
21
|
+
return createPortal(props.children, container, props.key)
|
|
22
|
+
}
|
package/src/components/Tag.tsx
CHANGED
|
@@ -37,7 +37,7 @@ export type TagProps = StaticTagProps | ClickableTagProps
|
|
|
37
37
|
*/
|
|
38
38
|
export function Tag(props: PropsWithChildren<TagProps>): JSX.Element {
|
|
39
39
|
const { shape: initShape, gradient, onClick, usage, ...nativeProps } = props
|
|
40
|
-
const palette = props?.palette ?? '
|
|
40
|
+
const palette = props?.palette ?? 'page'
|
|
41
41
|
const isClosable = Boolean(onClick)
|
|
42
42
|
const shape = isClosable ? 'pill' : initShape
|
|
43
43
|
const closableStyles = isClosable ? closableCss : ''
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, type PropsWithChildren } from 'react'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This module provides a context and hook for feature flags.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface FeatureFlagValue {
|
|
11
|
+
[key: string]: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const FeatureFlagContext = createContext<FeatureFlagValue | null>(null)
|
|
15
|
+
|
|
16
|
+
export interface FeatureFlagProviderProps {
|
|
17
|
+
flags: FeatureFlagValue
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Provides feature flags to the application.
|
|
22
|
+
* @param flags - The flags data for the provider.
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // This should be a JSON file or a server response.
|
|
26
|
+
* const flags = {
|
|
27
|
+
* featureOne: true,
|
|
28
|
+
* featureTwo: false
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* // Wrap the Provider around the root of your application.
|
|
32
|
+
* <FeatureFlagProvider flags={flags}>
|
|
33
|
+
* <FeatureFlag flag="featureOne">
|
|
34
|
+
* This is visible.
|
|
35
|
+
* </FeatureFlag>
|
|
36
|
+
* <FeatureFlag flag="featureTwo">
|
|
37
|
+
* This is hidden.
|
|
38
|
+
* </FeatureFlag>
|
|
39
|
+
* </FeatureFlagProvider>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function FeatureFlags(
|
|
43
|
+
props: PropsWithChildren<FeatureFlagProviderProps>,
|
|
44
|
+
) {
|
|
45
|
+
return (
|
|
46
|
+
<FeatureFlagContext.Provider value={props.flags}>
|
|
47
|
+
{props.children}
|
|
48
|
+
</FeatureFlagContext.Provider>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function useFeatureFlags(key: string): boolean {
|
|
53
|
+
const context = useContext(FeatureFlagContext)
|
|
54
|
+
if (context === null) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
'useFeatureFlag must be used within a FeatureFlags Provider',
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
return context[key] ?? false
|
|
60
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,12 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
export * from './components/Button'
|
|
9
9
|
export * from './components/FieldMessage'
|
|
10
|
+
export * from './components/FeatureFlag'
|
|
10
11
|
export * from './components/IconButton'
|
|
11
12
|
export * from './components/Input'
|
|
12
13
|
export * from './components/Label'
|
|
13
14
|
export * from './components/NavMenuTrigger'
|
|
14
15
|
export * from './components/NavMenuList'
|
|
15
16
|
export * from './components/NavMenuLink'
|
|
17
|
+
export * from './components/Portal'
|
|
16
18
|
export * from './components/Radio'
|
|
17
19
|
export * from './components/Tab'
|
|
18
20
|
export * from './components/TabList'
|
|
@@ -24,6 +26,7 @@ export * from './components/Show'
|
|
|
24
26
|
|
|
25
27
|
// context
|
|
26
28
|
|
|
29
|
+
export * from './context/feature-flags'
|
|
27
30
|
export * from './context/field'
|
|
28
31
|
export * from './context/navMenu'
|
|
29
32
|
export * from './context/tabs'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Tag.tsx"],"sourcesContent":["import type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { Close } from '@cerberus/icons'\nimport { Show } from './Show'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { iconButton, tag } from '@cerberus/styled-system/recipes'\nimport type { RecipeVariantProps } from '@cerberus/styled-system/types'\n\n/**\n * This module contains the tag component.\n * @module\n */\n\nexport type TagRecipeProps = RecipeVariantProps<typeof tag>\n\nexport type StaticTagProps = HTMLAttributes<HTMLSpanElement> &\n TagRecipeProps & {\n onClick?: never\n }\n\nexport type ClickableTagProps = HTMLAttributes<HTMLSpanElement> & {\n gradient?: never\n palette?: never\n onClick: () => void\n shape: 'pill'\n usage: 'filled'\n}\n\nexport type TagProps = StaticTagProps | ClickableTagProps\n\n/**\n * The Tag component is used to display a meta descriptions.\n * @definition [Tag docs](https://cerberus.digitalu.design/react/tags)\n * @example\n * ```tsx\n * <Tag>Tag</Tag>\n * ```\n */\nexport function Tag(props: PropsWithChildren<TagProps>): JSX.Element {\n const { shape: initShape, gradient, onClick, usage, ...nativeProps } = props\n const palette = props?.palette ?? 'neutral'\n const isClosable = Boolean(onClick)\n const shape = isClosable ? 'pill' : initShape\n const closableStyles = isClosable ? closableCss : ''\n\n return (\n <span\n {...nativeProps}\n className={cx(\n nativeProps.className,\n tag({\n gradient,\n palette,\n shape,\n usage,\n }),\n closableStyles,\n )}\n >\n {props.children}\n\n <Show when={isClosable}>\n <button\n aria-label=\"Close\"\n className={iconButton({\n palette: 'action',\n usage: 'filled',\n size: 'sm',\n })}\n onClick={onClick}\n >\n <Close />\n </button>\n </Show>\n </span>\n )\n}\n\nconst closableCss = css({\n bgColor: 'action.bg.active',\n color: 'action.text.initial',\n paddingInlineEnd: '0',\n})\n"],"mappings":";;;;;AACA,SAAS,aAAa;AAEtB,SAAS,KAAK,UAAU;AACxB,SAAS,YAAY,WAAW;AAyC5B,SAyBM,KAzBN;AARG,SAAS,IAAI,OAAiD;AACnE,QAAM,EAAE,OAAO,WAAW,UAAU,SAAS,OAAO,GAAG,YAAY,IAAI;AACvE,QAAM,WAAU,+BAAO,YAAW;AAClC,QAAM,aAAa,QAAQ,OAAO;AAClC,QAAM,QAAQ,aAAa,SAAS;AACpC,QAAM,iBAAiB,aAAa,cAAc;AAElD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,IAAI;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD;AAAA,MACF;AAAA,MAEC;AAAA,cAAM;AAAA,QAEP,oBAAC,QAAK,MAAM,YACV;AAAA,UAAC;AAAA;AAAA,YACC,cAAW;AAAA,YACX,WAAW,WAAW;AAAA,cACpB,SAAS;AAAA,cACT,OAAO;AAAA,cACP,MAAM;AAAA,YACR,CAAC;AAAA,YACD;AAAA,YAEA,8BAAC,SAAM;AAAA;AAAA,QACT,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAM,cAAc,IAAI;AAAA,EACtB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,kBAAkB;AACpB,CAAC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/NavMenuList.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo, type HTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { useNavMenuContext } from '../context/navMenu'\nimport type { Positions } from '../types'\nimport { Show } from './Show'\n\ninterface GetPositionResult {\n left: string\n right: string\n top: string\n bottom: string\n}\n\nexport function getPosition(position: Positions): GetPositionResult {\n const defaultPositions = {\n left: 'auto',\n right: 'auto',\n top: 'auto',\n bottom: 'auto',\n }\n switch (position) {\n case 'right':\n return { ...defaultPositions, top: '0%', left: '105%' }\n case 'left':\n return { ...defaultPositions, top: '0%', right: '105%' }\n case 'bottom':\n return { ...defaultPositions, top: '110%' }\n case 'top':\n return { ...defaultPositions, bottom: '110%' }\n default:\n return defaultPositions\n }\n}\n\nconst navListStyles = vstack({\n alignItems: 'flex-start',\n bgColor: 'neutral.surface.100',\n boxShadow: 'lg',\n gap: '2',\n opacity: '0',\n p: '4',\n position: 'absolute',\n rounded: 'md',\n zIndex: 'dropdown',\n _motionSafe: {\n animationName: 'zoomIn',\n animationDelay: '100ms',\n animationDuration: '150ms',\n animationFillMode: 'both',\n animationTimingFunction: 'ease-in-out',\n },\n _positionBottom: {\n transformOrigin: 'top left',\n },\n _positionTop: {\n transformOrigin: 'bottom left',\n },\n _positionLeft: {\n transformOrigin: 'top right',\n },\n _positionRight: {\n transformOrigin: 'top left',\n },\n})\n\nexport interface NavMenuListProps extends HTMLAttributes<HTMLUListElement> {\n id: string\n position?: Positions\n}\n\n/**\n * A component that allows the user to display a menu of navigation links.\n * @definition [Disclosure Nav](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/)\n * @definition [NavMenu Docs](https://cerberus.digitalu.design/react/nav-menu)\n *\n * @example\n * ```tsx\n * <NavMenuList id=\"nav-menu-list\" position=\"bottom\">\n * <NavMenuLink href=\"/home\">Home</NavMenuLink>\n * <NavMenuLink href=\"/about\">About</NavMenuLink>\n * </NavMenuList>\n * ```\n **/\nexport function NavMenuList(props: NavMenuListProps): JSX.Element {\n const { position, ...nativeProps } = props\n const { menuRef, expanded } = useNavMenuContext()\n const locationStyles = useMemo(\n () => getPosition(position ?? 'bottom'),\n [position],\n )\n\n return (\n <Show when={expanded}>\n <ul\n {...nativeProps}\n data-position={position ?? 'bottom'}\n className={cx(nativeProps.className, navListStyles)}\n ref={menuRef}\n style={locationStyles}\n />\n </Show>\n )\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,eAAoC;AAC7C,SAAS,UAAU;AACnB,SAAS,cAAc;AA4FjB;AAhFC,SAAS,YAAY,UAAwC;AAClE,QAAM,mBAAmB;AAAA,IACvB,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AACA,UAAQ,UAAU;AAAA,IAChB,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,MAAM,OAAO;AAAA,IACxD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,OAAO,OAAO;AAAA,IACzD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,OAAO;AAAA,IAC5C,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,QAAQ,OAAO;AAAA,IAC/C;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,gBAAgB,OAAO;AAAA,EAC3B,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAK;AAAA,EACL,SAAS;AAAA,EACT,GAAG;AAAA,EACH,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,aAAa;AAAA,IACX,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,EAC3B;AAAA,EACA,iBAAiB;AAAA,IACf,iBAAiB;AAAA,EACnB;AAAA,EACA,cAAc;AAAA,IACZ,iBAAiB;AAAA,EACnB;AAAA,EACA,eAAe;AAAA,IACb,iBAAiB;AAAA,EACnB;AAAA,EACA,gBAAgB;AAAA,IACd,iBAAiB;AAAA,EACnB;AACF,CAAC;AAoBM,SAAS,YAAY,OAAsC;AAChE,QAAM,EAAE,UAAU,GAAG,YAAY,IAAI;AACrC,QAAM,EAAE,SAAS,SAAS,IAAI,kBAAkB;AAChD,QAAM,iBAAiB;AAAA,IACrB,MAAM,YAAY,YAAY,QAAQ;AAAA,IACtC,CAAC,QAAQ;AAAA,EACX;AAEA,SACE,oBAAC,QAAK,MAAM,UACV;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,iBAAe,YAAY;AAAA,MAC3B,WAAW,GAAG,YAAY,WAAW,aAAa;AAAA,MAClD,KAAK;AAAA,MACL,OAAO;AAAA;AAAA,EACT,GACF;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/NavMenuList.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo, type HTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { useNavMenuContext } from '../context/navMenu'\nimport type { Positions } from '../types'\nimport { Show } from './Show'\n\ninterface GetPositionResult {\n left: string\n right: string\n top: string\n bottom: string\n}\n\nexport function getPosition(position: Positions): GetPositionResult {\n const defaultPositions = {\n left: 'auto',\n right: 'auto',\n top: 'auto',\n bottom: 'auto',\n }\n switch (position) {\n case 'right':\n return { ...defaultPositions, top: '0%', left: '105%' }\n case 'left':\n return { ...defaultPositions, top: '0%', right: '105%' }\n case 'bottom':\n return { ...defaultPositions, top: '110%' }\n case 'top':\n return { ...defaultPositions, bottom: '110%' }\n default:\n return defaultPositions\n }\n}\n\nconst navListStyles = vstack({\n alignItems: 'flex-start',\n bgColor: 'neutral.surface.100',\n boxShadow: 'lg',\n gap: '2',\n opacity: '0',\n p: '4',\n position: 'absolute',\n rounded: 'md',\n zIndex: 'dropdown',\n _motionSafe: {\n animationName: 'zoomIn',\n animationDelay: '100ms',\n animationDuration: '150ms',\n animationFillMode: 'both',\n animationTimingFunction: 'ease-in-out',\n },\n _positionBottom: {\n transformOrigin: 'top left',\n },\n _positionTop: {\n transformOrigin: 'bottom left',\n },\n _positionLeft: {\n transformOrigin: 'top right',\n },\n _positionRight: {\n transformOrigin: 'top left',\n },\n})\n\nexport interface NavMenuListProps extends HTMLAttributes<HTMLUListElement> {\n id: string\n position?: Positions\n}\n\n/**\n * A component that allows the user to display a menu of navigation links.\n * @definition [Disclosure Nav](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/)\n * @definition [NavMenu Docs](https://cerberus.digitalu.design/react/nav-menu)\n *\n * @example\n * ```tsx\n * <NavMenuList id=\"nav-menu-list\" position=\"bottom\">\n * <NavMenuLink href=\"/home\">Home</NavMenuLink>\n * <NavMenuLink href=\"/about\">About</NavMenuLink>\n * </NavMenuList>\n * ```\n **/\nexport function NavMenuList(props: NavMenuListProps): JSX.Element {\n const { position, ...nativeProps } = props\n const { menuRef, expanded } = useNavMenuContext()\n const locationStyles = useMemo(\n () => getPosition(position ?? 'bottom'),\n [position],\n )\n\n return (\n <Show when={expanded}>\n <ul\n {...nativeProps}\n data-position={position ?? 'bottom'}\n className={cx(nativeProps.className, navListStyles)}\n ref={menuRef}\n style={locationStyles}\n />\n </Show>\n )\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,eAAoC;AAC7C,SAAS,UAAU;AACnB,SAAS,cAAc;AA4FjB;AAhFC,SAAS,YAAY,UAAwC;AAClE,QAAM,mBAAmB;AAAA,IACvB,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AACA,UAAQ,UAAU;AAAA,IAChB,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,MAAM,OAAO;AAAA,IACxD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,OAAO,OAAO;AAAA,IACzD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,OAAO;AAAA,IAC5C,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,QAAQ,OAAO;AAAA,IAC/C;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,gBAAgB,OAAO;AAAA,EAC3B,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAK;AAAA,EACL,SAAS;AAAA,EACT,GAAG;AAAA,EACH,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,aAAa;AAAA,IACX,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,EAC3B;AAAA,EACA,iBAAiB;AAAA,IACf,iBAAiB;AAAA,EACnB;AAAA,EACA,cAAc;AAAA,IACZ,iBAAiB;AAAA,EACnB;AAAA,EACA,eAAe;AAAA,IACb,iBAAiB;AAAA,EACnB;AAAA,EACA,gBAAgB;AAAA,IACd,iBAAiB;AAAA,EACnB;AACF,CAAC;AAoBM,SAAS,YAAY,OAAsC;AAChE,QAAM,EAAE,UAAU,GAAG,YAAY,IAAI;AACrC,QAAM,EAAE,SAAS,SAAS,IAAI,kBAAkB;AAChD,QAAM,iBAAiB;AAAA,IACrB,MAAM,YAAY,YAAY,QAAQ;AAAA,IACtC,CAAC,QAAQ;AAAA,EACX;AAEA,SACE,oBAAC,QAAK,MAAM,UACV;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,iBAAe,YAAY;AAAA,MAC3B,WAAW,GAAG,YAAY,WAAW,aAAa;AAAA,MAClD,KAAK;AAAA,MACL,OAAO;AAAA;AAAA,EACT,GACF;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Tag.tsx"],"sourcesContent":["import type { HTMLAttributes, PropsWithChildren } from 'react'\nimport { Close } from '@cerberus/icons'\nimport { Show } from './Show'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { iconButton, tag } from '@cerberus/styled-system/recipes'\nimport type { RecipeVariantProps } from '@cerberus/styled-system/types'\n\n/**\n * This module contains the tag component.\n * @module\n */\n\nexport type TagRecipeProps = RecipeVariantProps<typeof tag>\n\nexport type StaticTagProps = HTMLAttributes<HTMLSpanElement> &\n TagRecipeProps & {\n onClick?: never\n }\n\nexport type ClickableTagProps = HTMLAttributes<HTMLSpanElement> & {\n gradient?: never\n palette?: never\n onClick: () => void\n shape: 'pill'\n usage: 'filled'\n}\n\nexport type TagProps = StaticTagProps | ClickableTagProps\n\n/**\n * The Tag component is used to display a meta descriptions.\n * @definition [Tag docs](https://cerberus.digitalu.design/react/tags)\n * @example\n * ```tsx\n * <Tag>Tag</Tag>\n * ```\n */\nexport function Tag(props: PropsWithChildren<TagProps>): JSX.Element {\n const { shape: initShape, gradient, onClick, usage, ...nativeProps } = props\n const palette = props?.palette ?? 'neutral'\n const isClosable = Boolean(onClick)\n const shape = isClosable ? 'pill' : initShape\n const closableStyles = isClosable ? closableCss : ''\n\n return (\n <span\n {...nativeProps}\n className={cx(\n nativeProps.className,\n tag({\n gradient,\n palette,\n shape,\n usage,\n }),\n closableStyles,\n )}\n >\n {props.children}\n\n <Show when={isClosable}>\n <button\n aria-label=\"Close\"\n className={iconButton({\n palette: 'action',\n usage: 'filled',\n size: 'sm',\n })}\n onClick={onClick}\n >\n <Close />\n </button>\n </Show>\n </span>\n )\n}\n\nconst closableCss = css({\n bgColor: 'action.bg.active',\n color: 'action.text.initial',\n paddingInlineEnd: '0',\n})\n"],"mappings":";;;;;AACA,SAAS,aAAa;AAEtB,SAAS,KAAK,UAAU;AACxB,SAAS,YAAY,WAAW;AAyC5B,SAyBM,KAzBN;AARG,SAAS,IAAI,OAAiD;AACnE,QAAM,EAAE,OAAO,WAAW,UAAU,SAAS,OAAO,GAAG,YAAY,IAAI;AACvE,QAAM,UAAU,OAAO,WAAW;AAClC,QAAM,aAAa,QAAQ,OAAO;AAClC,QAAM,QAAQ,aAAa,SAAS;AACpC,QAAM,iBAAiB,aAAa,cAAc;AAElD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,IAAI;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD;AAAA,MACF;AAAA,MAEC;AAAA,cAAM;AAAA,QAEP,oBAAC,QAAK,MAAM,YACV;AAAA,UAAC;AAAA;AAAA,YACC,cAAW;AAAA,YACX,WAAW,WAAW;AAAA,cACpB,SAAS;AAAA,cACT,OAAO;AAAA,cACP,MAAM;AAAA,YACR,CAAC;AAAA,YACD;AAAA,YAEA,8BAAC,SAAM;AAAA;AAAA,QACT,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAM,cAAc,IAAI;AAAA,EACtB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,kBAAkB;AACpB,CAAC;","names":[]}
|