@kcascend/liquid-ui 0.0.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/README.md +64 -0
- package/dist/components/Accordion/Accordion.d.ts +3 -0
- package/dist/components/Accordion/Accordion.d.ts.map +1 -0
- package/dist/components/Accordion/Accordion.js +46 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +3 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts.map +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +34 -0
- package/dist/components/Button/Button.d.ts +3 -0
- package/dist/components/Button/Button.d.ts.map +1 -0
- package/dist/components/Button/Button.js +7 -0
- package/dist/components/Card/Card.d.ts +3 -0
- package/dist/components/Card/Card.d.ts.map +1 -0
- package/dist/components/Card/Card.js +19 -0
- package/dist/components/Checkbox/Checkbox.d.ts +3 -0
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox/Checkbox.js +17 -0
- package/dist/components/ContainedList/ContainedList.d.ts +3 -0
- package/dist/components/ContainedList/ContainedList.d.ts.map +1 -0
- package/dist/components/ContainedList/ContainedList.js +26 -0
- package/dist/components/DataTable/DataTable.d.ts +3 -0
- package/dist/components/DataTable/DataTable.d.ts.map +1 -0
- package/dist/components/DataTable/DataTable.js +20 -0
- package/dist/components/DescriptionList/DescriptionList.d.ts +3 -0
- package/dist/components/DescriptionList/DescriptionList.d.ts.map +1 -0
- package/dist/components/DescriptionList/DescriptionList.js +14 -0
- package/dist/components/Form/Form.d.ts +5 -0
- package/dist/components/Form/Form.d.ts.map +1 -0
- package/dist/components/Form/Form.js +32 -0
- package/dist/components/GridLayout/GridLayout.d.ts +4 -0
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -0
- package/dist/components/GridLayout/GridLayout.js +138 -0
- package/dist/components/GridLayout/gridTokens.d.ts +18 -0
- package/dist/components/GridLayout/gridTokens.d.ts.map +1 -0
- package/dist/components/GridLayout/gridTokens.js +91 -0
- package/dist/components/Icon/Icon.d.ts +11 -0
- package/dist/components/Icon/Icon.d.ts.map +1 -0
- package/dist/components/Icon/Icon.js +25 -0
- package/dist/components/Icon/icons.d.ts +21 -0
- package/dist/components/Icon/icons.d.ts.map +1 -0
- package/dist/components/Icon/icons.js +20 -0
- package/dist/components/Icon/index.d.ts +3 -0
- package/dist/components/Icon/index.d.ts.map +1 -0
- package/dist/components/Icon/index.js +1 -0
- package/dist/components/Icons/Icons.d.ts +3 -0
- package/dist/components/Icons/Icons.d.ts.map +1 -0
- package/dist/components/Icons/Icons.js +1 -0
- package/dist/components/Index/Index.d.ts +3 -0
- package/dist/components/Index/Index.d.ts.map +1 -0
- package/dist/components/Index/Index.js +114 -0
- package/dist/components/InlineNotification/InlineNotification.d.ts +3 -0
- package/dist/components/InlineNotification/InlineNotification.d.ts.map +1 -0
- package/dist/components/InlineNotification/InlineNotification.js +47 -0
- package/dist/components/Link/Link.d.ts +3 -0
- package/dist/components/Link/Link.d.ts.map +1 -0
- package/dist/components/Link/Link.js +23 -0
- package/dist/components/Modal/Modal.d.ts +3 -0
- package/dist/components/Modal/Modal.d.ts.map +1 -0
- package/dist/components/Modal/Modal.js +27 -0
- package/dist/components/Pagination/Pagination.d.ts +3 -0
- package/dist/components/Pagination/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination/Pagination.js +34 -0
- package/dist/components/Radio/Radio.d.ts +3 -0
- package/dist/components/Radio/Radio.d.ts.map +1 -0
- package/dist/components/Radio/Radio.js +13 -0
- package/dist/components/SearchInput/SearchInput.d.ts +3 -0
- package/dist/components/SearchInput/SearchInput.d.ts.map +1 -0
- package/dist/components/SearchInput/SearchInput.js +37 -0
- package/dist/components/SelectInput/SelectInput.d.ts +3 -0
- package/dist/components/SelectInput/SelectInput.d.ts.map +1 -0
- package/dist/components/SelectInput/SelectInput.js +14 -0
- package/dist/components/StructuredList/StructuredList.d.ts +3 -0
- package/dist/components/StructuredList/StructuredList.d.ts.map +1 -0
- package/dist/components/StructuredList/StructuredList.js +17 -0
- package/dist/components/Tabs/Tabs.d.ts +3 -0
- package/dist/components/Tabs/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs/Tabs.js +27 -0
- package/dist/components/Tag/Tag.d.ts +3 -0
- package/dist/components/Tag/Tag.d.ts.map +1 -0
- package/dist/components/Tag/Tag.js +8 -0
- package/dist/components/TextArea/TextArea.d.ts +3 -0
- package/dist/components/TextArea/TextArea.d.ts.map +1 -0
- package/dist/components/TextArea/TextArea.js +15 -0
- package/dist/components/TextInput/TextInput.d.ts +3 -0
- package/dist/components/TextInput/TextInput.d.ts.map +1 -0
- package/dist/components/TextInput/TextInput.js +20 -0
- package/dist/components/ToggleInput/ToggleInput.d.ts +3 -0
- package/dist/components/ToggleInput/ToggleInput.d.ts.map +1 -0
- package/dist/components/ToggleInput/ToggleInput.js +10 -0
- package/dist/components/Tooltip/Tooltip.d.ts +3 -0
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip/Tooltip.js +13 -0
- package/dist/generated/tokens.d.ts +9836 -0
- package/dist/generated/tokens.d.ts.map +1 -0
- package/dist/generated/tokens.js +9834 -0
- package/dist/governance/accordionGovernance.d.ts +3 -0
- package/dist/governance/accordionGovernance.d.ts.map +1 -0
- package/dist/governance/accordionGovernance.js +9 -0
- package/dist/governance/breadcrumbGovernance.d.ts +3 -0
- package/dist/governance/breadcrumbGovernance.d.ts.map +1 -0
- package/dist/governance/breadcrumbGovernance.js +9 -0
- package/dist/governance/buttonGovernance.d.ts +3 -0
- package/dist/governance/buttonGovernance.d.ts.map +1 -0
- package/dist/governance/buttonGovernance.js +9 -0
- package/dist/governance/cardGovernance.d.ts +3 -0
- package/dist/governance/cardGovernance.d.ts.map +1 -0
- package/dist/governance/cardGovernance.js +9 -0
- package/dist/governance/checkboxGovernance.d.ts +3 -0
- package/dist/governance/checkboxGovernance.d.ts.map +1 -0
- package/dist/governance/checkboxGovernance.js +10 -0
- package/dist/governance/containedListGovernance.d.ts +3 -0
- package/dist/governance/containedListGovernance.d.ts.map +1 -0
- package/dist/governance/containedListGovernance.js +9 -0
- package/dist/governance/dataTableGovernance.d.ts +3 -0
- package/dist/governance/dataTableGovernance.d.ts.map +1 -0
- package/dist/governance/dataTableGovernance.js +10 -0
- package/dist/governance/descriptionListGovernance.d.ts +3 -0
- package/dist/governance/descriptionListGovernance.d.ts.map +1 -0
- package/dist/governance/descriptionListGovernance.js +9 -0
- package/dist/governance/formGovernance.d.ts +3 -0
- package/dist/governance/formGovernance.d.ts.map +1 -0
- package/dist/governance/formGovernance.js +9 -0
- package/dist/governance/gridLayoutGovernance.d.ts +3 -0
- package/dist/governance/gridLayoutGovernance.d.ts.map +1 -0
- package/dist/governance/gridLayoutGovernance.js +9 -0
- package/dist/governance/indexGovernance.d.ts +3 -0
- package/dist/governance/indexGovernance.d.ts.map +1 -0
- package/dist/governance/indexGovernance.js +9 -0
- package/dist/governance/inlineNotificationGovernance.d.ts +3 -0
- package/dist/governance/inlineNotificationGovernance.d.ts.map +1 -0
- package/dist/governance/inlineNotificationGovernance.js +9 -0
- package/dist/governance/linkGovernance.d.ts +3 -0
- package/dist/governance/linkGovernance.d.ts.map +1 -0
- package/dist/governance/linkGovernance.js +9 -0
- package/dist/governance/modalGovernance.d.ts +3 -0
- package/dist/governance/modalGovernance.d.ts.map +1 -0
- package/dist/governance/modalGovernance.js +10 -0
- package/dist/governance/paginationGovernance.d.ts +3 -0
- package/dist/governance/paginationGovernance.d.ts.map +1 -0
- package/dist/governance/paginationGovernance.js +10 -0
- package/dist/governance/radioGovernance.d.ts +3 -0
- package/dist/governance/radioGovernance.d.ts.map +1 -0
- package/dist/governance/radioGovernance.js +10 -0
- package/dist/governance/searchInputGovernance.d.ts +3 -0
- package/dist/governance/searchInputGovernance.d.ts.map +1 -0
- package/dist/governance/searchInputGovernance.js +10 -0
- package/dist/governance/selectInputGovernance.d.ts +3 -0
- package/dist/governance/selectInputGovernance.d.ts.map +1 -0
- package/dist/governance/selectInputGovernance.js +10 -0
- package/dist/governance/structuredListGovernance.d.ts +3 -0
- package/dist/governance/structuredListGovernance.d.ts.map +1 -0
- package/dist/governance/structuredListGovernance.js +9 -0
- package/dist/governance/tabsGovernance.d.ts +3 -0
- package/dist/governance/tabsGovernance.d.ts.map +1 -0
- package/dist/governance/tabsGovernance.js +10 -0
- package/dist/governance/tagGovernance.d.ts +3 -0
- package/dist/governance/tagGovernance.d.ts.map +1 -0
- package/dist/governance/tagGovernance.js +10 -0
- package/dist/governance/textAreaGovernance.d.ts +3 -0
- package/dist/governance/textAreaGovernance.d.ts.map +1 -0
- package/dist/governance/textAreaGovernance.js +10 -0
- package/dist/governance/textInputGovernance.d.ts +3 -0
- package/dist/governance/textInputGovernance.d.ts.map +1 -0
- package/dist/governance/textInputGovernance.js +10 -0
- package/dist/governance/toggleInputGovernance.d.ts +3 -0
- package/dist/governance/toggleInputGovernance.d.ts.map +1 -0
- package/dist/governance/toggleInputGovernance.js +10 -0
- package/dist/governance/tooltipGovernance.d.ts +3 -0
- package/dist/governance/tooltipGovernance.d.ts.map +1 -0
- package/dist/governance/tooltipGovernance.js +10 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/styles.css +4426 -0
- package/dist/tokens/components.css +559 -0
- package/dist/tokens/primitives.css +179 -0
- package/dist/tokens/semantic.css +376 -0
- package/dist/types.d.ts +336 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Liquid UI Package
|
|
2
|
+
|
|
3
|
+
`@kcascend/liquid-ui` is the reusable UI package for Liquid Design System consumers.
|
|
4
|
+
|
|
5
|
+
## Local development
|
|
6
|
+
|
|
7
|
+
1. Run `npm install` from the repository root to install the local file dependency.
|
|
8
|
+
2. Run `npm run build:ui` to rebuild the package outputs in `packages/liquid-ui/dist`.
|
|
9
|
+
3. Run `npm run storybook` to rebuild the package and launch Storybook against the package boundary.
|
|
10
|
+
|
|
11
|
+
## Grid usage
|
|
12
|
+
|
|
13
|
+
The package exposes a grid primitive through `GridLayout` and `GridColumn`.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { GridColumn, GridLayout } from '@kcascend/liquid-ui';
|
|
17
|
+
|
|
18
|
+
export function Example() {
|
|
19
|
+
return (
|
|
20
|
+
<GridLayout as="div">
|
|
21
|
+
<GridColumn sm={4} md={4} lg={8}>
|
|
22
|
+
Primary
|
|
23
|
+
</GridColumn>
|
|
24
|
+
<GridColumn sm={2} md={2} lg={4}>
|
|
25
|
+
Secondary A
|
|
26
|
+
</GridColumn>
|
|
27
|
+
<GridColumn sm={2} md={2} lg={4}>
|
|
28
|
+
Secondary B
|
|
29
|
+
</GridColumn>
|
|
30
|
+
</GridLayout>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Supported layout features:
|
|
36
|
+
|
|
37
|
+
- Responsive spans through `sm`, `md`, `lg`, `xlg`, and `max`.
|
|
38
|
+
- Offset columns with object values like `md={{ span: 4, offset: 2 }}`.
|
|
39
|
+
- Gutter modes with `narrow` and `condensed`.
|
|
40
|
+
- `withRowGap` to keep vertical spacing aligned with the active gutter.
|
|
41
|
+
- `fullWidth` for viewport-spanning layouts.
|
|
42
|
+
- `subgrid` for nested grids that inherit the parent column scaffold.
|
|
43
|
+
- Auto columns when a `GridColumn` is rendered without explicit breakpoint props.
|
|
44
|
+
|
|
45
|
+
## Figma governance
|
|
46
|
+
|
|
47
|
+
Every reusable component must record an approved Figma reference in story metadata or component documentation before it is considered ready for review. The initial workflow example in this package uses the Liquid token source in Figma:
|
|
48
|
+
|
|
49
|
+
- https://www.figma.com/design/QOtgMJzWSuF5XOLrlw151c/Liquid-DS---00-Tokens?node-id=5-110&p=f&m=dev
|
|
50
|
+
- https://www.figma.com/design/a9SMb2IjyRedfsaUMGXIyP/Liquid-DS---01-Components?node-id=2-2299&m=dev
|
|
51
|
+
|
|
52
|
+
Storybook now demonstrates both patterns:
|
|
53
|
+
|
|
54
|
+
- a package-consumed button component with Figma and accessibility metadata
|
|
55
|
+
- a token values reference story that reads directly from the generated `tokens` export
|
|
56
|
+
|
|
57
|
+
## Accessibility verification
|
|
58
|
+
|
|
59
|
+
Each component review must include:
|
|
60
|
+
|
|
61
|
+
- Keyboard interaction expectations when the component is interactive.
|
|
62
|
+
- Name, role, and state guidance for assistive technologies.
|
|
63
|
+
- Color contrast and focus treatment verification.
|
|
64
|
+
- Storybook documentation that explains any usage constraints needed to stay WCAG 2.1 aligned.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AccordionProps } from '../../types';
|
|
2
|
+
export declare function Accordion({ allowMultiple, className, defaultOpenItemIds, items, onOpenChange, openItemIds, style, ...props }: AccordionProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=Accordion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../src/components/Accordion/Accordion.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,aAAa,CAAC;AA2BjE,wBAAgB,SAAS,CAAC,EACxB,aAAqB,EACrB,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,YAAY,EACZ,WAAW,EACX,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,2CA4EhB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
|
+
import { Icon } from '../Icon/Icon';
|
|
4
|
+
function getClassName(className) {
|
|
5
|
+
return ['liquid-accordion', className].filter(Boolean).join(' ');
|
|
6
|
+
}
|
|
7
|
+
function getItemClassName(item, isOpen) {
|
|
8
|
+
return [
|
|
9
|
+
'liquid-accordion__item',
|
|
10
|
+
isOpen ? 'liquid-accordion__item--open' : '',
|
|
11
|
+
item.disabled ? 'liquid-accordion__item--disabled' : '',
|
|
12
|
+
]
|
|
13
|
+
.filter(Boolean)
|
|
14
|
+
.join(' ');
|
|
15
|
+
}
|
|
16
|
+
function getDefaultOpenItemIds(defaultOpenItemIds, allowMultiple) {
|
|
17
|
+
if (!defaultOpenItemIds || defaultOpenItemIds.length === 0) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
return allowMultiple ? defaultOpenItemIds : [defaultOpenItemIds[0]];
|
|
21
|
+
}
|
|
22
|
+
export function Accordion({ allowMultiple = false, className, defaultOpenItemIds, items, onOpenChange, openItemIds, style, ...props }) {
|
|
23
|
+
const initialOpenIds = useMemo(() => getDefaultOpenItemIds(defaultOpenItemIds, allowMultiple), [defaultOpenItemIds, allowMultiple]);
|
|
24
|
+
const [internalOpenIds, setInternalOpenIds] = useState(initialOpenIds);
|
|
25
|
+
const resolvedOpenIds = openItemIds ?? internalOpenIds;
|
|
26
|
+
const toggleItem = (itemId) => {
|
|
27
|
+
const isOpen = resolvedOpenIds.includes(itemId);
|
|
28
|
+
const nextOpenIds = isOpen
|
|
29
|
+
? resolvedOpenIds.filter((id) => id !== itemId)
|
|
30
|
+
: allowMultiple
|
|
31
|
+
? [...resolvedOpenIds, itemId]
|
|
32
|
+
: [itemId];
|
|
33
|
+
if (openItemIds === undefined) {
|
|
34
|
+
setInternalOpenIds(nextOpenIds);
|
|
35
|
+
}
|
|
36
|
+
onOpenChange?.(nextOpenIds);
|
|
37
|
+
};
|
|
38
|
+
return (_jsx("section", { ...props, className: getClassName(className), style: style, children: items.map((item) => {
|
|
39
|
+
const isOpen = resolvedOpenIds.includes(item.id);
|
|
40
|
+
const panelId = `${item.id}-panel`;
|
|
41
|
+
const triggerId = `${item.id}-trigger`;
|
|
42
|
+
return (_jsxs("article", { className: getItemClassName(item, isOpen), children: [_jsx("h3", { className: "liquid-accordion__heading", children: _jsxs("button", { id: triggerId, "aria-controls": panelId, "aria-expanded": isOpen, className: "liquid-accordion__trigger", disabled: item.disabled, "data-open": isOpen || undefined, type: "button", onClick: () => {
|
|
43
|
+
toggleItem(item.id);
|
|
44
|
+
}, children: [_jsx("span", { className: "liquid-accordion__title", children: item.title }), _jsx("span", { className: "liquid-accordion__icon", "aria-hidden": "true", children: _jsx(Icon, { name: "chevron_down", size: 20 }) })] }) }), _jsx("div", { id: panelId, "aria-labelledby": triggerId, className: "liquid-accordion__panel", hidden: !isOpen, role: "region", children: _jsx("div", { className: "liquid-accordion__text-margin", children: _jsx("div", { className: "liquid-accordion__content", children: item.content }) }) })] }, item.id));
|
|
45
|
+
}) }));
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Breadcrumb.d.ts","sourceRoot":"","sources":["../../../src/components/Breadcrumb/Breadcrumb.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,aAAa,CAAC;AA0BnE,wBAAgB,UAAU,CAAC,EACzB,SAAwB,EACxB,SAAS,EACT,KAAK,EACL,UAAU,EACV,SAAe,EACf,KAAK,EACL,GAAG,KAAK,EACT,EAAE,eAAe,2CA+DjB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
function getClassName(className) {
|
|
3
|
+
return ['liquid-breadcrumb', className].filter(Boolean).join(' ');
|
|
4
|
+
}
|
|
5
|
+
function getItemClassName(className, isCurrent) {
|
|
6
|
+
return [
|
|
7
|
+
'liquid-breadcrumb__item',
|
|
8
|
+
isCurrent ? 'liquid-breadcrumb__item--current' : '',
|
|
9
|
+
className,
|
|
10
|
+
]
|
|
11
|
+
.filter(Boolean)
|
|
12
|
+
.join(' ');
|
|
13
|
+
}
|
|
14
|
+
function getVisibleItems(items) {
|
|
15
|
+
return items.filter((item) => item.label !== null && item.label !== undefined);
|
|
16
|
+
}
|
|
17
|
+
function isCurrentItem(index, itemCount) {
|
|
18
|
+
return index === itemCount - 1;
|
|
19
|
+
}
|
|
20
|
+
export function Breadcrumb({ ariaLabel = 'Breadcrumb', className, items, onNavigate, separator = '/', style, ...props }) {
|
|
21
|
+
const visibleItems = getVisibleItems(items);
|
|
22
|
+
return (_jsx("nav", { ...props, "aria-label": ariaLabel, className: getClassName(className), style: style, children: _jsx("ol", { className: "liquid-breadcrumb__list", children: visibleItems.map((item, itemIndex) => {
|
|
23
|
+
const resolvedId = item.id ?? itemIndex;
|
|
24
|
+
const current = isCurrentItem(itemIndex, visibleItems.length);
|
|
25
|
+
const itemClassName = getItemClassName(item.className, current);
|
|
26
|
+
return (_jsxs("li", { className: itemClassName, children: [current ? (_jsx("span", { "aria-current": "page", className: "liquid-breadcrumb__current", children: item.label })) : item.href ? (_jsx("a", { className: "liquid-breadcrumb__link", href: item.href, onClick: () => {
|
|
27
|
+
onNavigate?.(item, itemIndex);
|
|
28
|
+
item.onClick?.();
|
|
29
|
+
}, children: item.label })) : (_jsx("button", { className: "liquid-breadcrumb__link", onClick: () => {
|
|
30
|
+
onNavigate?.(item, itemIndex);
|
|
31
|
+
item.onClick?.();
|
|
32
|
+
}, type: "button", children: item.label })), !current ? (_jsx("span", { "aria-hidden": "true", className: "liquid-breadcrumb__separator", children: separator })) : null] }, String(resolvedId)));
|
|
33
|
+
}) }) }));
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAA6B,MAAM,aAAa,CAAC;AAM1E,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,SAAS,EACT,OAAmB,EACnB,IAAW,EACX,QAAgB,EAChB,KAAK,EACL,IAAe,EACf,GAAG,KAAK,EACT,EAAE,WAAW,2CAcb"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
function getButtonClassName(className) {
|
|
3
|
+
return ['liquid-button', className].filter(Boolean).join(' ');
|
|
4
|
+
}
|
|
5
|
+
export function Button({ children, className, variant = 'primary', size = 'md', disabled = false, style, type = 'button', ...props }) {
|
|
6
|
+
return (_jsx("button", { ...props, className: getButtonClassName(className), "data-size": size, "data-variant": variant, disabled: disabled, style: style, type: type, children: children }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CardProps } from '../../types';
|
|
2
|
+
export declare function Card({ action, actionButtonProps, actionLabel, className, disabled, description, details, onAction, style, title, ...props }: CardProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../src/components/Card/Card.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAM7C,wBAAgB,IAAI,CAAC,EACnB,MAAM,EACN,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,QAAgB,EAChB,WAAW,EACX,OAAY,EACZ,QAAQ,EACR,KAAK,EACL,KAAK,EACL,GAAG,KAAK,EACT,EAAE,SAAS,2CAyEX"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '../Button/Button';
|
|
3
|
+
function getClassName(className) {
|
|
4
|
+
return ['liquid-card', className].filter(Boolean).join(' ');
|
|
5
|
+
}
|
|
6
|
+
export function Card({ action, actionButtonProps, actionLabel, className, disabled = false, description, details = [], onAction, style, title, ...props }) {
|
|
7
|
+
const hasHeader = Boolean(title || description);
|
|
8
|
+
const hasBody = details.length > 0;
|
|
9
|
+
const hasFooter = Boolean(action || actionLabel);
|
|
10
|
+
return (_jsx("section", { ...props, "aria-disabled": disabled || undefined, className: getClassName(className), "data-disabled": disabled ? 'true' : undefined, style: style, children: _jsxs("div", { className: "liquid-card__container", children: [hasHeader ? (_jsxs("header", { className: "liquid-card__header", children: [title ? _jsx("h2", { className: "liquid-card__title", children: title }) : null, description ? (_jsx("p", { className: "liquid-card__description", children: description })) : null] })) : null, hasBody ? (_jsx("div", { className: "liquid-card__body", children: _jsx("dl", { className: "liquid-card__detail-list", children: details.map((detail, detailIndex) => {
|
|
11
|
+
const resolvedId = detail.id ?? detailIndex;
|
|
12
|
+
return (_jsxs("div", { className: "liquid-card__detail-row", children: [_jsx("dt", { className: "liquid-card__detail-label", children: detail.label }), _jsx("dd", { className: "liquid-card__detail-value", children: detail.value })] }, String(resolvedId)));
|
|
13
|
+
}) }) })) : null, hasFooter ? (_jsx("footer", { className: "liquid-card__footer", children: action ? (action) : (_jsx(Button, { ...actionButtonProps, className: [
|
|
14
|
+
'liquid-card__action-button',
|
|
15
|
+
actionButtonProps?.className,
|
|
16
|
+
]
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
.join(' '), disabled: disabled || actionButtonProps?.disabled, size: actionButtonProps?.size ?? 'sm', variant: actionButtonProps?.variant ?? 'primary', onClick: onAction, children: actionLabel })) })) : null] }) }));
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD,wBAAgB,QAAQ,CAAC,EACvB,SAAS,EACT,EAAE,EACF,aAAqB,EACrB,KAAK,EACL,SAAiB,EACjB,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,aAAa,2CAkDf"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useRef, useEffect } from 'react';
|
|
3
|
+
import { Icon } from '../Icon/Icon';
|
|
4
|
+
function getClassName(className) {
|
|
5
|
+
return ['liquid-checkbox', className].filter(Boolean).join(' ');
|
|
6
|
+
}
|
|
7
|
+
export function Checkbox({ className, id, indeterminate = false, label, hideLabel = false, style, disabled, ...props }) {
|
|
8
|
+
const reactId = useId();
|
|
9
|
+
const inputId = id ?? reactId;
|
|
10
|
+
const inputRef = useRef(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (inputRef.current) {
|
|
13
|
+
inputRef.current.indeterminate = indeterminate;
|
|
14
|
+
}
|
|
15
|
+
}, [indeterminate]);
|
|
16
|
+
return (_jsxs("label", { className: getClassName(className), style: style, "data-disabled": disabled || undefined, children: [_jsx("input", { ...props, ref: inputRef, type: "checkbox", id: inputId, disabled: disabled, className: "liquid-checkbox__input" }), _jsxs("span", { className: "liquid-checkbox__box", "aria-hidden": "true", children: [_jsx(Icon, { className: "liquid-checkbox__check-icon", color: "var(--component-checkbox-icon-check, #ffffff)", name: "check", size: 14 }), _jsx(Icon, { className: "liquid-checkbox__dash-icon", color: "var(--component-checkbox-icon-check, #ffffff)", name: "dash", size: 14 })] }), label ? (_jsx("span", { className: hideLabel ? 'liquid-sr-only' : 'liquid-checkbox__label-text', children: label })) : null] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContainedList.d.ts","sourceRoot":"","sources":["../../../src/components/ContainedList/ContainedList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAwB,MAAM,aAAa,CAAC;AAwB5E,wBAAgB,aAAa,CAAC,EAC5B,SAA4B,EAC5B,SAAS,EACT,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAmB,EACnB,GAAG,KAAK,EACT,EAAE,kBAAkB,2CAuCpB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
function getClassName(className) {
|
|
3
|
+
return ['liquid-contained-list', className].filter(Boolean).join(' ');
|
|
4
|
+
}
|
|
5
|
+
function getHeaderClassName(variant) {
|
|
6
|
+
return [
|
|
7
|
+
'liquid-contained-list__header',
|
|
8
|
+
`liquid-contained-list__header--${variant}`,
|
|
9
|
+
]
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
.join(' ');
|
|
12
|
+
}
|
|
13
|
+
function getTitleClassName(variant) {
|
|
14
|
+
return [
|
|
15
|
+
'liquid-contained-list__title',
|
|
16
|
+
`liquid-contained-list__title--${variant}`,
|
|
17
|
+
]
|
|
18
|
+
.filter(Boolean)
|
|
19
|
+
.join(' ');
|
|
20
|
+
}
|
|
21
|
+
export function ContainedList({ ariaLabel = 'Contained list', className, items, style, title, variant = 'on-page', ...props }) {
|
|
22
|
+
return (_jsx("section", { ...props, className: getClassName(className), style: style, children: _jsxs("div", { className: "liquid-contained-list__table", role: "table", "aria-label": ariaLabel, children: [_jsx("div", { className: getHeaderClassName(variant), role: "rowgroup", children: _jsx("div", { className: "liquid-contained-list__row", role: "row", children: _jsx("div", { className: getTitleClassName(variant), role: "columnheader", children: title }) }) }), _jsx("div", { className: "liquid-contained-list__body", role: "rowgroup", children: items.map((item, itemIndex) => {
|
|
23
|
+
const resolvedId = item.id ?? itemIndex;
|
|
24
|
+
return (_jsx("div", { className: "liquid-contained-list__row", role: "row", children: _jsx("div", { className: "liquid-contained-list__item-label", role: "cell", children: item.label }) }, String(resolvedId)));
|
|
25
|
+
}) })] }) }));
|
|
26
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DataTableProps } from '../../types';
|
|
2
|
+
export declare function DataTable({ captionDescription, captionTitle, className, columns, onRowSelectChange, onSelectAllChange, rowCheckboxLabel, rows, selectable, selectAllLabel, style, ...props }: DataTableProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=DataTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/DataTable.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMlD,wBAAgB,SAAS,CAAC,EACxB,kBAAmE,EACnE,YAA4B,EAC5B,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,IAAI,EACJ,UAAkB,EAClB,cAAkC,EAClC,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,2CAgGhB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox } from '../Checkbox/Checkbox';
|
|
3
|
+
function getClassName(className) {
|
|
4
|
+
return ['liquid-data-table', className].filter(Boolean).join(' ');
|
|
5
|
+
}
|
|
6
|
+
export function DataTable({ captionDescription = 'Brief description of what the table contains', captionTitle = 'Table title', className, columns, onRowSelectChange, onSelectAllChange, rowCheckboxLabel, rows, selectable = false, selectAllLabel = 'Select all rows', style, ...props }) {
|
|
7
|
+
const selectableRows = rows.filter((row) => !row.selectionDisabled);
|
|
8
|
+
const selectedCount = selectableRows.filter((row) => row.selected).length;
|
|
9
|
+
const allSelected = selectableRows.length > 0 && selectedCount === selectableRows.length;
|
|
10
|
+
const partiallySelected = selectedCount > 0 && !allSelected;
|
|
11
|
+
return (_jsxs("section", { ...props, className: getClassName(className), style: style, children: [_jsxs("header", { className: "liquid-data-table__header", children: [_jsx("h2", { className: "liquid-data-table__title", children: captionTitle }), _jsx("p", { className: "liquid-data-table__description", children: captionDescription })] }), _jsxs("table", { className: "liquid-data-table__table", children: [_jsx("thead", { children: _jsxs("tr", { className: "liquid-data-table__column-row", children: [selectable ? (_jsx("th", { className: "liquid-data-table__column-header liquid-data-table__checkbox-column", scope: "col", children: _jsx(Checkbox, { checked: allSelected, indeterminate: partiallySelected, label: selectAllLabel, hideLabel: true, onChange: (event) => {
|
|
12
|
+
onSelectAllChange?.(event.currentTarget.checked);
|
|
13
|
+
} }) })) : null, columns.map((column) => (_jsx("th", { className: "liquid-data-table__column-header", "data-align": column.align ?? 'left', scope: "col", children: column.header }, column.id)))] }) }), _jsx("tbody", { children: rows.map((row, rowIndex) => {
|
|
14
|
+
const resolvedId = row.id ?? rowIndex;
|
|
15
|
+
return (_jsxs("tr", { className: "liquid-data-table__row", "data-selected": row.selected || undefined, children: [selectable ? (_jsx("td", { className: "liquid-data-table__cell liquid-data-table__checkbox-column", children: _jsx(Checkbox, { checked: Boolean(row.selected), disabled: row.selectionDisabled, hideLabel: true, label: rowCheckboxLabel?.(row, rowIndex) ??
|
|
16
|
+
`Select row ${rowIndex + 1}`, onChange: (event) => {
|
|
17
|
+
onRowSelectChange?.(resolvedId, event.currentTarget.checked);
|
|
18
|
+
} }) })) : null, columns.map((column, columnIndex) => (_jsx("td", { className: "liquid-data-table__cell", "data-align": column.align ?? 'left', children: row.cells[columnIndex] ?? null }, `${String(resolvedId)}:${column.id}`)))] }, String(resolvedId)));
|
|
19
|
+
}) })] })] }));
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DescriptionList.d.ts","sourceRoot":"","sources":["../../../src/components/DescriptionList/DescriptionList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAuB,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAU7E,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,SAAS,EACT,KAAK,EACL,KAAK,EACL,GAAG,KAAK,EACT,EAAE,oBAAoB,2CA2BtB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
function getClassName(className) {
|
|
3
|
+
return ['liquid-description-list', className].filter(Boolean).join(' ');
|
|
4
|
+
}
|
|
5
|
+
function getVisibleItems(items) {
|
|
6
|
+
return items.filter((item) => Boolean(item.label || item.value));
|
|
7
|
+
}
|
|
8
|
+
export function DescriptionList({ ariaLabel, className, items, style, ...props }) {
|
|
9
|
+
const visibleItems = getVisibleItems(items);
|
|
10
|
+
return (_jsx("section", { ...props, "aria-label": ariaLabel, className: getClassName(className), style: style, children: _jsx("dl", { className: "liquid-description-list__content", children: visibleItems.map((item, itemIndex) => {
|
|
11
|
+
const resolvedId = item.id ?? itemIndex;
|
|
12
|
+
return (_jsxs("div", { className: "liquid-description-list__row", children: [_jsx("dt", { className: "liquid-description-list__label", children: item.label }), _jsx("dd", { className: "liquid-description-list__value", children: item.value })] }, String(resolvedId)));
|
|
13
|
+
}) }) }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FormItemProps, FormProps, FormRowProps } from '../../types';
|
|
2
|
+
export declare function Form({ actions, children, className, description, onPrimaryAction, onSecondaryAction, primaryActionButtonProps, primaryActionLabel, secondaryActionButtonProps, secondaryActionLabel, style, title, ...props }: FormProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function FormRow({ children, className, ...props }: FormRowProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function FormItem({ children, className, grow, ...props }: FormItemProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
//# sourceMappingURL=Form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Form.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAc1E,wBAAgB,IAAI,CAAC,EACnB,OAAO,EACP,QAAQ,EACR,SAAS,EACT,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,0BAA0B,EAC1B,oBAAoB,EACpB,KAAK,EACL,KAAK,EACL,GAAG,KAAK,EACT,EAAE,SAAS,2CAwEX;AAED,wBAAgB,OAAO,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,2CAMtE;AAED,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,SAAS,EACT,IAAY,EACZ,GAAG,KAAK,EACT,EAAE,aAAa,2CAUf"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '../Button/Button';
|
|
3
|
+
function getClassName(className) {
|
|
4
|
+
return ['liquid-form', className].filter(Boolean).join(' ');
|
|
5
|
+
}
|
|
6
|
+
function getItemClassName(className) {
|
|
7
|
+
return ['liquid-form__item', className].filter(Boolean).join(' ');
|
|
8
|
+
}
|
|
9
|
+
function getRowClassName(className) {
|
|
10
|
+
return ['liquid-form__row', className].filter(Boolean).join(' ');
|
|
11
|
+
}
|
|
12
|
+
export function Form({ actions, children, className, description, onPrimaryAction, onSecondaryAction, primaryActionButtonProps, primaryActionLabel, secondaryActionButtonProps, secondaryActionLabel, style, title, ...props }) {
|
|
13
|
+
const hasHeader = Boolean(title || description);
|
|
14
|
+
const hasFooter = Boolean(actions || primaryActionLabel || secondaryActionLabel);
|
|
15
|
+
return (_jsxs("form", { ...props, className: getClassName(className), style: style, children: [hasHeader ? (_jsxs("header", { className: "liquid-form__header", children: [title ? _jsx("h2", { className: "liquid-form__title", children: title }) : null, description ? (_jsx("p", { className: "liquid-form__description", children: description })) : null] })) : null, _jsxs("div", { className: "liquid-form__content", children: [_jsx("div", { className: "liquid-form__body", children: children }), hasFooter ? (_jsx("footer", { className: "liquid-form__footer", children: actions ? (actions) : (_jsxs("div", { className: "liquid-form__actions", children: [primaryActionLabel ? (_jsx(Button, { ...primaryActionButtonProps, className: [
|
|
16
|
+
'liquid-form__action-button',
|
|
17
|
+
primaryActionButtonProps?.className,
|
|
18
|
+
]
|
|
19
|
+
.filter(Boolean)
|
|
20
|
+
.join(' '), size: primaryActionButtonProps?.size ?? 'sm', variant: primaryActionButtonProps?.variant ?? 'primary', onClick: onPrimaryAction, type: primaryActionButtonProps?.type ?? 'submit', children: primaryActionLabel })) : null, secondaryActionLabel ? (_jsx(Button, { ...secondaryActionButtonProps, className: [
|
|
21
|
+
'liquid-form__action-button',
|
|
22
|
+
secondaryActionButtonProps?.className,
|
|
23
|
+
]
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
.join(' '), size: secondaryActionButtonProps?.size ?? 'sm', variant: secondaryActionButtonProps?.variant ?? 'secondary', onClick: onSecondaryAction, type: secondaryActionButtonProps?.type ?? 'button', children: secondaryActionLabel })) : null] })) })) : null] })] }));
|
|
26
|
+
}
|
|
27
|
+
export function FormRow({ children, className, ...props }) {
|
|
28
|
+
return (_jsx("div", { ...props, className: getRowClassName(className), children: children }));
|
|
29
|
+
}
|
|
30
|
+
export function FormItem({ children, className, grow = false, ...props }) {
|
|
31
|
+
return (_jsx("div", { ...props, className: getItemClassName(className), "data-grow": grow ? 'true' : undefined, children: children }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GridColumnProps, GridLayoutProps } from '../../types';
|
|
2
|
+
export declare function GridLayout({ align, as: Element, children, className, condensed, fullWidth, narrow, style, subgrid, withRowGap, ...props }: GridLayoutProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
3
|
+
export declare function GridColumn({ as: Element, children, className, lg, max, md, sm, style, xlg, ...props }: GridColumnProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
4
|
+
//# sourceMappingURL=GridLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,eAAe,EAEf,eAAe,EAChB,MAAM,aAAa,CAAC;AAyIrB,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,EAAE,EAAE,OAAe,EACnB,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,MAAM,EACN,KAAK,EACL,OAAO,EACP,UAAU,EACV,GAAG,KAAK,EACT,EAAE,eAAe,0FAoBjB;AAED,wBAAgB,UAAU,CAAC,EACzB,EAAE,EAAE,OAAe,EACnB,QAAQ,EACR,SAAS,EACT,EAAE,EACF,GAAG,EACH,EAAE,EACF,EAAE,EACF,KAAK,EACL,GAAG,EACH,GAAG,KAAK,EACT,EAAE,eAAe,0FAkBjB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import { BREAKPOINT_KEYS, getGridBreakpointSpec } from './gridTokens';
|
|
3
|
+
function getClassName(className) {
|
|
4
|
+
return ['liquid-grid', className].filter(Boolean).join(' ');
|
|
5
|
+
}
|
|
6
|
+
function getColumnClassName(className) {
|
|
7
|
+
return ['liquid-grid__column', className].filter(Boolean).join(' ');
|
|
8
|
+
}
|
|
9
|
+
function getAlignment(align) {
|
|
10
|
+
if (align === 'start') {
|
|
11
|
+
return 'start';
|
|
12
|
+
}
|
|
13
|
+
if (align === 'end') {
|
|
14
|
+
return 'end';
|
|
15
|
+
}
|
|
16
|
+
if (align === 'center') {
|
|
17
|
+
return 'center';
|
|
18
|
+
}
|
|
19
|
+
return 'stretch';
|
|
20
|
+
}
|
|
21
|
+
function getResponsiveGridStyle(props) {
|
|
22
|
+
const { align, condensed, fullWidth, narrow, style, subgrid, withRowGap } = props;
|
|
23
|
+
const maxSpec = getGridBreakpointSpec('max');
|
|
24
|
+
const variables = {
|
|
25
|
+
'--liquid-grid-align': getAlignment(align),
|
|
26
|
+
'--liquid-grid-margin-inline': fullWidth || subgrid ? '0px' : 'auto',
|
|
27
|
+
'--liquid-grid-max-width': fullWidth || subgrid ? 'none' : `${maxSpec.width + maxSpec.margin * 2}px`,
|
|
28
|
+
};
|
|
29
|
+
for (const breakpoint of BREAKPOINT_KEYS) {
|
|
30
|
+
const spec = getGridBreakpointSpec(breakpoint);
|
|
31
|
+
const gutter = condensed ? 1 : narrow ? spec.narrowGutter : spec.wideGutter;
|
|
32
|
+
const hang = narrow ? spec.containerHang : 0;
|
|
33
|
+
const margin = Math.max(0, spec.margin - hang);
|
|
34
|
+
if (subgrid) {
|
|
35
|
+
variables[`--liquid-grid-margin-${breakpoint}`] = '0px';
|
|
36
|
+
variables[`--liquid-grid-row-gap-${breakpoint}`] = withRowGap
|
|
37
|
+
? `var(--liquid-grid-gutter-${breakpoint})`
|
|
38
|
+
: '0px';
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
variables[`--liquid-grid-columns-${breakpoint}`] = `${spec.columns}`;
|
|
42
|
+
variables[`--liquid-grid-margin-${breakpoint}`] = `${margin}px`;
|
|
43
|
+
variables[`--liquid-grid-gutter-${breakpoint}`] = `${gutter}px`;
|
|
44
|
+
variables[`--liquid-grid-row-gap-${breakpoint}`] = withRowGap
|
|
45
|
+
? `var(--liquid-grid-gutter-${breakpoint})`
|
|
46
|
+
: '0px';
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
...variables,
|
|
50
|
+
...style,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function normalizeColumnValue(value) {
|
|
54
|
+
if (typeof value === 'number') {
|
|
55
|
+
return { span: value };
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
function getGridColumnValue(value) {
|
|
60
|
+
const normalizedValue = normalizeColumnValue(value);
|
|
61
|
+
if (!normalizedValue) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const span = normalizedValue.span ?? 1;
|
|
65
|
+
const offset = normalizedValue.offset ?? 0;
|
|
66
|
+
if (span <= 0) {
|
|
67
|
+
return {
|
|
68
|
+
display: 'none',
|
|
69
|
+
placement: 'auto',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (offset > 0) {
|
|
73
|
+
return {
|
|
74
|
+
display: 'block',
|
|
75
|
+
placement: `${offset + 1} / span ${span}`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
display: 'block',
|
|
80
|
+
placement: `span ${span}`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function getResponsiveColumnStyle(props) {
|
|
84
|
+
const { lg, max, md, sm, style, xlg } = props;
|
|
85
|
+
const values = {
|
|
86
|
+
sm,
|
|
87
|
+
md,
|
|
88
|
+
lg,
|
|
89
|
+
xlg,
|
|
90
|
+
max,
|
|
91
|
+
};
|
|
92
|
+
const variables = {};
|
|
93
|
+
for (const breakpoint of BREAKPOINT_KEYS) {
|
|
94
|
+
const columnValue = getGridColumnValue(values[breakpoint]);
|
|
95
|
+
if (!columnValue) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
variables[`--liquid-grid-column-${breakpoint}`] = columnValue.placement;
|
|
99
|
+
variables[`--liquid-grid-column-display-${breakpoint}`] =
|
|
100
|
+
columnValue.display;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
...variables,
|
|
104
|
+
...style,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export function GridLayout({ align, as: Element = 'div', children, className, condensed, fullWidth, narrow, style, subgrid, withRowGap, ...props }) {
|
|
108
|
+
return createElement(Element, {
|
|
109
|
+
...props,
|
|
110
|
+
className: getClassName(className),
|
|
111
|
+
style: getResponsiveGridStyle({
|
|
112
|
+
align,
|
|
113
|
+
children,
|
|
114
|
+
className,
|
|
115
|
+
condensed,
|
|
116
|
+
fullWidth,
|
|
117
|
+
narrow,
|
|
118
|
+
style,
|
|
119
|
+
subgrid,
|
|
120
|
+
withRowGap,
|
|
121
|
+
}),
|
|
122
|
+
}, children);
|
|
123
|
+
}
|
|
124
|
+
export function GridColumn({ as: Element = 'div', children, className, lg, max, md, sm, style, xlg, ...props }) {
|
|
125
|
+
return createElement(Element, {
|
|
126
|
+
...props,
|
|
127
|
+
className: getColumnClassName(className),
|
|
128
|
+
style: getResponsiveColumnStyle({
|
|
129
|
+
className,
|
|
130
|
+
lg,
|
|
131
|
+
max,
|
|
132
|
+
md,
|
|
133
|
+
sm,
|
|
134
|
+
style,
|
|
135
|
+
xlg,
|
|
136
|
+
}),
|
|
137
|
+
}, children);
|
|
138
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type BreakpointKey = 'sm' | 'md' | 'lg' | 'xlg' | 'max';
|
|
2
|
+
export interface GridBreakpointSpec {
|
|
3
|
+
columns: number;
|
|
4
|
+
containerHang: number;
|
|
5
|
+
key: BreakpointKey;
|
|
6
|
+
margin: number;
|
|
7
|
+
narrowGutter: number;
|
|
8
|
+
wideGutter: number;
|
|
9
|
+
width: number;
|
|
10
|
+
}
|
|
11
|
+
export interface RowRhythmSpec {
|
|
12
|
+
caption: string;
|
|
13
|
+
value: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const BREAKPOINT_KEYS: BreakpointKey[];
|
|
16
|
+
export declare function getGridBreakpointSpec(breakpoint: BreakpointKey): GridBreakpointSpec;
|
|
17
|
+
export declare function getRowRhythms(): RowRhythmSpec[];
|
|
18
|
+
//# sourceMappingURL=gridTokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gridTokens.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/gridTokens.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAAC;AAE/D,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,aAAa,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,eAAe,EAAE,aAAa,EAM1C,CAAC;AAsEF,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,aAAa,GACxB,kBAAkB,CAqDpB;AAED,wBAAgB,aAAa,IAAI,aAAa,EAAE,CAQ/C"}
|