@matekit/react 0.0.0-stage → 0.1.1
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/CHANGELOG.md +102 -0
- package/LICENSE +202 -0
- package/NOTICE +56 -0
- package/README.md +115 -2
- package/dist/atoms/Divider/Divider.d.ts +49 -0
- package/dist/atoms/Divider/Divider.js +29 -0
- package/dist/atoms/FocusRing/FocusRing.d.ts +16 -0
- package/dist/atoms/FocusRing/FocusRing.js +16 -0
- package/dist/atoms/Group/Group.d.ts +38 -0
- package/dist/atoms/Group/Group.js +34 -0
- package/dist/atoms/Icon/Icon.d.ts +23 -0
- package/dist/atoms/Icon/Icon.js +19 -0
- package/dist/atoms/Interactive/Interactive.d.ts +98 -0
- package/dist/atoms/Interactive/Interactive.js +87 -0
- package/dist/atoms/Ripple/Ripple.d.ts +14 -0
- package/dist/atoms/Ripple/Ripple.js +63 -0
- package/dist/atoms/Shape/Shape.d.ts +24 -0
- package/dist/atoms/Shape/Shape.js +19 -0
- package/dist/atoms/Shape/shapes.d.ts +8 -0
- package/dist/atoms/Shape/shapes.js +40 -0
- package/dist/atoms/Stack/Stack.d.ts +58 -0
- package/dist/atoms/Stack/Stack.js +33 -0
- package/dist/atoms/StateLayer/StateLayer.d.ts +17 -0
- package/dist/atoms/StateLayer/StateLayer.js +17 -0
- package/dist/atoms/index.d.ts +10 -0
- package/dist/atoms/index.js +10 -0
- package/dist/fonts/roboto-flex/OFL.txt +93 -0
- package/dist/fonts/roboto-flex/roboto-flex-cyrillic-ext.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-cyrillic.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-greek.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-latin-ext.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-latin.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-vietnamese.woff2 +0 -0
- package/dist/icons/icons.d.ts +89 -0
- package/dist/icons/icons.js +186 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +3 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12 -0
- package/dist/internal/accessible-name.d.ts +17 -0
- package/dist/internal/accessible-name.js +33 -0
- package/dist/internal/anchor-position.d.ts +99 -0
- package/dist/internal/anchor-position.js +159 -0
- package/dist/internal/anchored-drag.d.ts +25 -0
- package/dist/internal/anchored-drag.js +106 -0
- package/dist/internal/dev.d.ts +2 -0
- package/dist/internal/dev.js +18 -0
- package/dist/internal/diagnostics.d.ts +46 -0
- package/dist/internal/diagnostics.js +125 -0
- package/dist/internal/group-label.d.ts +22 -0
- package/dist/internal/group-label.js +50 -0
- package/dist/internal/interactive.d.ts +28 -0
- package/dist/internal/interactive.js +18 -0
- package/dist/internal/layout-element.d.ts +21 -0
- package/dist/internal/layout-element.js +33 -0
- package/dist/internal/merge-refs.d.ts +13 -0
- package/dist/internal/merge-refs.js +35 -0
- package/dist/internal/modal-dialog.d.ts +63 -0
- package/dist/internal/modal-dialog.js +267 -0
- package/dist/internal/navigation-count.d.ts +38 -0
- package/dist/internal/navigation-count.js +60 -0
- package/dist/internal/navigation-item.d.ts +14 -0
- package/dist/internal/navigation-item.js +17 -0
- package/dist/internal/nearest-scroller.d.ts +4 -0
- package/dist/internal/nearest-scroller.js +17 -0
- package/dist/internal/open-state.d.ts +15 -0
- package/dist/internal/open-state.js +42 -0
- package/dist/internal/roving-focus.d.ts +41 -0
- package/dist/internal/roving-focus.js +126 -0
- package/dist/internal/settle-animations.d.ts +33 -0
- package/dist/internal/settle-animations.js +48 -0
- package/dist/internal/time-period.d.ts +10 -0
- package/dist/internal/time-period.js +26 -0
- package/dist/internal/time.d.ts +23 -0
- package/dist/internal/time.js +69 -0
- package/dist/internal/typeahead.d.ts +17 -0
- package/dist/internal/typeahead.js +35 -0
- package/dist/molecules/Badge/Badge.d.ts +25 -0
- package/dist/molecules/Badge/Badge.js +16 -0
- package/dist/molecules/Button/Button.d.ts +48 -0
- package/dist/molecules/Button/Button.js +34 -0
- package/dist/molecules/Card/Card.d.ts +159 -0
- package/dist/molecules/Card/Card.js +119 -0
- package/dist/molecules/Checkbox/Checkbox.d.ts +26 -0
- package/dist/molecules/Checkbox/Checkbox.js +40 -0
- package/dist/molecules/Chip/AssistChip.d.ts +23 -0
- package/dist/molecules/Chip/AssistChip.js +22 -0
- package/dist/molecules/Chip/ChipGroup.d.ts +85 -0
- package/dist/molecules/Chip/ChipGroup.js +92 -0
- package/dist/molecules/Chip/FilterChip.d.ts +33 -0
- package/dist/molecules/Chip/FilterChip.js +30 -0
- package/dist/molecules/Chip/InputChip.d.ts +60 -0
- package/dist/molecules/Chip/InputChip.js +107 -0
- package/dist/molecules/Chip/SuggestionChip.d.ts +24 -0
- package/dist/molecules/Chip/SuggestionChip.js +17 -0
- package/dist/molecules/Chip/chip-content.d.ts +39 -0
- package/dist/molecules/Chip/chip-content.js +95 -0
- package/dist/molecules/Chip/chip-element.d.ts +14 -0
- package/dist/molecules/Chip/chip-element.js +14 -0
- package/dist/molecules/Chip/strings.d.ts +8 -0
- package/dist/molecules/Chip/strings.js +5 -0
- package/dist/molecules/Fab/Fab.d.ts +78 -0
- package/dist/molecules/Fab/Fab.js +52 -0
- package/dist/molecules/IconButton/IconButton.d.ts +59 -0
- package/dist/molecules/IconButton/IconButton.js +36 -0
- package/dist/molecules/LoadingIndicator/LoadingIndicator.d.ts +38 -0
- package/dist/molecules/LoadingIndicator/LoadingIndicator.js +25 -0
- package/dist/molecules/LoadingIndicator/determinate.d.ts +3 -0
- package/dist/molecules/LoadingIndicator/determinate.js +47 -0
- package/dist/molecules/LoadingIndicator/loading-indicator-data.d.ts +21 -0
- package/dist/molecules/LoadingIndicator/loading-indicator-data.js +72 -0
- package/dist/molecules/ProgressIndicator/CircularProgressIndicator.d.ts +35 -0
- package/dist/molecules/ProgressIndicator/CircularProgressIndicator.js +30 -0
- package/dist/molecules/ProgressIndicator/LinearProgressIndicator.d.ts +43 -0
- package/dist/molecules/ProgressIndicator/LinearProgressIndicator.js +28 -0
- package/dist/molecules/ProgressIndicator/circular-wavy-data.d.ts +5 -0
- package/dist/molecules/ProgressIndicator/circular-wavy-data.js +19 -0
- package/dist/molecules/ProgressIndicator/progress.d.ts +24 -0
- package/dist/molecules/ProgressIndicator/progress.js +60 -0
- package/dist/molecules/RadioButton/RadioButton.d.ts +27 -0
- package/dist/molecules/RadioButton/RadioButton.js +70 -0
- package/dist/molecules/RadioButton/RadioGroup.d.ts +73 -0
- package/dist/molecules/RadioButton/RadioGroup.js +82 -0
- package/dist/molecules/ScrollField/ScrollField.d.ts +61 -0
- package/dist/molecules/ScrollField/ScrollField.js +352 -0
- package/dist/molecules/Slider/RangeSlider.d.ts +60 -0
- package/dist/molecules/Slider/RangeSlider.js +169 -0
- package/dist/molecules/Slider/Slider.d.ts +54 -0
- package/dist/molecules/Slider/Slider.js +71 -0
- package/dist/molecules/Slider/slider-shared.d.ts +26 -0
- package/dist/molecules/Slider/slider-shared.js +98 -0
- package/dist/molecules/Switch/Switch.d.ts +22 -0
- package/dist/molecules/Switch/Switch.js +20 -0
- package/dist/molecules/TextField/TextField.d.ts +83 -0
- package/dist/molecules/TextField/TextField.js +146 -0
- package/dist/molecules/TextField/TextFieldSlots.d.ts +22 -0
- package/dist/molecules/TextField/TextFieldSlots.js +24 -0
- package/dist/molecules/TimeInput/TimeInput.d.ts +108 -0
- package/dist/molecules/TimeInput/TimeInput.js +347 -0
- package/dist/molecules/TimeInput/strings.d.ts +13 -0
- package/dist/molecules/TimeInput/strings.js +10 -0
- package/dist/molecules/TimeScroll/TimeScroll.d.ts +106 -0
- package/dist/molecules/TimeScroll/TimeScroll.js +213 -0
- package/dist/molecules/TimeScroll/strings.d.ts +13 -0
- package/dist/molecules/TimeScroll/strings.js +12 -0
- package/dist/molecules/index.d.ts +27 -0
- package/dist/molecules/index.js +25 -0
- package/dist/organisms/BottomSheet/BottomSheet.d.ts +128 -0
- package/dist/organisms/BottomSheet/BottomSheet.js +432 -0
- package/dist/organisms/BottomSheet/BottomSheetSlots.d.ts +17 -0
- package/dist/organisms/BottomSheet/BottomSheetSlots.js +16 -0
- package/dist/organisms/BottomSheet/StandardBottomSheet.d.ts +37 -0
- package/dist/organisms/BottomSheet/StandardBottomSheet.js +206 -0
- package/dist/organisms/BottomSheet/bottom-sheet-context.d.ts +31 -0
- package/dist/organisms/BottomSheet/bottom-sheet-context.js +12 -0
- package/dist/organisms/BottomSheet/sheet-drag.d.ts +1 -0
- package/dist/organisms/BottomSheet/sheet-drag.js +4 -0
- package/dist/organisms/BottomSheet/strings.d.ts +9 -0
- package/dist/organisms/BottomSheet/strings.js +8 -0
- package/dist/organisms/ButtonGroup/ButtonGroup.d.ts +97 -0
- package/dist/organisms/ButtonGroup/ButtonGroup.js +242 -0
- package/dist/organisms/ButtonGroup/ButtonGroupItem.d.ts +36 -0
- package/dist/organisms/ButtonGroup/ButtonGroupItem.js +47 -0
- package/dist/organisms/Dialog/Dialog.d.ts +186 -0
- package/dist/organisms/Dialog/Dialog.js +193 -0
- package/dist/organisms/Dialog/DialogSlots.d.ts +60 -0
- package/dist/organisms/Dialog/DialogSlots.js +54 -0
- package/dist/organisms/Dialog/strings.d.ts +5 -0
- package/dist/organisms/Dialog/strings.js +5 -0
- package/dist/organisms/FabMenu/FabMenu.d.ts +104 -0
- package/dist/organisms/FabMenu/FabMenu.js +142 -0
- package/dist/organisms/FabMenu/strings.d.ts +9 -0
- package/dist/organisms/FabMenu/strings.js +5 -0
- package/dist/organisms/List/List.d.ts +190 -0
- package/dist/organisms/List/List.js +148 -0
- package/dist/organisms/Menu/Menu.d.ts +313 -0
- package/dist/organisms/Menu/Menu.js +865 -0
- package/dist/organisms/Menu/MenuSlots.d.ts +35 -0
- package/dist/organisms/Menu/MenuSlots.js +36 -0
- package/dist/organisms/NavigationBar/NavigationBar.d.ts +96 -0
- package/dist/organisms/NavigationBar/NavigationBar.js +77 -0
- package/dist/organisms/NavigationRail/ModalNavigationRail.d.ts +105 -0
- package/dist/organisms/NavigationRail/ModalNavigationRail.js +272 -0
- package/dist/organisms/NavigationRail/NavigationRail.d.ts +148 -0
- package/dist/organisms/NavigationRail/NavigationRail.js +114 -0
- package/dist/organisms/NavigationRail/NavigationRailSection.d.ts +54 -0
- package/dist/organisms/NavigationRail/NavigationRailSection.js +96 -0
- package/dist/organisms/NavigationRail/strings.d.ts +7 -0
- package/dist/organisms/NavigationRail/strings.js +7 -0
- package/dist/organisms/NavigationSuite/NavigationSuite.d.ts +109 -0
- package/dist/organisms/NavigationSuite/NavigationSuite.js +86 -0
- package/dist/organisms/PaneScaffold/PaneScaffold.d.ts +118 -0
- package/dist/organisms/PaneScaffold/PaneScaffold.js +132 -0
- package/dist/organisms/Search/Search.d.ts +213 -0
- package/dist/organisms/Search/Search.js +783 -0
- package/dist/organisms/Search/SearchSlots.d.ts +18 -0
- package/dist/organisms/Search/SearchSlots.js +19 -0
- package/dist/organisms/Search/strings.d.ts +21 -0
- package/dist/organisms/Search/strings.js +12 -0
- package/dist/organisms/Select/Select.d.ts +186 -0
- package/dist/organisms/Select/Select.js +597 -0
- package/dist/organisms/Select/SelectSlots.d.ts +12 -0
- package/dist/organisms/Select/SelectSlots.js +12 -0
- package/dist/organisms/SideSheet/SideSheet.d.ts +88 -0
- package/dist/organisms/SideSheet/SideSheet.js +109 -0
- package/dist/organisms/SideSheet/SideSheetSlots.d.ts +35 -0
- package/dist/organisms/SideSheet/SideSheetSlots.js +37 -0
- package/dist/organisms/SideSheet/strings.d.ts +7 -0
- package/dist/organisms/SideSheet/strings.js +6 -0
- package/dist/organisms/Snackbar/Snackbar.d.ts +46 -0
- package/dist/organisms/Snackbar/Snackbar.js +36 -0
- package/dist/organisms/Snackbar/SnackbarHost.d.ts +57 -0
- package/dist/organisms/Snackbar/SnackbarHost.js +221 -0
- package/dist/organisms/Snackbar/snackbar-queue.d.ts +81 -0
- package/dist/organisms/Snackbar/snackbar-queue.js +114 -0
- package/dist/organisms/Snackbar/strings.d.ts +8 -0
- package/dist/organisms/Snackbar/strings.js +5 -0
- package/dist/organisms/SplitButton/SplitButton.d.ts +73 -0
- package/dist/organisms/SplitButton/SplitButton.js +77 -0
- package/dist/organisms/SplitButton/strings.d.ts +9 -0
- package/dist/organisms/SplitButton/strings.js +5 -0
- package/dist/organisms/Tabs/TabLink.d.ts +27 -0
- package/dist/organisms/Tabs/TabLink.js +25 -0
- package/dist/organisms/Tabs/TabNav.d.ts +19 -0
- package/dist/organisms/Tabs/TabNav.js +55 -0
- package/dist/organisms/Tabs/Tabs.d.ts +147 -0
- package/dist/organisms/Tabs/Tabs.js +223 -0
- package/dist/organisms/Tabs/tab-content.d.ts +23 -0
- package/dist/organisms/Tabs/tab-content.js +105 -0
- package/dist/organisms/Tabs/tab-fit.d.ts +4 -0
- package/dist/organisms/Tabs/tab-fit.js +65 -0
- package/dist/organisms/Tabs/tab-motion.d.ts +2 -0
- package/dist/organisms/Tabs/tab-motion.js +68 -0
- package/dist/organisms/TimePickerDialog/TimePickerDialog.d.ts +26 -0
- package/dist/organisms/TimePickerDialog/TimePickerDialog.js +34 -0
- package/dist/organisms/Toolbar/Toolbar.d.ts +75 -0
- package/dist/organisms/Toolbar/Toolbar.js +84 -0
- package/dist/organisms/Toolbar/ToolbarLayout.d.ts +44 -0
- package/dist/organisms/Toolbar/ToolbarLayout.js +90 -0
- package/dist/organisms/Toolbar/ToolbarScroll.d.ts +8 -0
- package/dist/organisms/Toolbar/ToolbarScroll.js +222 -0
- package/dist/organisms/Tooltip/RichTooltip.d.ts +73 -0
- package/dist/organisms/Tooltip/RichTooltip.js +250 -0
- package/dist/organisms/Tooltip/Tooltip.d.ts +52 -0
- package/dist/organisms/Tooltip/Tooltip.js +99 -0
- package/dist/organisms/Tooltip/tooltip-behavior.d.ts +43 -0
- package/dist/organisms/Tooltip/tooltip-behavior.js +307 -0
- package/dist/organisms/TopAppBar/TopAppBar.d.ts +107 -0
- package/dist/organisms/TopAppBar/TopAppBar.js +78 -0
- package/dist/organisms/TopAppBar/TopAppBarScroll.d.ts +7 -0
- package/dist/organisms/TopAppBar/TopAppBarScroll.js +155 -0
- package/dist/organisms/index.d.ts +36 -0
- package/dist/organisms/index.js +36 -0
- package/dist/palettes/blue.css +275 -0
- package/dist/palettes/green.css +275 -0
- package/dist/palettes/index.css +823 -0
- package/dist/palettes/orange.css +275 -0
- package/dist/shapes.css +115 -0
- package/dist/strings/index.d.ts +35 -0
- package/dist/strings/index.js +39 -0
- package/dist/styles-no-fonts.css +12025 -0
- package/dist/styles.css +12123 -0
- package/dist/stylesheet.d.ts +2 -0
- package/dist/tokens/breakpoints.d.ts +33 -0
- package/dist/tokens/breakpoints.js +31 -0
- package/dist/tokens/space.d.ts +26 -0
- package/dist/tokens/space.js +26 -0
- package/package.json +110 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Átomo universal (ADR-0003): sin estado, efectos, contexto ni eventos; no lleva 'use client'.
|
|
2
|
+
// API y contrato con los hijos: ADR-0017.
|
|
3
|
+
import { cx } from '../../internal/interactive.js';
|
|
4
|
+
import { layoutElement } from '../../internal/layout-element.js';
|
|
5
|
+
/**
|
|
6
|
+
* Group of connected blocks: a minimal gap between children and a shape by position, with large
|
|
7
|
+
* outer corners and small inner ones (Material 3 Expressive's segmented List and connected Button
|
|
8
|
+
* groups). CSS resolves it by position (`:first-child`, `:last-child`), so it works with any number
|
|
9
|
+
* of children and on the server.
|
|
10
|
+
*
|
|
11
|
+
* Each use sets three variables (on the group or on a child, also per state):
|
|
12
|
+
* - `--mk-group-gap`: gap. Defaults to `--md-sys-space-25` (2 px).
|
|
13
|
+
* - `--mk-group-outer-radius`: radius of the outer corners. Defaults to 16 (`corner-large`).
|
|
14
|
+
* - `--mk-group-inner-radius`: radius of the inner ones. Defaults to 4 (`corner-extra-small`).
|
|
15
|
+
*
|
|
16
|
+
* The group sets each corner's radius on every direct child (`--mk-group-corner-start-start`,
|
|
17
|
+
* `-start-end`, `-end-start` and `-end-end`, not inherited by grandchildren). A child without a
|
|
18
|
+
* radius of its own (a `<div>`, an `<li>`) gets it automatically; a component with its own radius
|
|
19
|
+
* takes part if it reads those variables (ADR-0017). The variables are computed on each child, so a
|
|
20
|
+
* child can change its inner radius when pressed by redefining `--mk-group-inner-radius` in its
|
|
21
|
+
* `:active`, and the radius animates if the child has a `border-radius` transition.
|
|
22
|
+
*
|
|
23
|
+
* It adds no roles: the blocks can be a list (`render={<ul />}`), buttons (a button group takes
|
|
24
|
+
* `role="group"` and a name, passed as props) or cards.
|
|
25
|
+
*
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <Group orientation="vertical" render={<ul />}>
|
|
28
|
+
* <li>…</li><li>…</li><li>…</li>
|
|
29
|
+
* </Group>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function Group({ orientation, className, style, children, ...props }) {
|
|
33
|
+
return layoutElement('Group', cx('mk-group', className), style, { ...props, 'data-orientation': orientation === 'vertical' ? 'vertical' : 'horizontal' }, children);
|
|
34
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
export interface IconProps extends HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Text announced by screen readers. Without it, the icon is decorative and hidden (the usual
|
|
5
|
+
* case when it accompanies text, as in a button with a label).
|
|
6
|
+
*/
|
|
7
|
+
label?: string | undefined;
|
|
8
|
+
/** Size in px or any CSS length. When undefined, uses the size of the component that contains it. */
|
|
9
|
+
size?: number | string | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Icon container: gives size, color (the text color) and accessibility to any SVG. Works with
|
|
13
|
+
* matekit's icons, your own SVGs or another library's.
|
|
14
|
+
*
|
|
15
|
+
* The size comes from `--mk-icon-size`, set by components (20 px in a small button, 40 in an XL
|
|
16
|
+
* one); outside them, 24 px.
|
|
17
|
+
*
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <Icon><svg viewBox="0 0 24 24">…</svg></Icon>
|
|
20
|
+
* <Icon label="Favorite" size={32}><MyStar /></Icon>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function Icon({ label, size, className, style, children, ...props }: IconProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Icon container: gives size, color (the text color) and accessibility to any SVG. Works with
|
|
4
|
+
* matekit's icons, your own SVGs or another library's.
|
|
5
|
+
*
|
|
6
|
+
* The size comes from `--mk-icon-size`, set by components (20 px in a small button, 40 in an XL
|
|
7
|
+
* one); outside them, 24 px.
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <Icon><svg viewBox="0 0 24 24">…</svg></Icon>
|
|
11
|
+
* <Icon label="Favorite" size={32}><MyStar /></Icon>
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export function Icon({ label, size, className, style, children, ...props }) {
|
|
15
|
+
const sized = size === undefined
|
|
16
|
+
? style
|
|
17
|
+
: { ...style, '--mk-icon-size': typeof size === 'number' ? `${size}px` : size };
|
|
18
|
+
return (_jsx("span", { ...(label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': true }), ...props, className: className ? `mk-icon ${className}` : 'mk-icon', style: sized, children: children }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type HTMLAttributes, type ReactElement, type ReactNode, type Ref } from 'react';
|
|
2
|
+
/** Props the `render` element receives when cloned (those of an `<a>`, plus whatever the router asks for). */
|
|
3
|
+
export type RenderedProps = {
|
|
4
|
+
className?: string | ((...args: never[]) => string | undefined) | undefined;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
ref?: Ref<HTMLElement> | undefined;
|
|
7
|
+
};
|
|
8
|
+
/** With `href`, the element is an `<a>`. */
|
|
9
|
+
export type LinkElementProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
|
|
10
|
+
/** The link's destination: with it, the element is an `<a>`. */
|
|
11
|
+
href: string;
|
|
12
|
+
render?: undefined;
|
|
13
|
+
/** Ref to the `<a>`. */
|
|
14
|
+
ref?: Ref<HTMLAnchorElement> | undefined;
|
|
15
|
+
};
|
|
16
|
+
/** Without `href`, the element is a `<button type="button">`. */
|
|
17
|
+
export type ButtonElementProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> & {
|
|
18
|
+
href?: undefined;
|
|
19
|
+
render?: undefined;
|
|
20
|
+
/** Ref to the `<button>`. */
|
|
21
|
+
ref?: Ref<HTMLButtonElement> | undefined;
|
|
22
|
+
};
|
|
23
|
+
/** With `render`, the element you pass (the router's `Link`). */
|
|
24
|
+
export type RenderElementProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
25
|
+
/**
|
|
26
|
+
* The element rendered instead of the `<a>`: for example `<Link href="/" />` from Next.js or
|
|
27
|
+
* React Router. It is cloned, adding the classes (its own are kept), the other props and the
|
|
28
|
+
* content as children; its own props win. It must pass `className`, `aria-*`, `ref` and the
|
|
29
|
+
* children on to the `<a>` it renders, as those two do. Its children are replaced.
|
|
30
|
+
*/
|
|
31
|
+
render: ReactElement<RenderedProps>;
|
|
32
|
+
href?: undefined;
|
|
33
|
+
/** Ref to the element `render` renders, if that element does not bring its own. */
|
|
34
|
+
ref?: Ref<HTMLElement> | undefined;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Props of `Interactive`: one of three forms, plus `className` and the content.
|
|
38
|
+
* - With `href`: an `<a>` with its attributes (`target`, `download`…) and `ref` to the `<a>`.
|
|
39
|
+
* - Without `href` or `render`: a `<button>` with its attributes (`disabled`, `type`…) and `ref`
|
|
40
|
+
* to the `<button>`. `type` is `"button"` unless you pass another.
|
|
41
|
+
* - With `render`: the element you pass, cloned (see `render`).
|
|
42
|
+
* `href` and `render` don't go together.
|
|
43
|
+
*/
|
|
44
|
+
export type InteractiveProps = (LinkElementProps | ButtonElementProps | RenderElementProps) & {
|
|
45
|
+
/** The element's content (the atoms and the control's text or icons). */
|
|
46
|
+
children?: ReactNode;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* A control's interactive element: an `<a>`, a `<button>` or the `render` element. Use it as the
|
|
50
|
+
* base for your own controls that behave like matekit's: the `StateLayer`, `Ripple` and
|
|
51
|
+
* `FocusRing` atoms go as children and activate on their own with the element's pseudo-classes
|
|
52
|
+
* (`:hover`, `:focus-visible`, `:active`, `:disabled`). It adds no styles or atoms, and no active
|
|
53
|
+
* or disabled state: the control decides that. The control's CSS sets shape and color, and
|
|
54
|
+
* `outline: none` (`FocusRing` draws the ring; otherwise the browser adds its own).
|
|
55
|
+
*
|
|
56
|
+
* **The three forms** (ADR-0010, ADR-0020):
|
|
57
|
+
* - With `href`, a real `<a href>`: it opens in another tab, can be copied, and screen readers
|
|
58
|
+
* announce it as a link.
|
|
59
|
+
* - Without `href` or `render`, a `<button type="button">` (it doesn't submit forms;
|
|
60
|
+
* `type="submit"` does, if you pass it). `type={undefined}` also stays `"button"`.
|
|
61
|
+
* - With `render`, the element you pass, for example the Next.js or React Router `Link`, to
|
|
62
|
+
* navigate without reloading. `href` and `render` don't go together (the types reject it).
|
|
63
|
+
*
|
|
64
|
+
* **The `render` contract** (public API):
|
|
65
|
+
* - It takes an **element** (`render={<Link href="/" />}`), not a component (`render={Link}`):
|
|
66
|
+
* anything else throws an error that explains it.
|
|
67
|
+
* - It is cloned with `cloneElement`. It receives the other props of `Interactive` (attributes,
|
|
68
|
+
* `aria-*`, `data-*`, events, `ref`) and **its own props win**, including its `ref`: if both
|
|
69
|
+
* have one, the element's arrives (they are not combined, to avoid hooks in a universal atom).
|
|
70
|
+
* - Classes **are combined**: `Interactive`'s first, then the element's. If the element's
|
|
71
|
+
* `className` is a function of its state (React Router's `NavLink`), it is wrapped: the function
|
|
72
|
+
* receives the same arguments and its result is added to `Interactive`'s classes.
|
|
73
|
+
* - **Its children are replaced** by `Interactive`'s, without a warning.
|
|
74
|
+
* - The element must pass `className`, `aria-*`, `ref` and the children on to the `<a>` (or
|
|
75
|
+
* whatever it renders), as the Next.js and React Router `Link` do; otherwise matekit can't tell.
|
|
76
|
+
*
|
|
77
|
+
* ```tsx
|
|
78
|
+
* // A custom control: .my-control sets shape, color and `outline: none`; the atoms, the states.
|
|
79
|
+
* function MyControl({ className, children, ...props }: InteractiveProps) {
|
|
80
|
+
* return (
|
|
81
|
+
* <Interactive {...props} className={['my-control', className].filter(Boolean).join(' ')}>
|
|
82
|
+
* <StateLayer />
|
|
83
|
+
* <Ripple />
|
|
84
|
+
* <FocusRing />
|
|
85
|
+
* {children}
|
|
86
|
+
* </Interactive>
|
|
87
|
+
* )
|
|
88
|
+
* }
|
|
89
|
+
*
|
|
90
|
+
* <MyControl href="/help">Help</MyControl> // <a href="/help">
|
|
91
|
+
* <MyControl onClick={save}>Save</MyControl> // <button type="button">
|
|
92
|
+
* <MyControl render={<Link href="/orders" />}>Orders</MyControl> // the Next.js Link's <a>
|
|
93
|
+
* <MyControl render={<NavLink to="/orders" className={({ isActive }) => (isActive ? 'on' : '')} />}>
|
|
94
|
+
* Orders
|
|
95
|
+
* </MyControl> // React Router NavLink
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function Interactive(props: InteractiveProps): ReactElement;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Átomo universal (ADR-0003): sin estado, efectos, contexto ni eventos; no lleva 'use client'.
|
|
3
|
+
// Elige el elemento interactivo según ADR-0010 y ADR-0020: con `href` un `<a>`, sin `href` un
|
|
4
|
+
// `<button type="button">`, con `render` el elemento que se pase. Es la única fuente de esa lógica:
|
|
5
|
+
// la usan Button, IconButton, los FAB, los destinos de NavigationBar y NavigationRail
|
|
6
|
+
// (src/internal/navigation-item.tsx), CardPrimaryAction, ListItemAction y los chips de una acción
|
|
7
|
+
// (src/molecules/Chip/chip-element.tsx), y quien arme un control propio con StateLayer, FocusRing
|
|
8
|
+
// y Ripple. No trae estilos, átomos, estado activo ni reglas de deshabilitado: eso es de cada
|
|
9
|
+
// componente.
|
|
10
|
+
//
|
|
11
|
+
// cloneElement e isValidElement también existen en la versión de React para Server Components
|
|
12
|
+
// (react.react-server.js), así que esto corre en el servidor.
|
|
13
|
+
import { cloneElement, } from 'react';
|
|
14
|
+
import { assertRenderElement } from '../../internal/interactive.js';
|
|
15
|
+
// Une dos listas de clases; sin ninguna, `undefined` (el elemento queda sin `class`).
|
|
16
|
+
const joinClasses = (a, b) => (a && b ? `${a} ${b}` : a || b || undefined);
|
|
17
|
+
/**
|
|
18
|
+
* A control's interactive element: an `<a>`, a `<button>` or the `render` element. Use it as the
|
|
19
|
+
* base for your own controls that behave like matekit's: the `StateLayer`, `Ripple` and
|
|
20
|
+
* `FocusRing` atoms go as children and activate on their own with the element's pseudo-classes
|
|
21
|
+
* (`:hover`, `:focus-visible`, `:active`, `:disabled`). It adds no styles or atoms, and no active
|
|
22
|
+
* or disabled state: the control decides that. The control's CSS sets shape and color, and
|
|
23
|
+
* `outline: none` (`FocusRing` draws the ring; otherwise the browser adds its own).
|
|
24
|
+
*
|
|
25
|
+
* **The three forms** (ADR-0010, ADR-0020):
|
|
26
|
+
* - With `href`, a real `<a href>`: it opens in another tab, can be copied, and screen readers
|
|
27
|
+
* announce it as a link.
|
|
28
|
+
* - Without `href` or `render`, a `<button type="button">` (it doesn't submit forms;
|
|
29
|
+
* `type="submit"` does, if you pass it). `type={undefined}` also stays `"button"`.
|
|
30
|
+
* - With `render`, the element you pass, for example the Next.js or React Router `Link`, to
|
|
31
|
+
* navigate without reloading. `href` and `render` don't go together (the types reject it).
|
|
32
|
+
*
|
|
33
|
+
* **The `render` contract** (public API):
|
|
34
|
+
* - It takes an **element** (`render={<Link href="/" />}`), not a component (`render={Link}`):
|
|
35
|
+
* anything else throws an error that explains it.
|
|
36
|
+
* - It is cloned with `cloneElement`. It receives the other props of `Interactive` (attributes,
|
|
37
|
+
* `aria-*`, `data-*`, events, `ref`) and **its own props win**, including its `ref`: if both
|
|
38
|
+
* have one, the element's arrives (they are not combined, to avoid hooks in a universal atom).
|
|
39
|
+
* - Classes **are combined**: `Interactive`'s first, then the element's. If the element's
|
|
40
|
+
* `className` is a function of its state (React Router's `NavLink`), it is wrapped: the function
|
|
41
|
+
* receives the same arguments and its result is added to `Interactive`'s classes.
|
|
42
|
+
* - **Its children are replaced** by `Interactive`'s, without a warning.
|
|
43
|
+
* - The element must pass `className`, `aria-*`, `ref` and the children on to the `<a>` (or
|
|
44
|
+
* whatever it renders), as the Next.js and React Router `Link` do; otherwise matekit can't tell.
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* // A custom control: .my-control sets shape, color and `outline: none`; the atoms, the states.
|
|
48
|
+
* function MyControl({ className, children, ...props }: InteractiveProps) {
|
|
49
|
+
* return (
|
|
50
|
+
* <Interactive {...props} className={['my-control', className].filter(Boolean).join(' ')}>
|
|
51
|
+
* <StateLayer />
|
|
52
|
+
* <Ripple />
|
|
53
|
+
* <FocusRing />
|
|
54
|
+
* {children}
|
|
55
|
+
* </Interactive>
|
|
56
|
+
* )
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* <MyControl href="/help">Help</MyControl> // <a href="/help">
|
|
60
|
+
* <MyControl onClick={save}>Save</MyControl> // <button type="button">
|
|
61
|
+
* <MyControl render={<Link href="/orders" />}>Orders</MyControl> // the Next.js Link's <a>
|
|
62
|
+
* <MyControl render={<NavLink to="/orders" className={({ isActive }) => (isActive ? 'on' : '')} />}>
|
|
63
|
+
* Orders
|
|
64
|
+
* </MyControl> // React Router NavLink
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export function Interactive(props) {
|
|
68
|
+
const { render, className, children, ...rest } = props;
|
|
69
|
+
if (render !== undefined) {
|
|
70
|
+
assertRenderElement('Interactive', render);
|
|
71
|
+
const own = render.props;
|
|
72
|
+
// El NavLink de React Router acepta className como función de su estado: se respeta.
|
|
73
|
+
const ownClass = own.className;
|
|
74
|
+
const merged = typeof ownClass === 'function'
|
|
75
|
+
? (...args) => joinClasses(className, ownClass(...args))
|
|
76
|
+
: joinClasses(className, ownClass);
|
|
77
|
+
return cloneElement(render, { ...rest, ...own, className: merged, children });
|
|
78
|
+
}
|
|
79
|
+
if (rest.href !== undefined) {
|
|
80
|
+
const anchor = rest;
|
|
81
|
+
return (_jsx("a", { ...anchor, className: className, children: children }));
|
|
82
|
+
}
|
|
83
|
+
const button = rest;
|
|
84
|
+
// `type` explícitamente undefined también queda en "button" (si no, React lo omitiría y el
|
|
85
|
+
// botón enviaría el formulario).
|
|
86
|
+
return (_jsx("button", { ...button, type: button.type ?? 'button', className: className, children: children }));
|
|
87
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type HTMLAttributes } from 'react';
|
|
2
|
+
export interface RippleProps extends HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Material 3 ripple: on a pointer press, a circle grows from the contact point (500 ms) and fades
|
|
6
|
+
* out on release (200 ms). It does not appear with the keyboard; the state layer is enough there.
|
|
7
|
+
*
|
|
8
|
+
* Place it as a direct child of the interactive element; it listens to that parent's events. It
|
|
9
|
+
* does not activate if the parent is disabled or contains a disabled control as a direct child.
|
|
10
|
+
* With reduced motion, the ripple does not grow: it appears in full and fades out.
|
|
11
|
+
*
|
|
12
|
+
* Customization: `--mk-ripple-color`. Defaults to `currentColor`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function Ripple({ className, ...props }: RippleProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
// Átomo interactivo (ADR-0003): necesita la posición del puntero, así que corre en el cliente.
|
|
4
|
+
import { useEffect, useRef } from 'react';
|
|
5
|
+
const readToken = (el, name, fallback) => getComputedStyle(el).getPropertyValue(name).trim() || fallback;
|
|
6
|
+
const toMs = (value) => value.endsWith('ms') ? parseFloat(value) : value.endsWith('s') ? parseFloat(value) * 1000 : 0;
|
|
7
|
+
/**
|
|
8
|
+
* Material 3 ripple: on a pointer press, a circle grows from the contact point (500 ms) and fades
|
|
9
|
+
* out on release (200 ms). It does not appear with the keyboard; the state layer is enough there.
|
|
10
|
+
*
|
|
11
|
+
* Place it as a direct child of the interactive element; it listens to that parent's events. It
|
|
12
|
+
* does not activate if the parent is disabled or contains a disabled control as a direct child.
|
|
13
|
+
* With reduced motion, the ripple does not grow: it appears in full and fades out.
|
|
14
|
+
*
|
|
15
|
+
* Customization: `--mk-ripple-color`. Defaults to `currentColor`.
|
|
16
|
+
*/
|
|
17
|
+
export function Ripple({ className, ...props }) {
|
|
18
|
+
const ref = useRef(null);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const host = ref.current;
|
|
21
|
+
const target = host?.parentElement;
|
|
22
|
+
if (!host || !target)
|
|
23
|
+
return;
|
|
24
|
+
const onPointerDown = (event) => {
|
|
25
|
+
if (event.button !== 0)
|
|
26
|
+
return;
|
|
27
|
+
if (target.matches(':disabled, [aria-disabled="true"], :has(> :disabled)'))
|
|
28
|
+
return;
|
|
29
|
+
const rect = host.getBoundingClientRect();
|
|
30
|
+
const x = event.clientX - rect.left;
|
|
31
|
+
const y = event.clientY - rect.top;
|
|
32
|
+
// Radio hasta la esquina más lejana, para cubrir todo el elemento.
|
|
33
|
+
const radius = Math.hypot(Math.max(x, rect.width - x), Math.max(y, rect.height - y));
|
|
34
|
+
const wave = document.createElement('span');
|
|
35
|
+
wave.className = 'mk-ripple-wave';
|
|
36
|
+
wave.style.left = `${x - radius}px`;
|
|
37
|
+
wave.style.top = `${y - radius}px`;
|
|
38
|
+
wave.style.width = wave.style.height = `${radius * 2}px`;
|
|
39
|
+
host.append(wave);
|
|
40
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
41
|
+
wave.animate([{ transform: 'scale(0)' }, { transform: 'scale(1)' }], {
|
|
42
|
+
duration: reduced ? 0 : toMs(readToken(host, '--md-sys-motion-duration-long2', '500ms')),
|
|
43
|
+
easing: readToken(host, '--md-sys-motion-easing-emphasized-decelerate', 'ease-out'),
|
|
44
|
+
fill: 'forwards',
|
|
45
|
+
});
|
|
46
|
+
const release = () => {
|
|
47
|
+
window.removeEventListener('pointerup', release);
|
|
48
|
+
window.removeEventListener('pointercancel', release);
|
|
49
|
+
const fade = wave.animate([{ opacity: getComputedStyle(wave).opacity }, { opacity: 0 }], {
|
|
50
|
+
duration: toMs(readToken(host, '--md-sys-motion-duration-short4', '200ms')),
|
|
51
|
+
easing: readToken(host, '--md-sys-motion-easing-standard', 'ease'),
|
|
52
|
+
fill: 'forwards',
|
|
53
|
+
});
|
|
54
|
+
fade.onfinish = () => wave.remove();
|
|
55
|
+
};
|
|
56
|
+
window.addEventListener('pointerup', release);
|
|
57
|
+
window.addEventListener('pointercancel', release);
|
|
58
|
+
};
|
|
59
|
+
target.addEventListener('pointerdown', onPointerDown);
|
|
60
|
+
return () => target.removeEventListener('pointerdown', onPointerDown);
|
|
61
|
+
}, []);
|
|
62
|
+
return (_jsx("span", { ref: ref, "aria-hidden": "true", ...props, className: className ? `mk-ripple ${className}` : 'mk-ripple' }));
|
|
63
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HTMLAttributes, Ref } from 'react';
|
|
2
|
+
import type { ShapeName } from './shapes.ts';
|
|
3
|
+
export interface ShapeProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** One of the 35 decorative shapes of Material 3 Expressive (`SHAPES` lists them). */
|
|
5
|
+
shape: ShapeName;
|
|
6
|
+
/** Ref to the `<div>`. */
|
|
7
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Clips its content (an image, a color background, an icon) with one of the decorative shapes of
|
|
11
|
+
* Material 3 Expressive. The shape stretches to the element's size, as in Compose: on a square
|
|
12
|
+
* element it looks as in the kit.
|
|
13
|
+
*
|
|
14
|
+
* The clip is visual: the area that receives the pointer is still the element's rectangle. It is
|
|
15
|
+
* decoration: for a meaningful image, the `alt` goes on the image.
|
|
16
|
+
*
|
|
17
|
+
* Requires the optional `@matekit/react/shapes.css` stylesheet in addition to `styles.css`.
|
|
18
|
+
*
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <Shape shape="cookie-9-sided" style={{ width: 96, height: 96 }}><img src="…" alt="Ana" /></Shape>
|
|
21
|
+
* <Shape shape="sunny" className="icon-bg"><StarIcon /></Shape>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function Shape({ shape, className, children, ...props }: ShapeProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Clips its content (an image, a color background, an icon) with one of the decorative shapes of
|
|
4
|
+
* Material 3 Expressive. The shape stretches to the element's size, as in Compose: on a square
|
|
5
|
+
* element it looks as in the kit.
|
|
6
|
+
*
|
|
7
|
+
* The clip is visual: the area that receives the pointer is still the element's rectangle. It is
|
|
8
|
+
* decoration: for a meaningful image, the `alt` goes on the image.
|
|
9
|
+
*
|
|
10
|
+
* Requires the optional `@matekit/react/shapes.css` stylesheet in addition to `styles.css`.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <Shape shape="cookie-9-sided" style={{ width: 96, height: 96 }}><img src="…" alt="Ana" /></Shape>
|
|
14
|
+
* <Shape shape="sunny" className="icon-bg"><StarIcon /></Shape>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function Shape({ shape, className, children, ...props }) {
|
|
18
|
+
return (_jsx("div", { ...props, className: className ? `mk-shape ${className}` : 'mk-shape', "data-shape": shape, children: children }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Name of one of the 35 Material 3 Expressive decorative shapes. */
|
|
2
|
+
export type ShapeName = 'circle' | 'square' | 'slanted' | 'arch' | 'fan' | 'arrow' | 'semi-circle' | 'oval' | 'pill' | 'triangle' | 'diamond' | 'clam-shell' | 'pentagon' | 'gem' | 'very-sunny' | 'sunny' | 'cookie-4-sided' | 'cookie-6-sided' | 'cookie-7-sided' | 'cookie-9-sided' | 'cookie-12-sided' | 'ghostish' | 'clover-4-leaf' | 'clover-8-leaf' | 'burst' | 'soft-burst' | 'boom' | 'soft-boom' | 'flower' | 'puffy' | 'puffy-diamond' | 'pixel-circle' | 'pixel-triangle' | 'bun' | 'heart';
|
|
3
|
+
/** The 35 shapes, in the kit's order, with their kit and Compose names (for catalogs and tests). */
|
|
4
|
+
export declare const SHAPES: ReadonlyArray<{
|
|
5
|
+
name: ShapeName;
|
|
6
|
+
label: string;
|
|
7
|
+
compose: string;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Generado por scripts/build-shapes.ts. No editar a mano.
|
|
2
|
+
// Fuente: androidx/androidx@b842c5b3a5, compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/MaterialShapes.kt
|
|
3
|
+
/** The 35 shapes, in the kit's order, with their kit and Compose names (for catalogs and tests). */
|
|
4
|
+
export const SHAPES = [
|
|
5
|
+
{ name: 'circle', label: 'Circle', compose: 'Circle' },
|
|
6
|
+
{ name: 'square', label: 'Square', compose: 'Square' },
|
|
7
|
+
{ name: 'slanted', label: 'Slanted', compose: 'Slanted' },
|
|
8
|
+
{ name: 'arch', label: 'Arch', compose: 'Arch' },
|
|
9
|
+
{ name: 'fan', label: 'Fan', compose: 'Fan' },
|
|
10
|
+
{ name: 'arrow', label: 'Arrow', compose: 'Arrow' },
|
|
11
|
+
{ name: 'semi-circle', label: 'Semicircle', compose: 'SemiCircle' },
|
|
12
|
+
{ name: 'oval', label: 'Oval', compose: 'Oval' },
|
|
13
|
+
{ name: 'pill', label: 'Pill', compose: 'Pill' },
|
|
14
|
+
{ name: 'triangle', label: 'Triangle', compose: 'Triangle' },
|
|
15
|
+
{ name: 'diamond', label: 'Diamond', compose: 'Diamond' },
|
|
16
|
+
{ name: 'clam-shell', label: 'Clamshell', compose: 'ClamShell' },
|
|
17
|
+
{ name: 'pentagon', label: 'Pentagon', compose: 'Pentagon' },
|
|
18
|
+
{ name: 'gem', label: 'Gem', compose: 'Gem' },
|
|
19
|
+
{ name: 'very-sunny', label: 'Very sunny', compose: 'VerySunny' },
|
|
20
|
+
{ name: 'sunny', label: 'Sunny', compose: 'Sunny' },
|
|
21
|
+
{ name: 'cookie-4-sided', label: '4-sided cookie', compose: 'Cookie4Sided' },
|
|
22
|
+
{ name: 'cookie-6-sided', label: '6-sided cookie', compose: 'Cookie6Sided' },
|
|
23
|
+
{ name: 'cookie-7-sided', label: '7-sided cookie', compose: 'Cookie7Sided' },
|
|
24
|
+
{ name: 'cookie-9-sided', label: '9-sided cookie', compose: 'Cookie9Sided' },
|
|
25
|
+
{ name: 'cookie-12-sided', label: '12-sided cookie', compose: 'Cookie12Sided' },
|
|
26
|
+
{ name: 'ghostish', label: 'Ghost-ish', compose: 'Ghostish' },
|
|
27
|
+
{ name: 'clover-4-leaf', label: '4-leaf clover', compose: 'Clover4Leaf' },
|
|
28
|
+
{ name: 'clover-8-leaf', label: '8-leaf clover', compose: 'Clover8Leaf' },
|
|
29
|
+
{ name: 'burst', label: 'Burst', compose: 'Burst' },
|
|
30
|
+
{ name: 'soft-burst', label: 'Soft burst', compose: 'SoftBurst' },
|
|
31
|
+
{ name: 'boom', label: 'Boom', compose: 'Boom' },
|
|
32
|
+
{ name: 'soft-boom', label: 'Soft boom', compose: 'SoftBoom' },
|
|
33
|
+
{ name: 'flower', label: 'Flower', compose: 'Flower' },
|
|
34
|
+
{ name: 'puffy', label: 'Puffy', compose: 'Puffy' },
|
|
35
|
+
{ name: 'puffy-diamond', label: 'Puffy diamond', compose: 'PuffyDiamond' },
|
|
36
|
+
{ name: 'pixel-circle', label: 'Pixel circle', compose: 'PixelCircle' },
|
|
37
|
+
{ name: 'pixel-triangle', label: 'Pixel triangle', compose: 'PixelTriangle' },
|
|
38
|
+
{ name: 'bun', label: 'Bun', compose: 'Bun' },
|
|
39
|
+
{ name: 'heart', label: 'Heart', compose: 'Heart' },
|
|
40
|
+
];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type LayoutElementProps } from '../../internal/layout-element.tsx';
|
|
2
|
+
import type { SpaceStep } from '../../tokens/space.ts';
|
|
3
|
+
export type StackDirection = 'row' | 'column';
|
|
4
|
+
/** `align-items`: in a column, the horizontal axis; in a row, the vertical one. */
|
|
5
|
+
export type StackAlign = 'start' | 'center' | 'end' | 'stretch' | 'baseline';
|
|
6
|
+
/** `justify-content`: `between`, `around` and `evenly` are `space-between`, `space-around` and `space-evenly`. */
|
|
7
|
+
export type StackJustify = 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';
|
|
8
|
+
interface StackOwnProps {
|
|
9
|
+
/**
|
|
10
|
+
* Gap between children (`gap`), as a step of the Material 3 scale: `gap={200}` is
|
|
11
|
+
* `--md-sys-space-200`, 16 px. The number is the token's (hundredths of 8), not px: the types
|
|
12
|
+
* only accept the 18 steps. When undefined, 0 (as in CSS).
|
|
13
|
+
*/
|
|
14
|
+
gap?: SpaceStep | undefined;
|
|
15
|
+
/** Alignment on the cross axis (`align-items`). When undefined, the CSS default: `stretch`. */
|
|
16
|
+
align?: StackAlign | undefined;
|
|
17
|
+
/** Distribution on the main axis (`justify-content`). When undefined, the CSS default: at the start. */
|
|
18
|
+
justify?: StackJustify | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** Fixed direction. */
|
|
21
|
+
interface StackFixedProps {
|
|
22
|
+
/** Column or row. Both follow the text direction (RTL). Defaults to `column`. */
|
|
23
|
+
direction?: StackDirection | undefined;
|
|
24
|
+
/** Lets children wrap to the next line when they don't fit (`flex-wrap: wrap`). Defaults to `false`. */
|
|
25
|
+
wrap?: boolean | undefined;
|
|
26
|
+
switchAt?: undefined;
|
|
27
|
+
}
|
|
28
|
+
/** Direction by available space (the "switcher" pattern). */
|
|
29
|
+
interface StackSwitchProps {
|
|
30
|
+
/**
|
|
31
|
+
* Width of the Stack (a CSS length, preferably in rem: `"30rem"`) from which the children go in
|
|
32
|
+
* a row, sharing the width equally; below it, in a column, each at full width. It measures the
|
|
33
|
+
* Stack itself (the space its container gives it), not the window, and needs no extra
|
|
34
|
+
* container. Stored in `--mk-stack-switch-at`.
|
|
35
|
+
*/
|
|
36
|
+
switchAt: string;
|
|
37
|
+
direction?: undefined;
|
|
38
|
+
wrap?: undefined;
|
|
39
|
+
}
|
|
40
|
+
export type StackProps = LayoutElementProps & StackOwnProps & (StackFixedProps | StackSwitchProps);
|
|
41
|
+
/**
|
|
42
|
+
* Stack: the children in a column or a row with `display: flex`, separated by a step of the
|
|
43
|
+
* spacing scale. It is a thin layer over flex (ADR-0017): anything not here is written in CSS with
|
|
44
|
+
* `className` or `style`.
|
|
45
|
+
*
|
|
46
|
+
* To make a child take the leftover space (Compose's `weight`), give it
|
|
47
|
+
* `style={{ flex: 1, minInlineSize: 0 }}` (or the same in its CSS): `flex: 1` shares the leftover
|
|
48
|
+
* and `minInlineSize: 0` lets it shrink below its content.
|
|
49
|
+
*
|
|
50
|
+
* ```tsx
|
|
51
|
+
* <Stack gap={200}>…</Stack>
|
|
52
|
+
* <Stack direction="row" gap={100} align="center" wrap>…</Stack>
|
|
53
|
+
* <Stack switchAt="30rem" gap={150}>…</Stack>
|
|
54
|
+
* <Stack render={<ul />} gap={100}>…<li /></Stack>
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function Stack({ direction, wrap, switchAt, gap, align, justify, className, style, children, ...props }: StackProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Átomo universal (ADR-0003): sin estado, efectos, contexto ni eventos; no lleva 'use client'.
|
|
2
|
+
// API y motivos: ADR-0017.
|
|
3
|
+
import { cx } from '../../internal/interactive.js';
|
|
4
|
+
import { layoutElement } from '../../internal/layout-element.js';
|
|
5
|
+
/**
|
|
6
|
+
* Stack: the children in a column or a row with `display: flex`, separated by a step of the
|
|
7
|
+
* spacing scale. It is a thin layer over flex (ADR-0017): anything not here is written in CSS with
|
|
8
|
+
* `className` or `style`.
|
|
9
|
+
*
|
|
10
|
+
* To make a child take the leftover space (Compose's `weight`), give it
|
|
11
|
+
* `style={{ flex: 1, minInlineSize: 0 }}` (or the same in its CSS): `flex: 1` shares the leftover
|
|
12
|
+
* and `minInlineSize: 0` lets it shrink below its content.
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Stack gap={200}>…</Stack>
|
|
16
|
+
* <Stack direction="row" gap={100} align="center" wrap>…</Stack>
|
|
17
|
+
* <Stack switchAt="30rem" gap={150}>…</Stack>
|
|
18
|
+
* <Stack render={<ul />} gap={100}>…<li /></Stack>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function Stack({ direction, wrap, switchAt, gap, align, justify, className, style, children, ...props }) {
|
|
22
|
+
const switching = switchAt !== undefined;
|
|
23
|
+
const ownStyle = switching ? { '--mk-stack-switch-at': switchAt } : undefined;
|
|
24
|
+
return layoutElement('Stack', cx('mk-stack', className), ownStyle || style ? { ...ownStyle, ...style } : undefined, {
|
|
25
|
+
...props,
|
|
26
|
+
'data-direction': switching ? undefined : direction === 'row' ? 'row' : undefined,
|
|
27
|
+
'data-wrap': wrap ? '' : undefined,
|
|
28
|
+
'data-switch': switching ? '' : undefined,
|
|
29
|
+
'data-gap': gap === undefined ? undefined : String(gap),
|
|
30
|
+
'data-align': align,
|
|
31
|
+
'data-justify': justify,
|
|
32
|
+
}, children);
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
export interface StateLayerProps extends HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Material 3 state layer: an overlay in the content color that becomes visible on hover (8 %),
|
|
6
|
+
* keyboard focus (10 %) and press (10 %).
|
|
7
|
+
*
|
|
8
|
+
* Place it as a direct child of the interactive element; it reacts to that parent's states and
|
|
9
|
+
* inherits its border radius. It is not shown if the parent is disabled or contains a disabled
|
|
10
|
+
* control as a direct child (for example a hidden `<input>`).
|
|
11
|
+
*
|
|
12
|
+
* Customization with CSS variables:
|
|
13
|
+
* - `--mk-state-layer-color`: layer color. Defaults to `currentColor`.
|
|
14
|
+
* - `--mk-state-layer-opacity`: resting opacity; use it to show a state when the element that
|
|
15
|
+
* receives the pointer or focus is not the direct parent.
|
|
16
|
+
*/
|
|
17
|
+
export declare function StateLayer({ className, ...props }: StateLayerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Material 3 state layer: an overlay in the content color that becomes visible on hover (8 %),
|
|
4
|
+
* keyboard focus (10 %) and press (10 %).
|
|
5
|
+
*
|
|
6
|
+
* Place it as a direct child of the interactive element; it reacts to that parent's states and
|
|
7
|
+
* inherits its border radius. It is not shown if the parent is disabled or contains a disabled
|
|
8
|
+
* control as a direct child (for example a hidden `<input>`).
|
|
9
|
+
*
|
|
10
|
+
* Customization with CSS variables:
|
|
11
|
+
* - `--mk-state-layer-color`: layer color. Defaults to `currentColor`.
|
|
12
|
+
* - `--mk-state-layer-opacity`: resting opacity; use it to show a state when the element that
|
|
13
|
+
* receives the pointer or focus is not the direct parent.
|
|
14
|
+
*/
|
|
15
|
+
export function StateLayer({ className, ...props }) {
|
|
16
|
+
return (_jsx("span", { "aria-hidden": "true", ...props, className: className ? `mk-state-layer ${className}` : 'mk-state-layer' }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { Icon, type IconProps } from './Icon/Icon.tsx';
|
|
2
|
+
export { StateLayer, type StateLayerProps } from './StateLayer/StateLayer.tsx';
|
|
3
|
+
export { FocusRing, type FocusRingProps } from './FocusRing/FocusRing.tsx';
|
|
4
|
+
export { Ripple, type RippleProps } from './Ripple/Ripple.tsx';
|
|
5
|
+
export { Interactive, type InteractiveProps } from './Interactive/Interactive.tsx';
|
|
6
|
+
export { Shape, type ShapeProps } from './Shape/Shape.tsx';
|
|
7
|
+
export { SHAPES, type ShapeName } from './Shape/shapes.ts';
|
|
8
|
+
export { Divider, DividerSubhead, type DividerProps, type DividerSubheadProps, type DividerOrientation, type DividerInset, } from './Divider/Divider.tsx';
|
|
9
|
+
export { Stack, type StackProps, type StackDirection, type StackAlign, type StackJustify, } from './Stack/Stack.tsx';
|
|
10
|
+
export { Group, type GroupProps, type GroupOrientation } from './Group/Group.tsx';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { Icon } from './Icon/Icon.js';
|
|
2
|
+
export { StateLayer } from './StateLayer/StateLayer.js';
|
|
3
|
+
export { FocusRing } from './FocusRing/FocusRing.js';
|
|
4
|
+
export { Ripple } from './Ripple/Ripple.js';
|
|
5
|
+
export { Interactive } from './Interactive/Interactive.js';
|
|
6
|
+
export { Shape } from './Shape/Shape.js';
|
|
7
|
+
export { SHAPES } from './Shape/shapes.js';
|
|
8
|
+
export { Divider, DividerSubhead, } from './Divider/Divider.js';
|
|
9
|
+
export { Stack, } from './Stack/Stack.js';
|
|
10
|
+
export { Group } from './Group/Group.js';
|