@yarcl/react 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -2
- package/{src/apply.ts → dist/apply.d.ts} +4 -23
- package/dist/apply.js +37 -0
- package/dist/classes.d.ts +13 -0
- package/dist/classes.js +22 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +58 -0
- package/dist/color.js +49 -32
- package/dist/components/Accordion.d.ts +96 -0
- package/dist/components/Accordion.js +148 -0
- package/dist/components/Alert.d.ts +60 -0
- package/dist/components/Alert.js +61 -0
- package/dist/components/Avatar.d.ts +100 -0
- package/dist/components/Avatar.js +89 -0
- package/dist/components/Badge.d.ts +44 -0
- package/dist/components/Badge.js +43 -0
- package/dist/components/Breadcrumb.d.ts +77 -0
- package/dist/components/Breadcrumb.js +126 -0
- package/dist/components/Button.d.ts +18 -0
- package/dist/components/Button.js +33 -0
- package/dist/components/ButtonGroup.d.ts +29 -0
- package/dist/components/ButtonGroup.js +37 -0
- package/dist/components/Card.d.ts +36 -0
- package/dist/components/Card.js +26 -0
- package/dist/components/Checkbox.d.ts +28 -0
- package/dist/components/Checkbox.js +38 -0
- package/dist/components/Combobox.d.ts +75 -0
- package/dist/components/Combobox.js +362 -0
- package/dist/components/CommandPalette.d.ts +92 -0
- package/dist/components/CommandPalette.js +293 -0
- package/dist/components/DatePicker.d.ts +157 -0
- package/dist/components/DatePicker.js +230 -0
- package/dist/components/Dialog.d.ts +25 -0
- package/dist/components/Dialog.js +29 -0
- package/dist/components/Divider.d.ts +23 -0
- package/dist/components/Divider.js +25 -0
- package/dist/components/Drawer.d.ts +21 -0
- package/dist/components/Drawer.js +25 -0
- package/dist/components/EmptyState.d.ts +51 -0
- package/dist/components/EmptyState.js +47 -0
- package/dist/components/Field.d.ts +27 -0
- package/dist/components/Field.js +59 -0
- package/dist/components/Heading.d.ts +26 -0
- package/dist/components/Heading.js +25 -0
- package/dist/components/HoverCard.d.ts +47 -0
- package/dist/components/HoverCard.js +53 -0
- package/dist/components/IconButton.d.ts +19 -0
- package/dist/components/IconButton.js +32 -0
- package/dist/components/Inline.d.ts +21 -0
- package/dist/components/Inline.js +24 -0
- package/dist/components/Input.d.ts +19 -0
- package/dist/components/Input.js +25 -0
- package/dist/components/Label.d.ts +46 -0
- package/dist/components/Label.js +33 -0
- package/dist/components/Link.d.ts +27 -0
- package/dist/components/Link.js +26 -0
- package/dist/components/Menu.d.ts +73 -0
- package/dist/components/Menu.js +143 -0
- package/dist/components/Modal.d.ts +45 -0
- package/dist/components/Modal.js +110 -0
- package/dist/components/NumberInput.d.ts +49 -0
- package/dist/components/NumberInput.js +130 -0
- package/dist/components/Pagination.d.ts +86 -0
- package/dist/components/Pagination.js +119 -0
- package/dist/components/Popover.d.ts +72 -0
- package/dist/components/Popover.js +87 -0
- package/dist/components/Progress.d.ts +60 -0
- package/dist/components/Progress.js +59 -0
- package/dist/components/Radio.d.ts +32 -0
- package/dist/components/Radio.js +47 -0
- package/dist/components/RadioGroup.d.ts +57 -0
- package/dist/components/RadioGroup.js +68 -0
- package/dist/components/Select.d.ts +47 -0
- package/dist/components/Select.js +138 -0
- package/dist/components/Skeleton.d.ts +46 -0
- package/dist/components/Skeleton.js +40 -0
- package/dist/components/Slider.d.ts +126 -0
- package/dist/components/Slider.js +166 -0
- package/dist/components/Spinner.d.ts +23 -0
- package/dist/components/Spinner.js +23 -0
- package/dist/components/Stack.d.ts +35 -0
- package/dist/components/Stack.js +24 -0
- package/dist/components/Switch.d.ts +27 -0
- package/dist/components/Switch.js +33 -0
- package/dist/components/Table.d.ts +71 -0
- package/dist/components/Table.js +61 -0
- package/dist/components/Tabs.d.ts +66 -0
- package/dist/components/Tabs.js +109 -0
- package/dist/components/Text.d.ts +32 -0
- package/dist/components/Text.js +28 -0
- package/dist/components/Textarea.d.ts +15 -0
- package/dist/components/Textarea.js +24 -0
- package/dist/components/Toast.d.ts +90 -0
- package/dist/components/Toast.js +156 -0
- package/dist/components/ToggleGroup.d.ts +79 -0
- package/dist/components/ToggleGroup.js +101 -0
- package/dist/components/Tooltip.d.ts +46 -0
- package/dist/components/Tooltip.js +62 -0
- package/dist/components/VisuallyHidden.d.ts +18 -0
- package/dist/components/VisuallyHidden.js +22 -0
- package/dist/contrast.d.ts +32 -0
- package/dist/css.d.ts +2 -2
- package/dist/css.js +193 -157
- package/dist/define.d.ts +40 -15
- package/dist/define.js +30 -27
- package/dist/demo.d.ts +2 -0
- package/dist/demo.js +2 -0
- package/dist/esbuild.cjs +5 -0
- package/dist/esbuild.d.ts +4 -0
- package/dist/esbuild.js +6 -0
- package/dist/field-context.d.ts +16 -0
- package/dist/field-context.js +17 -0
- package/dist/floating.d.ts +12 -0
- package/dist/floating.js +52 -0
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.js +12 -0
- package/{src/index.ts → dist/index.d.ts} +11 -33
- package/dist/index.js +50 -0
- package/dist/init.d.ts +18 -0
- package/dist/init.js +224 -0
- package/dist/plugin.d.ts +10 -26
- package/dist/plugin.js +152 -78
- package/dist/reference/DemoYarcl.d.ts +12 -0
- package/dist/reference/DemoYarcl.js +312 -0
- package/dist/reference/DesignReference.d.ts +24 -0
- package/dist/reference/DesignReference.js +403 -0
- package/dist/reference/index.js +2 -0
- package/dist/rollup.cjs +5 -0
- package/dist/rollup.d.ts +4 -0
- package/dist/rollup.js +6 -0
- package/dist/rspack.cjs +5 -0
- package/dist/rspack.d.ts +4 -0
- package/dist/rspack.js +6 -0
- package/dist/runtime.d.ts +13 -0
- package/dist/runtime.js +30 -0
- package/dist/setup.d.ts +6 -0
- package/dist/setup.js +33 -0
- package/{src → dist}/styles.css +224 -106
- package/dist/themes/bloom.d.ts +295 -0
- package/dist/themes/bloom.js +202 -0
- package/dist/themes/brutalist.d.ts +277 -0
- package/dist/themes/brutalist.js +199 -0
- package/dist/themes/compact.d.ts +274 -0
- package/dist/themes/compact.js +200 -0
- package/dist/themes/contract.d.ts +23 -0
- package/dist/themes/editorial.d.ts +277 -0
- package/dist/themes/editorial.js +183 -0
- package/dist/themes/index.d.ts +1425 -0
- package/dist/themes/index.js +45 -0
- package/{src/types.ts → dist/types.d.ts} +40 -37
- package/dist/vite.cjs +5 -0
- package/dist/vite.d.ts +4 -0
- package/dist/vite.js +6 -0
- package/dist/webpack.cjs +5 -0
- package/dist/webpack.d.ts +4 -0
- package/dist/webpack.js +6 -0
- package/dist/yarcl.config.d.ts +276 -0
- package/dist/yarcl.config.js +273 -0
- package/package.json +69 -17
- package/src/classes.ts +0 -23
- package/src/color.ts +0 -48
- package/src/components/Accordion.tsx +0 -274
- package/src/components/Alert.tsx +0 -85
- package/src/components/Badge.tsx +0 -79
- package/src/components/Breadcrumb.tsx +0 -239
- package/src/components/Button.tsx +0 -58
- package/src/components/ButtonGroup.tsx +0 -61
- package/src/components/Card.tsx +0 -50
- package/src/components/Checkbox.tsx +0 -49
- package/src/components/Combobox.tsx +0 -522
- package/src/components/CommandPalette.tsx +0 -452
- package/src/components/DatePicker.tsx +0 -432
- package/src/components/Dialog.tsx +0 -39
- package/src/components/Divider.tsx +0 -34
- package/src/components/Drawer.tsx +0 -31
- package/src/components/Field.tsx +0 -61
- package/src/components/Heading.tsx +0 -40
- package/src/components/HoverCard.tsx +0 -108
- package/src/components/IconButton.tsx +0 -59
- package/src/components/Inline.tsx +0 -42
- package/src/components/Input.tsx +0 -28
- package/src/components/Label.tsx +0 -58
- package/src/components/Link.tsx +0 -41
- package/src/components/Menu.tsx +0 -207
- package/src/components/Modal.tsx +0 -164
- package/src/components/NumberInput.tsx +0 -208
- package/src/components/Pagination.tsx +0 -227
- package/src/components/Popover.tsx +0 -140
- package/src/components/Progress.tsx +0 -122
- package/src/components/Radio.tsx +0 -59
- package/src/components/RadioGroup.tsx +0 -114
- package/src/components/Select.tsx +0 -197
- package/src/components/Skeleton.tsx +0 -95
- package/src/components/Slider.tsx +0 -315
- package/src/components/Spinner.tsx +0 -38
- package/src/components/Stack.tsx +0 -57
- package/src/components/Switch.tsx +0 -42
- package/src/components/Table.tsx +0 -99
- package/src/components/Tabs.tsx +0 -159
- package/src/components/Text.tsx +0 -67
- package/src/components/Textarea.tsx +0 -26
- package/src/components/Toast.tsx +0 -190
- package/src/components/ToggleGroup.tsx +0 -227
- package/src/components/Tooltip.tsx +0 -78
- package/src/contrast.ts +0 -82
- package/src/css.ts +0 -228
- package/src/define.check.ts +0 -259
- package/src/define.ts +0 -379
- package/src/field-context.ts +0 -31
- package/src/floating.tsx +0 -61
- package/src/hooks.ts +0 -19
- package/src/plugin.ts +0 -94
- package/src/reference/DesignReference.tsx +0 -374
- package/src/runtime.ts +0 -38
- package/src/themes/bloom.ts +0 -72
- package/src/themes/brutalist.ts +0 -63
- package/src/themes/compact.ts +0 -63
- package/src/themes/contract.ts +0 -24
- package/src/themes/editorial.ts +0 -55
- package/src/themes/index.ts +0 -47
- package/src/yarcl.config.ts +0 -104
- /package/{src/reference/index.ts → dist/reference/index.d.ts} +0 -0
- /package/{src → dist}/reference/reference.css +0 -0
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react';
|
|
2
|
-
import { colorClass, cx, radiusClass, sizeClass, variantClass } from '../classes';
|
|
3
|
-
import type { TokenProps, VariantProps } from '../types';
|
|
4
|
-
import { useButtonGroup } from './ButtonGroup';
|
|
5
|
-
import { Spinner } from './Spinner';
|
|
6
|
-
import { useDefaults } from '../runtime';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/** Props for {@link Button}. Accepts all native `<button>` attributes except `color`. */
|
|
10
|
-
export interface ButtonProps extends Omit<ComponentProps<'button'>, 'color'>, TokenProps, VariantProps {
|
|
11
|
-
/** Shows a {@link Spinner}, disables the button and sets `aria-busy`. */
|
|
12
|
-
loading?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A button styled from the consumer's design tokens.
|
|
17
|
-
* Shares the size scale with {@link Input}, so both have the same height at the same size.
|
|
18
|
-
* Icons (`<svg>`) inside are sized from the size's `iconSize`.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```tsx
|
|
22
|
-
* <Button size="lg" color="danger" variant="outline" radius="pill">Delete</Button>
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export function Button({
|
|
26
|
-
size,
|
|
27
|
-
radius,
|
|
28
|
-
color,
|
|
29
|
-
variant,
|
|
30
|
-
loading,
|
|
31
|
-
disabled,
|
|
32
|
-
className,
|
|
33
|
-
type = 'button',
|
|
34
|
-
children,
|
|
35
|
-
...props
|
|
36
|
-
}: ButtonProps) {
|
|
37
|
-
const own = useDefaults('Button');
|
|
38
|
-
const group = useButtonGroup();
|
|
39
|
-
return (
|
|
40
|
-
<button
|
|
41
|
-
type={type}
|
|
42
|
-
className={cx(
|
|
43
|
-
'yarcl-button',
|
|
44
|
-
sizeClass(size ?? group?.size ?? own.size),
|
|
45
|
-
radiusClass(radius ?? group?.radius ?? own.radius, size ?? group?.size ?? own.size),
|
|
46
|
-
colorClass(color ?? group?.color ?? own.color),
|
|
47
|
-
variantClass(variant ?? group?.variant ?? own.variant),
|
|
48
|
-
className,
|
|
49
|
-
)}
|
|
50
|
-
disabled={disabled || loading}
|
|
51
|
-
aria-busy={loading || undefined}
|
|
52
|
-
{...props}
|
|
53
|
-
>
|
|
54
|
-
{loading && <Spinner label="" aria-hidden="true" />}
|
|
55
|
-
{children}
|
|
56
|
-
</button>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, type ComponentProps } from 'react';
|
|
2
|
-
import { cx } from '../classes';
|
|
3
|
-
import type { TokenProps, VariantProps } from '../types';
|
|
4
|
-
|
|
5
|
-
const ButtonGroupContext = createContext<(TokenProps & VariantProps) | null>(null);
|
|
6
|
-
|
|
7
|
-
export function useButtonGroup() {
|
|
8
|
-
return useContext(ButtonGroupContext);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** Props for {@link ButtonGroup}. Token props are passed down to every button inside. */
|
|
12
|
-
export interface ButtonGroupProps extends Omit<ComponentProps<'div'>, 'color'>, TokenProps, VariantProps {
|
|
13
|
-
/**
|
|
14
|
-
* Joins the buttons into one control with shared borders.
|
|
15
|
-
* @default true
|
|
16
|
-
*/
|
|
17
|
-
attached?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Direction of the buttons.
|
|
20
|
-
* @default 'horizontal'
|
|
21
|
-
*/
|
|
22
|
-
orientation?: 'horizontal' | 'vertical';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Groups related {@link Button}s and {@link IconButton}s. Buttons inherit `size`, `color`,
|
|
27
|
-
* `variant` and `radius` from the group unless they set their own. Give the group an `aria-label`.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```tsx
|
|
31
|
-
* <ButtonGroup aria-label="Pagination" variant="outline">
|
|
32
|
-
* <Button>Previous</Button>
|
|
33
|
-
* <Button>Next</Button>
|
|
34
|
-
* </ButtonGroup>
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export function ButtonGroup({
|
|
38
|
-
size,
|
|
39
|
-
color,
|
|
40
|
-
variant,
|
|
41
|
-
radius,
|
|
42
|
-
attached = true,
|
|
43
|
-
orientation = 'horizontal',
|
|
44
|
-
className,
|
|
45
|
-
...props
|
|
46
|
-
}: ButtonGroupProps) {
|
|
47
|
-
return (
|
|
48
|
-
<ButtonGroupContext.Provider value={{ size, color, variant, radius }}>
|
|
49
|
-
<div
|
|
50
|
-
role="group"
|
|
51
|
-
className={cx(
|
|
52
|
-
'yarcl-button-group',
|
|
53
|
-
`yarcl-button-group-${orientation}`,
|
|
54
|
-
attached && 'yarcl-button-group-attached',
|
|
55
|
-
className,
|
|
56
|
-
)}
|
|
57
|
-
{...props}
|
|
58
|
-
/>
|
|
59
|
-
</ButtonGroupContext.Provider>
|
|
60
|
-
);
|
|
61
|
-
}
|
package/src/components/Card.tsx
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react';
|
|
2
|
-
import { cx, paddingClass, radiusClass, shadowClass } from '../classes';
|
|
3
|
-
import type { Radius, Shadow, Spacing } from '../types';
|
|
4
|
-
import { useDefaults } from '../runtime';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** Props for {@link Card}. */
|
|
8
|
-
export interface CardProps extends ComponentProps<'div'> {
|
|
9
|
-
/**
|
|
10
|
-
* Element to render.
|
|
11
|
-
* @default 'div'
|
|
12
|
-
*/
|
|
13
|
-
as?: 'div' | 'section' | 'article' | 'aside';
|
|
14
|
-
/**
|
|
15
|
-
* Inner padding, from the `spacing` config.
|
|
16
|
-
* @default config.defaults.padding
|
|
17
|
-
*/
|
|
18
|
-
padding?: Spacing;
|
|
19
|
-
/**
|
|
20
|
-
* Corner radius, from the `radii` config.
|
|
21
|
-
* @default config.defaults.radius
|
|
22
|
-
*/
|
|
23
|
-
radius?: Radius;
|
|
24
|
-
/** Elevation, from the `shadows` config. No shadow when omitted. */
|
|
25
|
-
shadow?: Shadow;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* A bordered surface for grouping content.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```tsx
|
|
33
|
-
* <Card shadow="md">
|
|
34
|
-
* <Stack>
|
|
35
|
-
* <Heading level={3}>Plan</Heading>
|
|
36
|
-
* <Text muted>Pro, billed yearly</Text>
|
|
37
|
-
* </Stack>
|
|
38
|
-
* </Card>
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export function Card({ as = 'div', padding, radius, shadow, className, ...props }: CardProps) {
|
|
42
|
-
const own = useDefaults('Card');
|
|
43
|
-
const Tag = as as 'div';
|
|
44
|
-
return (
|
|
45
|
-
<Tag
|
|
46
|
-
className={cx('yarcl-card', paddingClass(padding ?? own.padding), radiusClass(radius ?? own.radius), shadowClass(shadow ?? own.shadow), className)}
|
|
47
|
-
{...props}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { useEffect, useImperativeHandle, useRef, type ComponentProps, type ReactNode } from 'react';
|
|
2
|
-
import { colorClass, cx, sizeClass } from '../classes';
|
|
3
|
-
import { useFieldProps } from '../field-context';
|
|
4
|
-
import type { Color, Size } from '../types';
|
|
5
|
-
import { useDefaults } from '../runtime';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/** Props for {@link Checkbox}. Accepts all native `<input>` attributes except `type`, `color` and `size`. */
|
|
9
|
-
export interface CheckboxProps extends Omit<ComponentProps<'input'>, 'type' | 'color' | 'size' | 'children'> {
|
|
10
|
-
/** Label shown next to the box. */
|
|
11
|
-
children?: ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* Box size, from the `sizes` config (uses the size's `iconSize`).
|
|
14
|
-
* @default config.defaults.size
|
|
15
|
-
*/
|
|
16
|
-
size?: Size;
|
|
17
|
-
/**
|
|
18
|
-
* Color of the checked box, from the `colors` config.
|
|
19
|
-
* @default config.defaults.color
|
|
20
|
-
*/
|
|
21
|
-
color?: Color;
|
|
22
|
-
/** Shows a mixed state. Cleared by the browser when the user toggles the box. */
|
|
23
|
-
indeterminate?: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* A checkbox with an optional label.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```tsx
|
|
31
|
-
* <Checkbox defaultChecked>Remember me</Checkbox>
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export function Checkbox(props: CheckboxProps) {
|
|
35
|
-
const own = useDefaults('Checkbox');
|
|
36
|
-
const { children, size, color, indeterminate = false, className, style, ref, ...rest } = useFieldProps(props);
|
|
37
|
-
const inner = useRef<HTMLInputElement>(null);
|
|
38
|
-
useImperativeHandle(ref, () => inner.current!, []);
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (inner.current) inner.current.indeterminate = indeterminate;
|
|
41
|
-
}, [indeterminate]);
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<label className={cx('yarcl-checkbox', sizeClass(size ?? own.size), colorClass(color ?? own.color), className)} style={style}>
|
|
45
|
-
<input ref={inner} type="checkbox" className="yarcl-checkbox-input" {...rest} />
|
|
46
|
-
{children != null && <span className="yarcl-checkbox-label">{children}</span>}
|
|
47
|
-
</label>
|
|
48
|
-
);
|
|
49
|
-
}
|