@cocso-ui/react 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/accordion/Accordion.d.ts +15 -0
- package/dist/cjs/accordion/Accordion.js +71 -0
- package/dist/cjs/accordion/Accordion.module.css.js +9 -0
- package/dist/cjs/button/Button.d.ts +23 -0
- package/dist/cjs/button/Button.js +115 -0
- package/dist/cjs/button/Button.module.css.js +9 -0
- package/dist/cjs/checkbox/Checkbox.d.ts +18 -0
- package/dist/cjs/checkbox/Checkbox.js +115 -0
- package/dist/cjs/checkbox/Checkbox.module.css.js +9 -0
- package/dist/cjs/dropdown/Dropdown.d.ts +11 -0
- package/dist/cjs/dropdown/Dropdown.js +55 -0
- package/dist/cjs/dropdown/Dropdown.module.css.js +9 -0
- package/dist/cjs/index.d.ts +19 -0
- package/dist/cjs/index.js +53 -0
- package/dist/cjs/link/Link.d.ts +16 -0
- package/dist/cjs/link/Link.js +35 -0
- package/dist/cjs/link/Link.module.css.js +9 -0
- package/dist/cjs/modal/Modal.d.ts +12 -0
- package/dist/cjs/modal/Modal.js +103 -0
- package/dist/cjs/modal/Modal.module.css.js +9 -0
- package/dist/cjs/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js +28 -0
- package/dist/cjs/one-time-password-field/OneTimePasswordField.d.ts +8 -0
- package/dist/cjs/one-time-password-field/OneTimePasswordField.js +52 -0
- package/dist/cjs/one-time-password-field/OneTimePasswordField.module.css.js +9 -0
- package/dist/cjs/pagination/Pagination.d.ts +13 -0
- package/dist/cjs/pagination/Pagination.js +83 -0
- package/dist/cjs/pagination/Pagination.module.css.js +9 -0
- package/dist/cjs/popover/Popover.d.ts +10 -0
- package/dist/cjs/popover/Popover.js +44 -0
- package/dist/cjs/popover/Popover.module.css.js +9 -0
- package/dist/cjs/select/Select.d.ts +12 -0
- package/dist/cjs/select/Select.js +84 -0
- package/dist/cjs/select/Select.module.css.js +9 -0
- package/dist/cjs/spinner/Spinner.d.ts +14 -0
- package/dist/cjs/spinner/Spinner.js +40 -0
- package/dist/cjs/spinner/Spinner.module.css.js +9 -0
- package/dist/cjs/stock-quantity-status/StockQuantityStatus.d.ts +12 -0
- package/dist/cjs/stock-quantity-status/StockQuantityStatus.js +105 -0
- package/dist/cjs/stock-quantity-status/StockQuantityStatus.module.css.js +9 -0
- package/dist/cjs/switch/Switch.d.ts +16 -0
- package/dist/cjs/switch/Switch.js +89 -0
- package/dist/cjs/switch/Switch.module.css.js +9 -0
- package/dist/cjs/tab/Tab.d.ts +10 -0
- package/dist/cjs/tab/Tab.js +64 -0
- package/dist/{token → cjs/token}/color.d.ts +3 -1
- package/dist/cjs/token/color.js +84 -0
- package/dist/{token → cjs/token}/spacing.d.ts +3 -1
- package/dist/cjs/token/spacing.js +29 -0
- package/dist/{token → cjs/token}/typography.d.ts +10 -7
- package/dist/cjs/token/typography.js +50 -0
- package/dist/cjs/typography/Typography.d.ts +33 -0
- package/dist/cjs/typography/Typography.js +90 -0
- package/dist/cjs/typography/Typography.module.css.js +9 -0
- package/dist/esm/accordion/Accordion.d.mts +15 -0
- package/dist/esm/accordion/Accordion.mjs +50 -0
- package/dist/esm/accordion/Accordion.module.css.mjs +7 -0
- package/dist/esm/button/Button.d.mts +23 -0
- package/dist/esm/button/Button.mjs +113 -0
- package/dist/esm/button/Button.module.css.mjs +7 -0
- package/dist/esm/checkbox/Checkbox.d.mts +18 -0
- package/dist/esm/checkbox/Checkbox.mjs +94 -0
- package/dist/esm/checkbox/Checkbox.module.css.mjs +7 -0
- package/dist/esm/dropdown/Dropdown.d.mts +11 -0
- package/dist/esm/dropdown/Dropdown.mjs +34 -0
- package/dist/esm/dropdown/Dropdown.module.css.mjs +7 -0
- package/dist/esm/index.d.mts +19 -0
- package/dist/esm/index.mjs +19 -0
- package/dist/esm/link/Link.d.mts +16 -0
- package/dist/esm/link/Link.mjs +33 -0
- package/dist/esm/link/Link.module.css.mjs +7 -0
- package/dist/esm/modal/Modal.d.mts +12 -0
- package/dist/esm/modal/Modal.mjs +82 -0
- package/dist/esm/modal/Modal.module.css.mjs +7 -0
- package/dist/esm/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs +26 -0
- package/dist/esm/one-time-password-field/OneTimePasswordField.d.mts +8 -0
- package/dist/esm/one-time-password-field/OneTimePasswordField.mjs +31 -0
- package/dist/esm/one-time-password-field/OneTimePasswordField.module.css.mjs +7 -0
- package/dist/esm/pagination/Pagination.d.mts +13 -0
- package/dist/esm/pagination/Pagination.mjs +81 -0
- package/dist/esm/pagination/Pagination.module.css.mjs +7 -0
- package/dist/esm/popover/Popover.d.mts +10 -0
- package/dist/esm/popover/Popover.mjs +23 -0
- package/dist/esm/popover/Popover.module.css.mjs +7 -0
- package/dist/esm/select/Select.d.mts +12 -0
- package/dist/esm/select/Select.mjs +82 -0
- package/dist/esm/select/Select.module.css.mjs +7 -0
- package/dist/esm/spinner/Spinner.d.mts +14 -0
- package/dist/esm/spinner/Spinner.mjs +38 -0
- package/dist/esm/spinner/Spinner.module.css.mjs +7 -0
- package/dist/esm/stock-quantity-status/StockQuantityStatus.d.mts +12 -0
- package/dist/esm/stock-quantity-status/StockQuantityStatus.mjs +102 -0
- package/dist/esm/stock-quantity-status/StockQuantityStatus.module.css.mjs +7 -0
- package/dist/esm/switch/Switch.d.mts +16 -0
- package/dist/esm/switch/Switch.mjs +68 -0
- package/dist/esm/switch/Switch.module.css.mjs +7 -0
- package/dist/esm/tab/Tab.d.mts +10 -0
- package/dist/esm/tab/Tab.mjs +43 -0
- package/dist/esm/token/color.d.mts +82 -0
- package/dist/esm/token/color.mjs +82 -0
- package/dist/esm/token/spacing.d.mts +27 -0
- package/dist/esm/token/spacing.mjs +27 -0
- package/dist/esm/token/typography.d.mts +47 -0
- package/dist/esm/token/typography.mjs +46 -0
- package/dist/esm/typography/Typography.d.mts +33 -0
- package/dist/esm/typography/Typography.mjs +88 -0
- package/dist/esm/typography/Typography.module.css.mjs +7 -0
- package/package.json +33 -26
- package/dist/accordion/Accordion.d.ts +0 -12
- package/dist/accordion/index.d.ts +0 -1
- package/dist/body/Body.d.ts +0 -11
- package/dist/body/index.d.ts +0 -1
- package/dist/button/Button.d.ts +0 -18
- package/dist/button/index.d.ts +0 -1
- package/dist/checkbox/Checkbox.d.ts +0 -13
- package/dist/checkbox/index.d.ts +0 -1
- package/dist/display/Display.d.ts +0 -11
- package/dist/display/index.d.ts +0 -1
- package/dist/dropdown/Dropdown.d.ts +0 -7
- package/dist/dropdown/index.d.ts +0 -1
- package/dist/heading/Heading.d.ts +0 -10
- package/dist/heading/index.d.ts +0 -1
- package/dist/index.cjs +0 -1
- package/dist/index.css +0 -1
- package/dist/index.d.ts +0 -20
- package/dist/index.js +0 -1
- package/dist/link/Link.d.ts +0 -11
- package/dist/link/index.d.ts +0 -1
- package/dist/modal/Modal.d.ts +0 -8
- package/dist/modal/index.d.ts +0 -1
- package/dist/one-time-password-field/OneTimePasswordField.d.ts +0 -4
- package/dist/one-time-password-field/index.d.ts +0 -1
- package/dist/pagination/Pagination.d.ts +0 -8
- package/dist/pagination/index.d.ts +0 -1
- package/dist/popover/Popover.d.ts +0 -6
- package/dist/popover/index.d.ts +0 -1
- package/dist/select/Select.d.ts +0 -8
- package/dist/select/index.d.ts +0 -1
- package/dist/spinner/Spinner.d.ts +0 -9
- package/dist/spinner/index.d.ts +0 -1
- package/dist/stock-quantity-status/StockQuantityStatus.d.ts +0 -7
- package/dist/stock-quantity-status/index.d.ts +0 -1
- package/dist/switch/Switch.d.ts +0 -11
- package/dist/switch/index.d.ts +0 -1
- package/dist/tab/Tab.d.ts +0 -6
- package/dist/tab/index.d.ts +0 -1
- package/dist/toast/index.d.ts +0 -1
- package/dist/token/index.d.ts +0 -3
- package/dist/typography/Typography.d.ts +0 -9
- package/dist/typography/index.d.ts +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var styleInject_es = require('../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js');
|
|
4
|
+
|
|
5
|
+
var css_248z = ".Typography-module_typography__45lnt{--cocso-typography-font-color:inherit;--cocso-typography-font-size:inherit;--cocso-typography-font-weight:inherit;--cocso-typography-line-height:inherit;color:var(--cocso-typography-font-color);font-size:var(--cocso-typography-font-size);font-weight:var(--cocso-typography-font-weight);line-height:var(--cocso-typography-line-height)}.Typography-module_typography__45lnt[aria-disabled=true]{cursor:not-allowed;opacity:.4}@media (min-width:768px){.Typography-module_typography__45lnt{font-size:var(--cocso-tablet-typography-font-size,var(--cocso-typography-font-size))}}@media (min-width:1024px){.Typography-module_typography__45lnt{font-size:var(--cocso-desktop-typography-font-size,var(--cocso-tablet-typography-font-size,var(--cocso-typography-font-size)))}}";
|
|
6
|
+
var styles = {"typography":"Typography-module_typography__45lnt"};
|
|
7
|
+
styleInject_es(css_248z);
|
|
8
|
+
|
|
9
|
+
module.exports = styles;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
4
|
+
|
|
5
|
+
interface TriggerProps extends ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> {
|
|
6
|
+
chevron?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const Accordion: react.ForwardRefExoticComponent<(AccordionPrimitive.AccordionSingleProps | AccordionPrimitive.AccordionMultipleProps) & react.RefAttributes<HTMLDivElement>> & {
|
|
9
|
+
Item: react.ForwardRefExoticComponent<Omit<Omit<AccordionPrimitive.AccordionItemProps & react.RefAttributes<HTMLDivElement>, "ref">, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
Header: react.ForwardRefExoticComponent<AccordionPrimitive.AccordionHeaderProps & react.RefAttributes<HTMLHeadingElement>>;
|
|
11
|
+
Trigger: react.ForwardRefExoticComponent<TriggerProps & react.RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
Content: react.ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionContentProps & react.RefAttributes<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { Accordion };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { KeyboardArrowDownIcon } from '@cocso-ui/react-icons';
|
|
2
|
+
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import styles from './Accordion.module.css.mjs';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
const AccordionItem = /*#__PURE__*/forwardRef(({
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}, ref) => {
|
|
12
|
+
return /*#__PURE__*/jsx(AccordionPrimitive.Item, {
|
|
13
|
+
ref: ref,
|
|
14
|
+
className: clsx(styles.item, className),
|
|
15
|
+
...props
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
const AccordionTrigger = /*#__PURE__*/forwardRef(({
|
|
19
|
+
className,
|
|
20
|
+
children,
|
|
21
|
+
chevron = true,
|
|
22
|
+
...props
|
|
23
|
+
}, ref) => {
|
|
24
|
+
return /*#__PURE__*/jsxs(AccordionPrimitive.Trigger, {
|
|
25
|
+
ref: ref,
|
|
26
|
+
className: clsx(styles.trigger, className),
|
|
27
|
+
...props,
|
|
28
|
+
children: [children, chevron && /*#__PURE__*/jsx(KeyboardArrowDownIcon, {
|
|
29
|
+
className: styles.chevron
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
const AccordionContent = /*#__PURE__*/forwardRef(({
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}, ref) => {
|
|
37
|
+
return /*#__PURE__*/jsx(AccordionPrimitive.Content, {
|
|
38
|
+
ref: ref,
|
|
39
|
+
className: clsx(styles.content, className),
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
const Accordion = Object.assign(AccordionPrimitive.Root, {
|
|
44
|
+
Item: AccordionItem,
|
|
45
|
+
Header: AccordionPrimitive.Header,
|
|
46
|
+
Trigger: AccordionTrigger,
|
|
47
|
+
Content: AccordionContent
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export { Accordion };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".Accordion-module_content__V9Ftc,.Accordion-module_item__iE3dq{overflow:hidden}.Accordion-module_content__V9Ftc[data-state=open]{animation:Accordion-module_slide-down__88c3a .3s cubic-bezier(.87,0,.13,1)}.Accordion-module_content__V9Ftc[data-state=closed]{animation:Accordion-module_slide-up__hbYw7 .3s cubic-bezier(.87,0,.13,1)}.Accordion-module_trigger__6nu7o{cursor:pointer;display:flex;justify-content:space-between;width:100%}.Accordion-module_chevron__oFGVg{display:inline-block;height:var(--number-10);transition:transform .2s ease-in-out;width:var(--number-10)}.Accordion-module_trigger__6nu7o[data-state=closed]>.Accordion-module_chevron__oFGVg{transform:rotate(0deg)}.Accordion-module_trigger__6nu7o[data-state=open]>.Accordion-module_chevron__oFGVg{transform:rotate(180deg)}@keyframes Accordion-module_slide-up__hbYw7{0%{height:var(--radix-accordion-content-height)}to{height:0}}@keyframes Accordion-module_slide-down__88c3a{0%{height:0}to{height:var(--radix-accordion-content-height)}}";
|
|
4
|
+
var styles = {"item":"Accordion-module_item__iE3dq","content":"Accordion-module_content__V9Ftc","trigger":"Accordion-module_trigger__6nu7o","chevron":"Accordion-module_chevron__oFGVg"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { styles as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
+
import { FontWeight } from '../token/typography.mjs';
|
|
4
|
+
|
|
5
|
+
type ButtonSize = 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
|
6
|
+
type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'success' | 'error' | 'warning' | 'neutral';
|
|
7
|
+
type ButtonShape = 'square' | 'circle' | 'rounded';
|
|
8
|
+
interface ButtonProps extends Omit<ComponentPropsWithoutRef<'button'>, 'prefix'> {
|
|
9
|
+
asChild?: boolean;
|
|
10
|
+
size?: ButtonSize;
|
|
11
|
+
variant?: ButtonVariant;
|
|
12
|
+
weight?: FontWeight;
|
|
13
|
+
shape?: ButtonShape;
|
|
14
|
+
prefix?: ReactNode;
|
|
15
|
+
suffix?: ReactNode;
|
|
16
|
+
svgOnly?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
21
|
+
|
|
22
|
+
export { Button };
|
|
23
|
+
export type { ButtonProps, ButtonShape, ButtonSize, ButtonVariant };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { forwardRef, isValidElement, cloneElement } from 'react';
|
|
4
|
+
import { match } from 'ts-pattern';
|
|
5
|
+
import styles from './Button.module.css.mjs';
|
|
6
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
7
|
+
import { fontWeight } from '../token/typography.mjs';
|
|
8
|
+
import { Spinner } from '../spinner/Spinner.mjs';
|
|
9
|
+
import { colors } from '../token/color.mjs';
|
|
10
|
+
|
|
11
|
+
const Button = /*#__PURE__*/forwardRef(({
|
|
12
|
+
asChild,
|
|
13
|
+
className,
|
|
14
|
+
style: _style,
|
|
15
|
+
children,
|
|
16
|
+
size = 'md',
|
|
17
|
+
variant = 'primary',
|
|
18
|
+
weight = 'medium',
|
|
19
|
+
shape = 'square',
|
|
20
|
+
prefix,
|
|
21
|
+
suffix,
|
|
22
|
+
svgOnly = false,
|
|
23
|
+
disabled = false,
|
|
24
|
+
loading = false,
|
|
25
|
+
...props
|
|
26
|
+
}, ref) => {
|
|
27
|
+
const style = {
|
|
28
|
+
..._style,
|
|
29
|
+
...getSizeStyles(size),
|
|
30
|
+
'--cocso-button-font-color': getColor(variant),
|
|
31
|
+
'--cocso-button-font-weight': fontWeight[weight],
|
|
32
|
+
'--cocso-button-border': getBorder(variant),
|
|
33
|
+
'--cocso-button-border-radius': getBorderRadius(shape, size),
|
|
34
|
+
'--cocso-button-bg-color': getBackgroundColor(variant),
|
|
35
|
+
'--cocso-button-bg-color-hover': getBackgroundColorHover(variant),
|
|
36
|
+
'--cocso-button-bg-color-active': getBackgroundColorActive(variant)
|
|
37
|
+
};
|
|
38
|
+
const isDisabled = disabled || loading;
|
|
39
|
+
const cn = clsx(styles.button, isDisabled && styles.disabled, svgOnly && styles.svgOnly, className);
|
|
40
|
+
const renderButtonContent = ctx => /*#__PURE__*/jsxs(Fragment, {
|
|
41
|
+
children: [loading && /*#__PURE__*/jsx(Spinner, {
|
|
42
|
+
size: "sm",
|
|
43
|
+
color: "white"
|
|
44
|
+
}), prefix && /*#__PURE__*/jsx("span", {
|
|
45
|
+
className: styles.prefix,
|
|
46
|
+
children: prefix
|
|
47
|
+
}), /*#__PURE__*/jsx("span", {
|
|
48
|
+
className: styles.content,
|
|
49
|
+
children: ctx
|
|
50
|
+
}), suffix && /*#__PURE__*/jsx("span", {
|
|
51
|
+
className: styles.suffix,
|
|
52
|
+
children: suffix
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
if (asChild) {
|
|
56
|
+
if (! /*#__PURE__*/isValidElement(children)) {
|
|
57
|
+
throw new Error('Button: asChild requires a single React element as a child');
|
|
58
|
+
}
|
|
59
|
+
const target = children;
|
|
60
|
+
const ctx = target.props.children;
|
|
61
|
+
return /*#__PURE__*/cloneElement(target, {
|
|
62
|
+
ref,
|
|
63
|
+
...props,
|
|
64
|
+
...target.props,
|
|
65
|
+
className: clsx(cn, target.props.className),
|
|
66
|
+
style: {
|
|
67
|
+
...style,
|
|
68
|
+
...target.props.style
|
|
69
|
+
},
|
|
70
|
+
children: renderButtonContent(ctx)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return /*#__PURE__*/jsx(Primitive.button, {
|
|
74
|
+
ref: ref,
|
|
75
|
+
className: cn,
|
|
76
|
+
disabled: isDisabled,
|
|
77
|
+
style: style,
|
|
78
|
+
...props,
|
|
79
|
+
children: renderButtonContent(children)
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
const getSizeStyles = size => {
|
|
83
|
+
const height = match(size).with('xl', () => 56).with('lg', () => 48).with('md', () => 40).with('sm', () => 32).with('xs', () => 24).exhaustive();
|
|
84
|
+
const inlinePadding = match(size).with('xl', () => 16).with('lg', () => 14).with('md', () => 10).with('sm', () => 6).with('xs', () => 0).exhaustive();
|
|
85
|
+
const fontSize = match(size).with('xl', () => 16).with('lg', () => 16).with('xs', () => 12).otherwise(() => 14);
|
|
86
|
+
return {
|
|
87
|
+
'--cocso-button-height': `${height}px`,
|
|
88
|
+
'--cocso-button-padding-inline': `${inlinePadding}px`,
|
|
89
|
+
'--cocso-button-font-size': `${fontSize}px`
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
const getBorderRadius = (shape, size) => {
|
|
93
|
+
return match(shape).with('square', () => {
|
|
94
|
+
return match(size).with('xs', () => '4px').otherwise(() => '6px');
|
|
95
|
+
}).with('circle', () => '100%').with('rounded', () => '100px').exhaustive();
|
|
96
|
+
};
|
|
97
|
+
const getColor = variant => {
|
|
98
|
+
return match(variant).with('primary', 'success', 'error', 'neutral', () => colors.white).with('secondary', 'tertiary', 'warning', () => colors.neutral950).exhaustive();
|
|
99
|
+
};
|
|
100
|
+
const getBorder = variant => {
|
|
101
|
+
return match(variant).with('tertiary', () => `1px solid ${colors.neutral100}`).otherwise(() => 'none');
|
|
102
|
+
};
|
|
103
|
+
const getBackgroundColor = variant => {
|
|
104
|
+
return match(variant).with('primary', () => colors.primary500).with('secondary', () => colors.white).with('tertiary', () => colors.transparent).with('success', () => colors.success500).with('error', () => colors.danger500).with('warning', () => colors.warning300).with('neutral', () => colors.neutral950).exhaustive();
|
|
105
|
+
};
|
|
106
|
+
const getBackgroundColorHover = variant => {
|
|
107
|
+
return match(variant).with('primary', () => colors.primary600).with('secondary', () => colors.neutral50).with('tertiary', () => colors.neutral50).with('success', () => colors.success600).with('error', () => colors.danger600).with('warning', () => colors.warning400).with('neutral', () => colors.neutral800).exhaustive();
|
|
108
|
+
};
|
|
109
|
+
const getBackgroundColorActive = variant => {
|
|
110
|
+
return match(variant).with('primary', () => colors.primary700).with('secondary', () => colors.neutral100).with('tertiary', () => colors.neutral100).with('success', () => colors.success700).with('error', () => colors.danger700).with('warning', () => colors.warning500).with('neutral', () => colors.neutral700).exhaustive();
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export { Button };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".Button-module_button__eiKKZ{--cocso-button-height:inherit;--cocso-button-padding-inline:inherit;--cocso-button-font-color:inherit;--cocso-button-font-size:inherit;--cocso-button-font-weight:inherit;--cocso-button-border:inherit;--cocso-button-border-radius:inherit;--cocso-button-bg-color:inherit;align-items:center;background-color:var(--cocso-button-bg-color);border:var(--cocso-button-border);border-radius:var(--cocso-button-border-radius);color:var(--cocso-button-font-color);cursor:pointer;display:inline-flex;font-size:var(--cocso-button-font-size);font-weight:var(--cocso-button-font-weight);height:var(--cocso-button-height);justify-content:center;opacity:1;padding-inline:var(--cocso-button-padding-inline);position:relative;transform:translateZ(0);transition:background-color .15s ease-in-out}.Button-module_button__eiKKZ:not(.Button-module_disabled__M6r1w):hover{--cocso-button-bg-color-hover:inherit;background-color:var(--cocso-button-bg-color-hover)}.Button-module_button__eiKKZ:not(.Button-module_disabled__M6r1w):active{--cocso-button-bg-color-active:inherit;background-color:var(--cocso-button-bg-color-active)}.Button-module_content__SVjwi{padding:0 6px}.Button-module_prefix__d7ljt{margin-right:2px}.Button-module_prefix__d7ljt,.Button-module_suffix__9oysT{align-items:center;display:inline-flex;flex-shrink:0;justify-content:center;min-width:20px}.Button-module_suffix__9oysT{margin-left:2px}.Button-module_disabled__M6r1w{cursor:not-allowed;opacity:.4}.Button-module_svgOnly__8RcZ7{aspect-ratio:1/1;padding:0}";
|
|
4
|
+
var styles = {"button":"Button-module_button__eiKKZ","disabled":"Button-module_disabled__M6r1w","content":"Button-module_content__SVjwi","prefix":"Button-module_prefix__d7ljt","suffix":"Button-module_suffix__9oysT","svgOnly":"Button-module_svgOnly__8RcZ7"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { styles as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
4
|
+
|
|
5
|
+
type CheckboxSize = 'lg' | 'md' | 'sm';
|
|
6
|
+
type CheckboxStatus = 'on' | 'off' | 'intermediate';
|
|
7
|
+
interface CheckboxProps extends Omit<ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, 'checked' | 'onCheckedChange' | 'onChange'> {
|
|
8
|
+
id?: string;
|
|
9
|
+
size?: CheckboxSize;
|
|
10
|
+
status: CheckboxStatus;
|
|
11
|
+
onChange: (status: CheckboxStatus) => void;
|
|
12
|
+
label?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const Checkbox: react.ForwardRefExoticComponent<CheckboxProps & react.RefAttributes<HTMLButtonElement>>;
|
|
16
|
+
|
|
17
|
+
export { Checkbox };
|
|
18
|
+
export type { CheckboxProps, CheckboxSize, CheckboxStatus };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { CheckIcon } from '@cocso-ui/react-icons';
|
|
2
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { forwardRef, useId } from 'react';
|
|
5
|
+
import { match } from 'ts-pattern';
|
|
6
|
+
import styles from './Checkbox.module.css.mjs';
|
|
7
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
|
+
import { Typography } from '../typography/Typography.mjs';
|
|
9
|
+
import { spacing } from '../token/spacing.mjs';
|
|
10
|
+
import { colors } from '../token/color.mjs';
|
|
11
|
+
|
|
12
|
+
const Checkbox = /*#__PURE__*/forwardRef(({
|
|
13
|
+
id: _id,
|
|
14
|
+
className,
|
|
15
|
+
style: _style,
|
|
16
|
+
size = 'md',
|
|
17
|
+
status,
|
|
18
|
+
onChange,
|
|
19
|
+
label,
|
|
20
|
+
disabled,
|
|
21
|
+
...props
|
|
22
|
+
}, ref) => {
|
|
23
|
+
const generatedId = useId();
|
|
24
|
+
const id = _id ?? generatedId;
|
|
25
|
+
const handleCheckedChange = checked => {
|
|
26
|
+
if (!disabled) {
|
|
27
|
+
const nextStatus = match(checked).with(true, () => 'on').with('indeterminate', () => 'intermediate').with(false, () => 'off').exhaustive();
|
|
28
|
+
onChange(nextStatus);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const getCheckedState = () => {
|
|
32
|
+
return match(status).with('on', () => true).with('intermediate', () => 'indeterminate').with('off', () => false).exhaustive();
|
|
33
|
+
};
|
|
34
|
+
const style = {
|
|
35
|
+
..._style,
|
|
36
|
+
'--cocso-checkbox-size': getSize(size),
|
|
37
|
+
'--cocso-checkbox-color': colors.white,
|
|
38
|
+
'--cocso-checkbox-border-color': getBorderColor(status),
|
|
39
|
+
'--cocso-checkbox-bg-color': getBackgroundColor(status)
|
|
40
|
+
};
|
|
41
|
+
return /*#__PURE__*/jsxs("div", {
|
|
42
|
+
className: clsx(styles.wrapper, className),
|
|
43
|
+
style: style,
|
|
44
|
+
children: [/*#__PURE__*/jsxs(CheckboxPrimitive.Root, {
|
|
45
|
+
ref: ref,
|
|
46
|
+
id: id,
|
|
47
|
+
className: styles.checkbox,
|
|
48
|
+
checked: getCheckedState(),
|
|
49
|
+
onCheckedChange: handleCheckedChange,
|
|
50
|
+
disabled: disabled,
|
|
51
|
+
...props,
|
|
52
|
+
children: [/*#__PURE__*/jsx(CheckboxPrimitive.Indicator, {
|
|
53
|
+
className: styles.indicator,
|
|
54
|
+
style: {
|
|
55
|
+
opacity: status === 'on' ? 1 : 0
|
|
56
|
+
},
|
|
57
|
+
"aria-hidden": "true",
|
|
58
|
+
children: /*#__PURE__*/jsx(CheckIcon, {
|
|
59
|
+
size: 24
|
|
60
|
+
})
|
|
61
|
+
}), /*#__PURE__*/jsx("div", {
|
|
62
|
+
className: styles.indicator,
|
|
63
|
+
style: {
|
|
64
|
+
opacity: status === 'intermediate' ? 1 : 0
|
|
65
|
+
},
|
|
66
|
+
"aria-hidden": "true",
|
|
67
|
+
children: /*#__PURE__*/jsx(CheckIcon, {
|
|
68
|
+
size: 24
|
|
69
|
+
})
|
|
70
|
+
})]
|
|
71
|
+
}), label && /*#__PURE__*/jsx(Typography, {
|
|
72
|
+
type: "body",
|
|
73
|
+
className: styles.label,
|
|
74
|
+
size: size,
|
|
75
|
+
"aria-disabled": disabled,
|
|
76
|
+
asChild: true,
|
|
77
|
+
children: /*#__PURE__*/jsx("label", {
|
|
78
|
+
htmlFor: id,
|
|
79
|
+
children: label
|
|
80
|
+
})
|
|
81
|
+
})]
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
const getSize = size => {
|
|
85
|
+
return match(size).with('lg', () => spacing.s10).with('md', () => spacing.s9).with('sm', () => spacing.s8).exhaustive();
|
|
86
|
+
};
|
|
87
|
+
const getBorderColor = status => {
|
|
88
|
+
return match(status).with('on', () => colors.primary500).with('intermediate', () => colors.primary500).with('off', () => colors.neutral100).exhaustive();
|
|
89
|
+
};
|
|
90
|
+
const getBackgroundColor = status => {
|
|
91
|
+
return match(status).with('on', () => colors.primary500).with('intermediate', () => colors.primary500).with('off', () => colors.white).exhaustive();
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export { Checkbox };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".Checkbox-module_wrapper__5uqJp{align-items:center;display:flex;gap:var(--ds-spacing-5)}.Checkbox-module_checkbox__05Z5t{--cocso-checkbox-size:inherit;--cocso-checkbox-color:inherit;--cocso-checkbox-border-color:inherit;--cocso-checkbox-bg-color:inherit;align-items:center;background-color:var(--cocso-checkbox-bg-color);border:1px solid var(--cocso-checkbox-border-color);border-radius:4px;color:var(--cocso-checkbox-color);cursor:pointer;display:inline-flex;height:var(--cocso-checkbox-size);justify-content:center;opacity:1;position:relative;transition:color .15s ease-in-out,border-color .15s ease-in-out,background-color .15s ease-in-out;width:var(--cocso-checkbox-size)}.Checkbox-module_checkbox__05Z5t>svg{stroke:var(--cocso-checkbox-color);display:block;height:auto;max-width:100%;transition:stroke .15s ease-in-out}.Checkbox-module_checkbox__05Z5t input[type=checkbox]{clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.Checkbox-module_indicator__MLpNt{bottom:var(--number-1);left:var(--number-1);position:absolute;right:var(--number-1);top:var(--number-1);transition:opacity .15s ease-in-out}.Checkbox-module_label__ubb5U{cursor:pointer;opacity:1}.Checkbox-module_checkbox__05Z5t[disabled],.Checkbox-module_label__ubb5U[aria-disabled=true]{cursor:not-allowed;opacity:.5}";
|
|
4
|
+
var styles = {"wrapper":"Checkbox-module_wrapper__5uqJp","checkbox":"Checkbox-module_checkbox__05Z5t","indicator":"Checkbox-module_indicator__MLpNt","label":"Checkbox-module_label__ubb5U"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { styles as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as DropdownPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
|
+
|
|
4
|
+
declare const Dropdown: react.FC<DropdownPrimitive.DropdownMenuProps> & {
|
|
5
|
+
Trigger: react.ForwardRefExoticComponent<DropdownPrimitive.DropdownMenuTriggerProps & react.RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
Portal: react.FC<DropdownPrimitive.DropdownMenuPortalProps>;
|
|
7
|
+
Content: react.ForwardRefExoticComponent<Omit<Omit<DropdownPrimitive.DropdownMenuContentProps & react.RefAttributes<HTMLDivElement>, "ref">, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
8
|
+
Item: react.ForwardRefExoticComponent<Omit<DropdownPrimitive.DropdownMenuItemProps & react.RefAttributes<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { Dropdown };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as DropdownPrimitive from '@radix-ui/react-dropdown-menu';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import styles from './Dropdown.module.css.mjs';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
const DropdownContent = /*#__PURE__*/forwardRef(({
|
|
8
|
+
className,
|
|
9
|
+
...props
|
|
10
|
+
}, ref) => {
|
|
11
|
+
return /*#__PURE__*/jsx(DropdownPrimitive.Content, {
|
|
12
|
+
ref: ref,
|
|
13
|
+
className: clsx(styles.content, className),
|
|
14
|
+
...props
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
const DropdownItem = /*#__PURE__*/forwardRef(({
|
|
18
|
+
className,
|
|
19
|
+
...props
|
|
20
|
+
}, ref) => {
|
|
21
|
+
return /*#__PURE__*/jsx(DropdownPrimitive.Item, {
|
|
22
|
+
ref: ref,
|
|
23
|
+
className: clsx(styles.item, className),
|
|
24
|
+
...props
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
const Dropdown = Object.assign(DropdownPrimitive.Root, {
|
|
28
|
+
Trigger: DropdownPrimitive.Trigger,
|
|
29
|
+
Portal: DropdownPrimitive.Portal,
|
|
30
|
+
Content: DropdownContent,
|
|
31
|
+
Item: DropdownItem
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export { Dropdown };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs';
|
|
2
|
+
|
|
3
|
+
var css_248z = "@keyframes Dropdown-module_dropdown-slide-up__2uVH3{0%{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}@keyframes Dropdown-module_dropdown-slide-down__T5LLc{0%{opacity:0;transform:translateY(-2px)}to{opacity:1;transform:translateY(0)}}.Dropdown-module_content__S3TRi{background-color:var(--color-background-white);border-radius:var(--ds-spacing-3);box-shadow:var(--shadow-1);display:flex;flex-direction:column;will-change:transform,opacity;z-index:var(--z-index-overlay)}.Dropdown-module_content__S3TRi[data-side=top]{animation:Dropdown-module_dropdown-slide-up__2uVH3 .4s cubic-bezier(.16,1,.3,1)}.Dropdown-module_content__S3TRi[data-side=bottom]{animation:Dropdown-module_dropdown-slide-down__T5LLc .4s cubic-bezier(.16,1,.3,1)}.Dropdown-module_item__MIltz{display:flex;flex-direction:column}";
|
|
4
|
+
var styles = {"content":"Dropdown-module_content__S3TRi","item":"Dropdown-module_item__MIltz"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { styles as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { Accordion } from './accordion/Accordion.mjs';
|
|
2
|
+
export { Button, ButtonProps, ButtonShape, ButtonSize, ButtonVariant } from './button/Button.mjs';
|
|
3
|
+
export { Checkbox, CheckboxProps, CheckboxSize, CheckboxStatus } from './checkbox/Checkbox.mjs';
|
|
4
|
+
export { Dropdown } from './dropdown/Dropdown.mjs';
|
|
5
|
+
export { Link, LinkProps, LinkSize } from './link/Link.mjs';
|
|
6
|
+
export { Modal } from './modal/Modal.mjs';
|
|
7
|
+
export { OneTimePasswordField } from './one-time-password-field/OneTimePasswordField.mjs';
|
|
8
|
+
export { Pagination, PaginationProps } from './pagination/Pagination.mjs';
|
|
9
|
+
export { Popover } from './popover/Popover.mjs';
|
|
10
|
+
export { Select, SelectProps } from './select/Select.mjs';
|
|
11
|
+
export { Spinner, SpinnerColor, SpinnerProps, SpinnerSize } from './spinner/Spinner.mjs';
|
|
12
|
+
export { QuantityStatus, QuantityStatusProps, StockQuantityStatus, getColor } from './stock-quantity-status/StockQuantityStatus.mjs';
|
|
13
|
+
export { Switch, SwitchProps, SwitchSize } from './switch/Switch.mjs';
|
|
14
|
+
export { Tab } from './tab/Tab.mjs';
|
|
15
|
+
export { Toaster, toast } from 'sonner';
|
|
16
|
+
export { colors } from './token/color.mjs';
|
|
17
|
+
export { spacing } from './token/spacing.mjs';
|
|
18
|
+
export { FontSize, FontWeight, LineHeight, ResponsiveFontSize, fontSize, fontWeight, lineHeight } from './token/typography.mjs';
|
|
19
|
+
export { BodySize, DisplaySize, HeadingSize, Typography, TypographyProps } from './typography/Typography.mjs';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { Accordion } from './accordion/Accordion.mjs';
|
|
2
|
+
export { Button } from './button/Button.mjs';
|
|
3
|
+
export { Checkbox } from './checkbox/Checkbox.mjs';
|
|
4
|
+
export { Dropdown } from './dropdown/Dropdown.mjs';
|
|
5
|
+
export { Link } from './link/Link.mjs';
|
|
6
|
+
export { Modal } from './modal/Modal.mjs';
|
|
7
|
+
export { OneTimePasswordField } from './one-time-password-field/OneTimePasswordField.mjs';
|
|
8
|
+
export { Pagination } from './pagination/Pagination.mjs';
|
|
9
|
+
export { Popover } from './popover/Popover.mjs';
|
|
10
|
+
export { Select } from './select/Select.mjs';
|
|
11
|
+
export { Spinner } from './spinner/Spinner.mjs';
|
|
12
|
+
export { StockQuantityStatus, getColor } from './stock-quantity-status/StockQuantityStatus.mjs';
|
|
13
|
+
export { Switch } from './switch/Switch.mjs';
|
|
14
|
+
export { Tab } from './tab/Tab.mjs';
|
|
15
|
+
export { Toaster, toast } from 'sonner';
|
|
16
|
+
export { colors } from './token/color.mjs';
|
|
17
|
+
export { spacing } from './token/spacing.mjs';
|
|
18
|
+
export { fontSize, fontWeight, lineHeight } from './token/typography.mjs';
|
|
19
|
+
export { Typography } from './typography/Typography.mjs';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
import { FontWeight, LineHeight } from '../token/typography.mjs';
|
|
4
|
+
|
|
5
|
+
type LinkSize = 'lg' | 'md' | 'sm' | 'xs';
|
|
6
|
+
interface LinkProps extends ComponentPropsWithoutRef<'a'> {
|
|
7
|
+
asChild?: boolean;
|
|
8
|
+
size?: LinkSize;
|
|
9
|
+
weight?: FontWeight;
|
|
10
|
+
lineHeight?: LineHeight;
|
|
11
|
+
indicator?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const Link: react.ForwardRefExoticComponent<LinkProps & react.RefAttributes<HTMLAnchorElement>>;
|
|
14
|
+
|
|
15
|
+
export { Link };
|
|
16
|
+
export type { LinkProps, LinkSize };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import styles from './Link.module.css.mjs';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
import { Typography } from '../typography/Typography.mjs';
|
|
8
|
+
|
|
9
|
+
const Link = /*#__PURE__*/forwardRef(({
|
|
10
|
+
asChild,
|
|
11
|
+
className,
|
|
12
|
+
size,
|
|
13
|
+
weight,
|
|
14
|
+
lineHeight,
|
|
15
|
+
indicator = true,
|
|
16
|
+
...props
|
|
17
|
+
}, ref) => {
|
|
18
|
+
const Comp = asChild ? Slot : Primitive.a;
|
|
19
|
+
return /*#__PURE__*/jsx(Typography, {
|
|
20
|
+
type: "body",
|
|
21
|
+
size: size,
|
|
22
|
+
weight: weight,
|
|
23
|
+
lineHeight: lineHeight,
|
|
24
|
+
asChild: true,
|
|
25
|
+
children: /*#__PURE__*/jsx(Comp, {
|
|
26
|
+
ref: ref,
|
|
27
|
+
className: clsx(styles.link, indicator && styles.indicator, className),
|
|
28
|
+
...props
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export { Link };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".Link-module_link__J9CFb{align-items:center;cursor:pointer;display:inline-flex;gap:var(--ds-spacing-2);justify-content:center;text-decoration:none;transition:color .15s ease-in-out;width:fit-content}.Link-module_link__J9CFb>svg{flex-shrink:0;height:var(--ds-spacing-8);width:var(--ds-spacing-8)}.Link-module_indicator__DIUaW{text-decoration:underline}";
|
|
4
|
+
var styles = {"link":"Link-module_link__J9CFb","indicator":"Link-module_indicator__DIUaW"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { styles as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as ModalPrimitive from '@radix-ui/react-dialog';
|
|
3
|
+
|
|
4
|
+
declare const Modal: react.FC<ModalPrimitive.DialogProps> & {
|
|
5
|
+
Trigger: react.ForwardRefExoticComponent<ModalPrimitive.DialogTriggerProps & react.RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
Content: react.ForwardRefExoticComponent<Omit<Omit<ModalPrimitive.DialogContentProps & react.RefAttributes<HTMLDivElement>, "ref">, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
Close: react.ForwardRefExoticComponent<Omit<ModalPrimitive.DialogCloseProps & react.RefAttributes<HTMLButtonElement>, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
Title: react.ForwardRefExoticComponent<Omit<ModalPrimitive.DialogTitleProps & react.RefAttributes<HTMLHeadingElement>, "ref"> & react.RefAttributes<HTMLHeadingElement>>;
|
|
9
|
+
Description: react.ForwardRefExoticComponent<Omit<ModalPrimitive.DialogDescriptionProps & react.RefAttributes<HTMLParagraphElement>, "ref"> & react.RefAttributes<HTMLParagraphElement>>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { Modal };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { CloseIcon } from '@cocso-ui/react-icons';
|
|
2
|
+
import * as ModalPrimitive from '@radix-ui/react-dialog';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import styles from './Modal.module.css.mjs';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
import { Typography } from '../typography/Typography.mjs';
|
|
8
|
+
|
|
9
|
+
const ModalContent = /*#__PURE__*/forwardRef(({
|
|
10
|
+
className,
|
|
11
|
+
children,
|
|
12
|
+
...props
|
|
13
|
+
}, ref) => {
|
|
14
|
+
return /*#__PURE__*/jsxs(ModalPrimitive.Portal, {
|
|
15
|
+
children: [/*#__PURE__*/jsx(ModalPrimitive.Overlay, {
|
|
16
|
+
className: styles.overlay
|
|
17
|
+
}), /*#__PURE__*/jsx(ModalPrimitive.Content, {
|
|
18
|
+
ref: ref,
|
|
19
|
+
className: clsx(styles.content, className),
|
|
20
|
+
...props,
|
|
21
|
+
children: children
|
|
22
|
+
})]
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
const ModalClose = /*#__PURE__*/forwardRef(({
|
|
26
|
+
className,
|
|
27
|
+
children,
|
|
28
|
+
...props
|
|
29
|
+
}, ref) => {
|
|
30
|
+
return /*#__PURE__*/jsx(ModalPrimitive.Close, {
|
|
31
|
+
ref: ref,
|
|
32
|
+
className: clsx(styles.close, className),
|
|
33
|
+
...props,
|
|
34
|
+
children: /*#__PURE__*/jsx(CloseIcon, {
|
|
35
|
+
size: 24
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const ModalTitle = /*#__PURE__*/forwardRef(({
|
|
40
|
+
className,
|
|
41
|
+
children,
|
|
42
|
+
...props
|
|
43
|
+
}, ref) => {
|
|
44
|
+
return /*#__PURE__*/jsx(ModalPrimitive.Title, {
|
|
45
|
+
ref: ref,
|
|
46
|
+
className: clsx(styles.title, className),
|
|
47
|
+
asChild: true,
|
|
48
|
+
...props,
|
|
49
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
50
|
+
type: "heading",
|
|
51
|
+
color: "text.basic",
|
|
52
|
+
children: children
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
const ModalDescription = /*#__PURE__*/forwardRef(({
|
|
57
|
+
className,
|
|
58
|
+
children,
|
|
59
|
+
...props
|
|
60
|
+
}, ref) => {
|
|
61
|
+
return /*#__PURE__*/jsx(ModalPrimitive.Description, {
|
|
62
|
+
ref: ref,
|
|
63
|
+
className: clsx(styles.description, className),
|
|
64
|
+
asChild: true,
|
|
65
|
+
...props,
|
|
66
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
67
|
+
type: "body",
|
|
68
|
+
size: "sm",
|
|
69
|
+
color: "text.subtle",
|
|
70
|
+
children: children
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
const Modal = Object.assign(ModalPrimitive.Root, {
|
|
75
|
+
Trigger: ModalPrimitive.Trigger,
|
|
76
|
+
Content: ModalContent,
|
|
77
|
+
Close: ModalClose,
|
|
78
|
+
Title: ModalTitle,
|
|
79
|
+
Description: ModalDescription
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export { Modal };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs';
|
|
2
|
+
|
|
3
|
+
var css_248z = "@keyframes Modal-module_overlay-show__zyvAx{0%{opacity:0}to{opacity:1}}.Modal-module_overlay__7ZBDB{animation:Modal-module_overlay-show__zyvAx .15s cubic-bezier(.16,1,.3,1);background-color:var(--ds-black-alpha-30);inset:0;position:fixed;z-index:var(--z-index-overlay)}@keyframes Modal-module_content-show__anq3d{0%{opacity:0;transform:translate(-50%,-48%) scale(.98)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}.Modal-module_content__M1b6Q{animation:Modal-module_content-show__anq3d .15s cubic-bezier(.16,1,.3,1);background-color:var(--ds-white);border-radius:8px;display:flex;flex-direction:column;left:50%;max-height:85vh;max-width:420px;padding:var(--number-8);position:fixed;top:50%;transform:translate(-50%,-50%);width:90vw;z-index:var(--z-index-modal)}.Modal-module_close__UbAF7{align-items:center;cursor:pointer;display:flex;height:var(--ds-spacing-10);justify-content:center;width:var(--ds-spacing-10)}.Modal-module_title__oTluo{text-align:center;word-break:keep-all}.Modal-module_description__RgMC5{margin-top:var(--ds-spacing-5);text-align:center}";
|
|
4
|
+
var styles = {"overlay":"Modal-module_overlay__7ZBDB","content":"Modal-module_content__M1b6Q","close":"Modal-module_close__UbAF7","title":"Modal-module_title__oTluo","description":"Modal-module_description__RgMC5"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { styles as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function styleInject(css, ref) {
|
|
2
|
+
if (ref === void 0) ref = {};
|
|
3
|
+
var insertAt = ref.insertAt;
|
|
4
|
+
if (!css || typeof document === 'undefined') {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
8
|
+
var style = document.createElement('style');
|
|
9
|
+
style.type = 'text/css';
|
|
10
|
+
if (insertAt === 'top') {
|
|
11
|
+
if (head.firstChild) {
|
|
12
|
+
head.insertBefore(style, head.firstChild);
|
|
13
|
+
} else {
|
|
14
|
+
head.appendChild(style);
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
head.appendChild(style);
|
|
18
|
+
}
|
|
19
|
+
if (style.styleSheet) {
|
|
20
|
+
style.styleSheet.cssText = css;
|
|
21
|
+
} else {
|
|
22
|
+
style.appendChild(document.createTextNode(css));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { styleInject as default };
|