@ps1ui/core 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/base.css +378 -0
- package/dist/components/Anchor/Anchor.d.mts +14 -0
- package/dist/components/Anchor/Anchor.mjs +15 -0
- package/dist/components/Anchor/Anchor.mjs.map +1 -0
- package/dist/components/Button/Button.d.mts +30 -0
- package/dist/components/Button/Button.mjs +17 -0
- package/dist/components/Button/Button.mjs.map +1 -0
- package/dist/components/Card/Card.d.mts +7 -0
- package/dist/components/Card/Card.mjs +14 -0
- package/dist/components/Card/Card.mjs.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.mts +10 -0
- package/dist/components/Checkbox/Checkbox.mjs +23 -0
- package/dist/components/Checkbox/Checkbox.mjs.map +1 -0
- package/dist/components/Code/Code.d.mts +7 -0
- package/dist/components/Code/Code.mjs +14 -0
- package/dist/components/Code/Code.mjs.map +1 -0
- package/dist/components/CodeBlock/CodeBlock.d.mts +15 -0
- package/dist/components/CodeBlock/CodeBlock.mjs +44 -0
- package/dist/components/CodeBlock/CodeBlock.mjs.map +1 -0
- package/dist/components/CodeBlock/refractor.d.mts +7 -0
- package/dist/components/CodeBlock/refractor.mjs +26 -0
- package/dist/components/CodeBlock/refractor.mjs.map +1 -0
- package/dist/components/Container/Container.d.mts +21 -0
- package/dist/components/Container/Container.mjs +24 -0
- package/dist/components/Container/Container.mjs.map +1 -0
- package/dist/components/Details/Details.d.mts +10 -0
- package/dist/components/Details/Details.mjs +20 -0
- package/dist/components/Details/Details.mjs.map +1 -0
- package/dist/components/Grid/Grid.d.mts +21 -0
- package/dist/components/Grid/Grid.mjs +24 -0
- package/dist/components/Grid/Grid.mjs.map +1 -0
- package/dist/components/GridItem/GridItem.d.mts +14 -0
- package/dist/components/GridItem/GridItem.mjs +21 -0
- package/dist/components/GridItem/GridItem.mjs.map +1 -0
- package/dist/components/Heading/Heading.d.mts +26 -0
- package/dist/components/Heading/Heading.mjs +53 -0
- package/dist/components/Heading/Heading.mjs.map +1 -0
- package/dist/components/Input/Input.d.mts +7 -0
- package/dist/components/Input/Input.mjs +15 -0
- package/dist/components/Input/Input.mjs.map +1 -0
- package/dist/components/Label/Label.d.mts +7 -0
- package/dist/components/Label/Label.mjs +14 -0
- package/dist/components/Label/Label.mjs.map +1 -0
- package/dist/components/List/List.d.mts +13 -0
- package/dist/components/List/List.mjs +15 -0
- package/dist/components/List/List.mjs.map +1 -0
- package/dist/components/ListItem/ListItem.d.mts +7 -0
- package/dist/components/ListItem/ListItem.mjs +13 -0
- package/dist/components/ListItem/ListItem.mjs.map +1 -0
- package/dist/components/PS1Root/PS1Root.d.mts +7 -0
- package/dist/components/PS1Root/PS1Root.mjs +13 -0
- package/dist/components/PS1Root/PS1Root.mjs.map +1 -0
- package/dist/components/Stack/Stack.d.mts +33 -0
- package/dist/components/Stack/Stack.mjs +48 -0
- package/dist/components/Stack/Stack.mjs.map +1 -0
- package/dist/components/Table/Table.d.mts +7 -0
- package/dist/components/Table/Table.mjs +25 -0
- package/dist/components/Table/Table.mjs.map +1 -0
- package/dist/components/Tbody/Tbody.d.mts +7 -0
- package/dist/components/Tbody/Tbody.mjs +13 -0
- package/dist/components/Tbody/Tbody.mjs.map +1 -0
- package/dist/components/Td/Td.d.mts +7 -0
- package/dist/components/Td/Td.mjs +13 -0
- package/dist/components/Td/Td.mjs.map +1 -0
- package/dist/components/Text/Text.d.mts +31 -0
- package/dist/components/Text/Text.mjs +34 -0
- package/dist/components/Text/Text.mjs.map +1 -0
- package/dist/components/Th/Th.d.mts +7 -0
- package/dist/components/Th/Th.mjs +13 -0
- package/dist/components/Th/Th.mjs.map +1 -0
- package/dist/components/Thead/Thead.d.mts +7 -0
- package/dist/components/Thead/Thead.mjs +13 -0
- package/dist/components/Thead/Thead.mjs.map +1 -0
- package/dist/components/Tr/Tr.d.mts +7 -0
- package/dist/components/Tr/Tr.mjs +13 -0
- package/dist/components/Tr/Tr.mjs.map +1 -0
- package/dist/components.css +1870 -0
- package/dist/index.d.mts +28 -0
- package/dist/index.mjs +25 -0
- package/dist/styles.css +1930 -0
- package/dist/utils/cx.mjs +8 -0
- package/dist/utils/cx.mjs.map +1 -0
- package/dist/utils/numbers.mjs +8 -0
- package/dist/utils/numbers.mjs.map +1 -0
- package/dist/utils/responsive.d.mts +6 -0
- package/dist/utils/responsive.mjs +39 -0
- package/dist/utils/responsive.mjs.map +1 -0
- package/dist/utils/spacing.d.mts +5 -0
- package/dist/utils/spacing.mjs +8 -0
- package/dist/utils/spacing.mjs.map +1 -0
- package/dist/utils/typography.d.mts +5 -0
- package/dist/utils/typography.mjs +16 -0
- package/dist/utils/typography.mjs.map +1 -0
- package/dist/utils/useMergedRef.mjs +30 -0
- package/dist/utils/useMergedRef.mjs.map +1 -0
- package/dist/utils/useScrollableFocus.mjs +29 -0
- package/dist/utils/useScrollableFocus.mjs.map +1 -0
- package/package.json +84 -3
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { cx } from "../../utils/cx.mjs";
|
|
2
|
+
import { resolveResponsive } from "../../utils/responsive.mjs";
|
|
3
|
+
import { spaceToVar } from "../../utils/spacing.mjs";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Stack/Stack.tsx
|
|
6
|
+
const directionToValue = (v) => v;
|
|
7
|
+
const alignToValue = (v) => {
|
|
8
|
+
switch (v) {
|
|
9
|
+
case "start": return "flex-start";
|
|
10
|
+
case "end": return "flex-end";
|
|
11
|
+
default: return v;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const justifyToValue = (v) => {
|
|
15
|
+
switch (v) {
|
|
16
|
+
case "start": return "flex-start";
|
|
17
|
+
case "end": return "flex-end";
|
|
18
|
+
case "between": return "space-between";
|
|
19
|
+
case "around": return "space-around";
|
|
20
|
+
case "evenly": return "space-evenly";
|
|
21
|
+
default: return v;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const wrapToValue = (v) => v ? "wrap" : "nowrap";
|
|
25
|
+
function Stack({ direction, gap, align, justify, wrap, className, style, ...rest }) {
|
|
26
|
+
const directionVars = resolveResponsive(direction, "--_stack-direction", directionToValue);
|
|
27
|
+
const gapVars = resolveResponsive(gap, "--_stack-gap", spaceToVar);
|
|
28
|
+
const alignVars = resolveResponsive(align, "--_stack-align", alignToValue);
|
|
29
|
+
const justifyVars = resolveResponsive(justify, "--_stack-justify", justifyToValue);
|
|
30
|
+
const wrapVars = resolveResponsive(wrap, "--_stack-wrap", wrapToValue);
|
|
31
|
+
const mergedStyle = {
|
|
32
|
+
...style,
|
|
33
|
+
...directionVars,
|
|
34
|
+
...gapVars,
|
|
35
|
+
...alignVars,
|
|
36
|
+
...justifyVars,
|
|
37
|
+
...wrapVars
|
|
38
|
+
};
|
|
39
|
+
return /* @__PURE__ */ jsx("div", {
|
|
40
|
+
...rest,
|
|
41
|
+
className: cx("ps1ui-stack", className),
|
|
42
|
+
style: mergedStyle
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { Stack };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=Stack.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stack.mjs","names":[],"sources":["../../../src/components/Stack/Stack.tsx"],"sourcesContent":["import type { ComponentProps, CSSProperties } from \"react\";\nimport { cx } from \"../../utils/cx\";\nimport { resolveResponsive, type Responsive } from \"../../utils/responsive\";\nimport { spaceToVar, type SpaceScale } from \"../../utils/spacing\";\n\nexport type StackDirection = \"row\" | \"column\";\nexport type StackGap = SpaceScale;\nexport type StackAlign = \"start\" | \"center\" | \"end\" | \"stretch\" | \"baseline\";\nexport type StackJustify = \"start\" | \"center\" | \"end\" | \"between\" | \"around\" | \"evenly\";\n\nexport type StackProps = ComponentProps<\"div\"> & {\n /**\n * Main-axis direction.\n * @default \"column\"\n */\n direction?: Responsive<StackDirection>;\n /**\n * Gap between items on the space scale.\n * @default \"md\"\n */\n gap?: Responsive<StackGap>;\n /** Cross-axis alignment (align-items). */\n align?: Responsive<StackAlign>;\n /** Main-axis distribution (justify-content). */\n justify?: Responsive<StackJustify>;\n /**\n * Wrap items onto multiple lines instead of overflowing.\n * @default false\n */\n wrap?: Responsive<boolean>;\n};\n\n// direction values pass straight through — CSS flex-direction accepts\n// `row` / `column` (and `row-reverse` / `column-reverse`, which the union\n// deliberately excludes; add those to the union if the API ever grows).\nconst directionToValue = (v: StackDirection): string => v;\n\n// Flexbox uses `flex-start` / `flex-end` in the box-alignment spec. The\n// StackAlign union exposes the shorter `start` / `end` alias for terseness;\n// the transform remaps them so the CSS variable holds a valid `align-items`\n// value directly.\nconst alignToValue = (v: StackAlign): string => {\n switch (v) {\n case \"start\":\n return \"flex-start\";\n case \"end\":\n return \"flex-end\";\n default:\n return v;\n }\n};\n\n// Same treatment as `alignToValue`, plus expansions for the `space-*`\n// justify-content variants.\nconst justifyToValue = (v: StackJustify): string => {\n switch (v) {\n case \"start\":\n return \"flex-start\";\n case \"end\":\n return \"flex-end\";\n case \"between\":\n return \"space-between\";\n case \"around\":\n return \"space-around\";\n case \"evenly\":\n return \"space-evenly\";\n default:\n return v;\n }\n};\n\n// boolean → CSS flex-wrap keyword.\nconst wrapToValue = (v: boolean): string => (v ? \"wrap\" : \"nowrap\");\n\nexport function Stack({\n direction,\n gap,\n align,\n justify,\n wrap,\n className,\n style,\n ...rest\n}: StackProps) {\n const directionVars = resolveResponsive(direction, \"--_stack-direction\", directionToValue);\n const gapVars = resolveResponsive(gap, \"--_stack-gap\", spaceToVar);\n const alignVars = resolveResponsive(align, \"--_stack-align\", alignToValue);\n const justifyVars = resolveResponsive(justify, \"--_stack-justify\", justifyToValue);\n const wrapVars = resolveResponsive(wrap, \"--_stack-wrap\", wrapToValue);\n\n // Caller style first, internal `--_*` vars win — see Text.tsx. Cast because\n // csstype has no index signature for `--*` keys (React 19 included).\n const mergedStyle: CSSProperties = {\n ...style,\n ...directionVars,\n ...gapVars,\n ...alignVars,\n ...justifyVars,\n ...wrapVars,\n } as CSSProperties;\n\n return <div {...rest} className={cx(\"ps1ui-stack\", className)} style={mergedStyle} />;\n}\n"],"mappings":";;;;;AAmCA,MAAM,oBAAoB,MAA8B;AAMxD,MAAM,gBAAgB,MAA0B;CAC9C,QAAQ,GAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAIA,MAAM,kBAAkB,MAA4B;CAClD,QAAQ,GAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAGA,MAAM,eAAe,MAAwB,IAAI,SAAS;AAE1D,SAAgB,MAAM,EACpB,WACA,KACA,OACA,SACA,MACA,WACA,OACA,GAAG,QACU;CACb,MAAM,gBAAgB,kBAAkB,WAAW,sBAAsB,gBAAgB;CACzF,MAAM,UAAU,kBAAkB,KAAK,gBAAgB,UAAU;CACjE,MAAM,YAAY,kBAAkB,OAAO,kBAAkB,YAAY;CACzE,MAAM,cAAc,kBAAkB,SAAS,oBAAoB,cAAc;CACjF,MAAM,WAAW,kBAAkB,MAAM,iBAAiB,WAAW;CAIrE,MAAM,cAA6B;EACjC,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;CACL;CAEA,OAAO,oBAAC,OAAD;EAAK,GAAI;EAAM,WAAW,GAAG,eAAe,SAAS;EAAG,OAAO;CAAc,CAAA;AACtF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
//#region src/components/Table/Table.d.ts
|
|
3
|
+
type TableProps = ComponentProps<"table">;
|
|
4
|
+
declare function Table({ className, ref: forwardedRef, ...rest }: TableProps): import("react").JSX.Element;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { Table, TableProps };
|
|
7
|
+
//# sourceMappingURL=Table.d.mts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../utils/cx.mjs";
|
|
3
|
+
import { useMergedRef } from "../../utils/useMergedRef.mjs";
|
|
4
|
+
import { useScrollableFocus } from "../../utils/useScrollableFocus.mjs";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/Table/Table.tsx
|
|
7
|
+
function Table({ className, ref: forwardedRef, ...rest }) {
|
|
8
|
+
const { scrollerRef, contentRef, tabIndex, measure } = useScrollableFocus();
|
|
9
|
+
const mergedRef = useMergedRef(contentRef, forwardedRef);
|
|
10
|
+
return /* @__PURE__ */ jsx("div", {
|
|
11
|
+
className: "ps1ui-table__scroller",
|
|
12
|
+
tabIndex,
|
|
13
|
+
ref: scrollerRef,
|
|
14
|
+
onBlur: measure,
|
|
15
|
+
children: /* @__PURE__ */ jsx("table", {
|
|
16
|
+
...rest,
|
|
17
|
+
ref: mergedRef,
|
|
18
|
+
className: cx("ps1ui-table", className)
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { Table };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=Table.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.mjs","names":[],"sources":["../../../src/components/Table/Table.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ComponentProps } from \"react\";\nimport { cx } from \"../../utils/cx\";\nimport { useMergedRef } from \"../../utils/useMergedRef\";\nimport { useScrollableFocus } from \"../../utils/useScrollableFocus\";\n\n// Props type the native <table>: everything spreads onto the <table> element,\n// ref included. The horizontal-scroll wrapper the component renders around it\n// is an internal implementation detail — it carries no caller props and is\n// styled/targeted via the stable `.ps1ui-table__scroller` class.\nexport type TableProps = ComponentProps<\"table\">;\n\nexport function Table({ className, ref: forwardedRef, ...rest }: TableProps) {\n // A <table> cannot be its own overflow container (`display: table` boxes\n // don't honor overflow), so scrolling lives on a wrapper div. Keyboard\n // reachability of that wrapper — tabIndex only while the table actually\n // overflows, kept while focused, safe-side under static SSR — is the shared\n // useScrollableFocus contract (see the hook's header for the full account).\n // The table's own box is the observed content: children re-rendering wider\n // or narrower resize it, which re-fires the measurement.\n const { scrollerRef, contentRef, tabIndex, measure } = useScrollableFocus<\n HTMLDivElement,\n HTMLTableElement\n >();\n\n // Both the hook (overflow observation) and the caller get the <table> node.\n const mergedRef = useMergedRef(contentRef, forwardedRef);\n\n return (\n <div\n className=\"ps1ui-table__scroller\"\n // oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- axe scrollable-region-focusable requires the scroller be keyboard-reachable when the table overflows; useScrollableFocus gates this on measured overflow so small tables stay out of the tab order.\n tabIndex={tabIndex}\n ref={scrollerRef}\n // Re-measure once focus leaves: while focused the hook keeps the tab\n // stop even if content now fits (dropping tabindex off the focused\n // element would blur it to <body>); blur is the moment it can safely go.\n onBlur={measure}\n >\n <table {...rest} ref={mergedRef} className={cx(\"ps1ui-table\", className)} />\n </div>\n );\n}\n"],"mappings":";;;;;;AAaA,SAAgB,MAAM,EAAE,WAAW,KAAK,cAAc,GAAG,QAAoB;CAQ3E,MAAM,EAAE,aAAa,YAAY,UAAU,YAAY,mBAGrD;CAGF,MAAM,YAAY,aAAa,YAAY,YAAY;CAEvD,OACE,oBAAC,OAAD;EACE,WAAU;EAEA;EACV,KAAK;EAIL,QAAQ;YAER,oBAAC,SAAD;GAAO,GAAI;GAAM,KAAK;GAAW,WAAW,GAAG,eAAe,SAAS;EAAI,CAAA;CACxE,CAAA;AAET"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
//#region src/components/Tbody/Tbody.d.ts
|
|
3
|
+
type TbodyProps = ComponentProps<"tbody">;
|
|
4
|
+
declare function Tbody({ className, ...rest }: TbodyProps): import("react").JSX.Element;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { Tbody, TbodyProps };
|
|
7
|
+
//# sourceMappingURL=Tbody.d.mts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cx } from "../../utils/cx.mjs";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/Tbody/Tbody.tsx
|
|
4
|
+
function Tbody({ className, ...rest }) {
|
|
5
|
+
return /* @__PURE__ */ jsx("tbody", {
|
|
6
|
+
...rest,
|
|
7
|
+
className: cx("ps1ui-tbody", className)
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Tbody };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=Tbody.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tbody.mjs","names":[],"sources":["../../../src/components/Tbody/Tbody.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\";\nimport { cx } from \"../../utils/cx\";\n\n// Thin typed wrapper for `<tbody>` inside a `<Table>`. Cell styling lives on\n// `.ps1ui-table th / td` in Table.css, so a bare `<tbody>` continues to\n// render identically — Tbody exists to give call sites a stable class hook\n// (`.ps1ui-tbody`) and a documented API surface for what belongs inside a\n// `<Table>` (same contract as ListItem inside List).\nexport type TbodyProps = ComponentProps<\"tbody\">;\n\nexport function Tbody({ className, ...rest }: TbodyProps) {\n return <tbody {...rest} className={cx(\"ps1ui-tbody\", className)} />;\n}\n"],"mappings":";;;AAUA,SAAgB,MAAM,EAAE,WAAW,GAAG,QAAoB;CACxD,OAAO,oBAAC,SAAD;EAAO,GAAI;EAAM,WAAW,GAAG,eAAe,SAAS;CAAI,CAAA;AACpE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
//#region src/components/Td/Td.d.ts
|
|
3
|
+
type TdProps = ComponentProps<"td">;
|
|
4
|
+
declare function Td({ className, ...rest }: TdProps): import("react").JSX.Element;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { Td, TdProps };
|
|
7
|
+
//# sourceMappingURL=Td.d.mts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cx } from "../../utils/cx.mjs";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/Td/Td.tsx
|
|
4
|
+
function Td({ className, ...rest }) {
|
|
5
|
+
return /* @__PURE__ */ jsx("td", {
|
|
6
|
+
...rest,
|
|
7
|
+
className: cx("ps1ui-td", className)
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Td };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=Td.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Td.mjs","names":[],"sources":["../../../src/components/Td/Td.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\";\nimport { cx } from \"../../utils/cx\";\n\n// Thin typed wrapper for `<td>` inside a `<Table>`. Data-cell styling lives\n// on `.ps1ui-table td` in Table.css, so a bare `<td>` continues to render\n// identically — Td exists to give call sites a stable class hook\n// (`.ps1ui-td`) and a documented API surface for what belongs inside a\n// `<Table>` (same contract as ListItem inside List).\nexport type TdProps = ComponentProps<\"td\">;\n\nexport function Td({ className, ...rest }: TdProps) {\n return <td {...rest} className={cx(\"ps1ui-td\", className)} />;\n}\n"],"mappings":";;;AAUA,SAAgB,GAAG,EAAE,WAAW,GAAG,QAAiB;CAClD,OAAO,oBAAC,MAAD;EAAI,GAAI;EAAM,WAAW,GAAG,YAAY,SAAS;CAAI,CAAA;AAC9D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Responsive } from "../../utils/responsive.mjs";
|
|
2
|
+
import { FontWeight } from "../../utils/typography.mjs";
|
|
3
|
+
import { CSSProperties, ComponentPropsWithoutRef } from "react";
|
|
4
|
+
//#region src/components/Text/Text.d.ts
|
|
5
|
+
type TextElement = "p" | "span" | "div" | "label" | "strong" | "em" | "small";
|
|
6
|
+
type TextVariant = "body" | "muted" | "subtle" | "primary" | "accent";
|
|
7
|
+
type TextSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
8
|
+
type TextWeight = FontWeight;
|
|
9
|
+
type TextOwnProps<E extends TextElement> = {
|
|
10
|
+
/** Element to render. */
|
|
11
|
+
as?: E;
|
|
12
|
+
/** Color variant. */
|
|
13
|
+
variant?: TextVariant;
|
|
14
|
+
/**
|
|
15
|
+
* Font size on the type scale.
|
|
16
|
+
* @default "sm"
|
|
17
|
+
*/
|
|
18
|
+
size?: Responsive<TextSize>;
|
|
19
|
+
/** Font weight. */
|
|
20
|
+
weight?: Responsive<TextWeight>;
|
|
21
|
+
/** Truncate overflowing text with an ellipsis instead of wrapping. */
|
|
22
|
+
truncate?: boolean;
|
|
23
|
+
};
|
|
24
|
+
type TextProps<E extends TextElement = "p"> = TextOwnProps<E> & Omit<ComponentPropsWithoutRef<E>, keyof TextOwnProps<E>>;
|
|
25
|
+
declare function Text<E extends TextElement = "p">({ as, variant, size, weight, truncate, className, style, ...rest }: TextProps<E>): import("react").ReactElement<Omit<TextProps<E>, "as" | "className" | "size" | "style" | "truncate" | "variant" | "weight"> & {
|
|
26
|
+
className: string;
|
|
27
|
+
style: CSSProperties;
|
|
28
|
+
}, string | import("react").JSXElementConstructor<any>>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { Text, TextElement, TextProps, TextSize, TextVariant, TextWeight };
|
|
31
|
+
//# sourceMappingURL=Text.d.mts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { cx } from "../../utils/cx.mjs";
|
|
2
|
+
import { resolveResponsive } from "../../utils/responsive.mjs";
|
|
3
|
+
import { fontSizeToVar, weightToValue } from "../../utils/typography.mjs";
|
|
4
|
+
import { createElement } from "react";
|
|
5
|
+
//#region src/components/Text/Text.tsx
|
|
6
|
+
const INLINE_TEXT_ELEMENTS = {
|
|
7
|
+
p: false,
|
|
8
|
+
div: false,
|
|
9
|
+
span: true,
|
|
10
|
+
label: true,
|
|
11
|
+
strong: true,
|
|
12
|
+
em: true,
|
|
13
|
+
small: true
|
|
14
|
+
};
|
|
15
|
+
function Text({ as, variant = "body", size, weight, truncate = false, className, style, ...rest }) {
|
|
16
|
+
const tag = as ?? "p";
|
|
17
|
+
const sizeVars = resolveResponsive(size, "--_text-size", fontSizeToVar);
|
|
18
|
+
const weightVars = resolveResponsive(weight, "--_text-weight", weightToValue);
|
|
19
|
+
const classes = cx("ps1ui-text", `ps1ui-text--${variant}`, truncate && "ps1ui-text--truncate", truncate && INLINE_TEXT_ELEMENTS[tag] && "ps1ui-text--truncate-inline", className);
|
|
20
|
+
const mergedStyle = {
|
|
21
|
+
...style,
|
|
22
|
+
...sizeVars,
|
|
23
|
+
...weightVars
|
|
24
|
+
};
|
|
25
|
+
return createElement(tag, {
|
|
26
|
+
...rest,
|
|
27
|
+
className: classes,
|
|
28
|
+
style: mergedStyle
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { Text };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=Text.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.mjs","names":[],"sources":["../../../src/components/Text/Text.tsx"],"sourcesContent":["import { createElement } from \"react\";\nimport type { ComponentPropsWithoutRef, CSSProperties } from \"react\";\nimport { cx } from \"../../utils/cx\";\nimport { resolveResponsive, type Responsive } from \"../../utils/responsive\";\nimport { fontSizeToVar, weightToValue, type FontWeight } from \"../../utils/typography\";\n\nexport type TextElement = \"p\" | \"span\" | \"div\" | \"label\" | \"strong\" | \"em\" | \"small\";\n\nexport type TextVariant = \"body\" | \"muted\" | \"subtle\" | \"primary\" | \"accent\";\nexport type TextSize = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n// TextWeight is a re-export of the shared FontWeight scale. Keeping a\n// component-local alias preserves the public type name (backwards compat)\n// while the underlying scale stays single-sourced in utils/typography.ts.\nexport type TextWeight = FontWeight;\n\ntype TextOwnProps<E extends TextElement> = {\n /** Element to render. */\n as?: E;\n /** Color variant. */\n variant?: TextVariant;\n /**\n * Font size on the type scale.\n * @default \"sm\"\n */\n size?: Responsive<TextSize>;\n /** Font weight. */\n weight?: Responsive<TextWeight>;\n /** Truncate overflowing text with an ellipsis instead of wrapping. */\n truncate?: boolean;\n};\n\n// Deliberate exception to the general \"use ComponentProps<'tag'>\" rule other components follow.\n// With the polymorphic `as` prop, TypeScript cannot narrow the `ref` prop's type against the\n// resolved element E — allowing `ref` here would silently accept mismatched ref types\n// (e.g. a ref typed for HTMLParagraphElement on `<Text as=\"span\" ref={…} />`). Keeping `ref`\n// out of the prop type entirely is safer than a misleading loose type; don't switch this\n// to ComponentProps for consistency with the other components.\nexport type TextProps<E extends TextElement = \"p\"> = TextOwnProps<E> &\n Omit<ComponentPropsWithoutRef<E>, keyof TextOwnProps<E>>;\n\n// Exhaustive over TextElement so adding a tag without classifying it fails to typecheck,\n// instead of silently leaving truncate's inline-block fix un-applied for that tag.\nconst INLINE_TEXT_ELEMENTS: Record<TextElement, boolean> = {\n p: false,\n div: false,\n span: true,\n label: true,\n strong: true,\n em: true,\n small: true,\n};\n\nexport function Text<E extends TextElement = \"p\">({\n as,\n variant = \"body\",\n size,\n weight,\n truncate = false,\n className,\n style,\n ...rest\n}: TextProps<E>) {\n const tag = as ?? \"p\";\n const sizeVars = resolveResponsive(size, \"--_text-size\", fontSizeToVar);\n const weightVars = resolveResponsive(weight, \"--_text-weight\", weightToValue);\n\n const classes = cx(\n \"ps1ui-text\",\n `ps1ui-text--${variant}`,\n truncate && \"ps1ui-text--truncate\",\n truncate && INLINE_TEXT_ELEMENTS[tag] && \"ps1ui-text--truncate-inline\",\n className,\n );\n\n // Caller style first, resolved vars last: `--_*` is the reserved internal\n // prefix and wins on purpose — responsive values are prop-controlled. Cast\n // because csstype has no index signature for `--*` keys (React 19 included).\n const mergedStyle: CSSProperties = {\n ...style,\n ...sizeVars,\n ...weightVars,\n } as CSSProperties;\n\n return createElement(tag, { ...rest, className: classes, style: mergedStyle });\n}\n"],"mappings":";;;;;AA0CA,MAAM,uBAAqD;CACzD,GAAG;CACH,KAAK;CACL,MAAM;CACN,OAAO;CACP,QAAQ;CACR,IAAI;CACJ,OAAO;AACT;AAEA,SAAgB,KAAkC,EAChD,IACA,UAAU,QACV,MACA,QACA,WAAW,OACX,WACA,OACA,GAAG,QACY;CACf,MAAM,MAAM,MAAM;CAClB,MAAM,WAAW,kBAAkB,MAAM,gBAAgB,aAAa;CACtE,MAAM,aAAa,kBAAkB,QAAQ,kBAAkB,aAAa;CAE5E,MAAM,UAAU,GACd,cACA,eAAe,WACf,YAAY,wBACZ,YAAY,qBAAqB,QAAQ,+BACzC,SACF;CAKA,MAAM,cAA6B;EACjC,GAAG;EACH,GAAG;EACH,GAAG;CACL;CAEA,OAAO,cAAc,KAAK;EAAE,GAAG;EAAM,WAAW;EAAS,OAAO;CAAY,CAAC;AAC/E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
//#region src/components/Th/Th.d.ts
|
|
3
|
+
type ThProps = ComponentProps<"th">;
|
|
4
|
+
declare function Th({ className, ...rest }: ThProps): import("react").JSX.Element;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { Th, ThProps };
|
|
7
|
+
//# sourceMappingURL=Th.d.mts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cx } from "../../utils/cx.mjs";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/Th/Th.tsx
|
|
4
|
+
function Th({ className, ...rest }) {
|
|
5
|
+
return /* @__PURE__ */ jsx("th", {
|
|
6
|
+
...rest,
|
|
7
|
+
className: cx("ps1ui-th", className)
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Th };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=Th.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Th.mjs","names":[],"sources":["../../../src/components/Th/Th.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\";\nimport { cx } from \"../../utils/cx\";\n\n// Thin typed wrapper for `<th>` inside a `<Table>`. Header-cell styling\n// lives on `.ps1ui-table th` in Table.css, so a bare `<th>` continues to\n// render identically — Th exists to give call sites a stable class hook\n// (`.ps1ui-th`) and a documented API surface for what belongs inside a\n// `<Table>` (same contract as ListItem inside List). Semantics stay native:\n// pass `scope=\"col\"` / `scope=\"row\"` exactly as you would on a raw <th>.\nexport type ThProps = ComponentProps<\"th\">;\n\nexport function Th({ className, ...rest }: ThProps) {\n return <th {...rest} className={cx(\"ps1ui-th\", className)} />;\n}\n"],"mappings":";;;AAWA,SAAgB,GAAG,EAAE,WAAW,GAAG,QAAiB;CAClD,OAAO,oBAAC,MAAD;EAAI,GAAI;EAAM,WAAW,GAAG,YAAY,SAAS;CAAI,CAAA;AAC9D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
//#region src/components/Thead/Thead.d.ts
|
|
3
|
+
type TheadProps = ComponentProps<"thead">;
|
|
4
|
+
declare function Thead({ className, ...rest }: TheadProps): import("react").JSX.Element;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { Thead, TheadProps };
|
|
7
|
+
//# sourceMappingURL=Thead.d.mts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cx } from "../../utils/cx.mjs";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/Thead/Thead.tsx
|
|
4
|
+
function Thead({ className, ...rest }) {
|
|
5
|
+
return /* @__PURE__ */ jsx("thead", {
|
|
6
|
+
...rest,
|
|
7
|
+
className: cx("ps1ui-thead", className)
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Thead };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=Thead.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Thead.mjs","names":[],"sources":["../../../src/components/Thead/Thead.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\";\nimport { cx } from \"../../utils/cx\";\n\n// Thin typed wrapper for `<thead>` inside a `<Table>`. All header styling\n// lives on `.ps1ui-table thead th` in Table.css, so a bare `<thead>`\n// continues to render identically — Thead exists to give call sites a stable\n// class hook (`.ps1ui-thead`) and a documented API surface for what belongs\n// inside a `<Table>` (same contract as ListItem inside List).\nexport type TheadProps = ComponentProps<\"thead\">;\n\nexport function Thead({ className, ...rest }: TheadProps) {\n return <thead {...rest} className={cx(\"ps1ui-thead\", className)} />;\n}\n"],"mappings":";;;AAUA,SAAgB,MAAM,EAAE,WAAW,GAAG,QAAoB;CACxD,OAAO,oBAAC,SAAD;EAAO,GAAI;EAAM,WAAW,GAAG,eAAe,SAAS;CAAI,CAAA;AACpE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
//#region src/components/Tr/Tr.d.ts
|
|
3
|
+
type TrProps = ComponentProps<"tr">;
|
|
4
|
+
declare function Tr({ className, ...rest }: TrProps): import("react").JSX.Element;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { Tr, TrProps };
|
|
7
|
+
//# sourceMappingURL=Tr.d.mts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cx } from "../../utils/cx.mjs";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/Tr/Tr.tsx
|
|
4
|
+
function Tr({ className, ...rest }) {
|
|
5
|
+
return /* @__PURE__ */ jsx("tr", {
|
|
6
|
+
...rest,
|
|
7
|
+
className: cx("ps1ui-tr", className)
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Tr };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=Tr.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tr.mjs","names":[],"sources":["../../../src/components/Tr/Tr.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\";\nimport { cx } from \"../../utils/cx\";\n\n// Thin typed wrapper for `<tr>` inside a `<Table>`. Cell styling lives on\n// `.ps1ui-table th / td` in Table.css, so a bare `<tr>` continues to render\n// identically — Tr exists to give call sites a stable class hook\n// (`.ps1ui-tr`) and a documented API surface for what belongs inside a\n// `<Table>` (same contract as ListItem inside List).\nexport type TrProps = ComponentProps<\"tr\">;\n\nexport function Tr({ className, ...rest }: TrProps) {\n return <tr {...rest} className={cx(\"ps1ui-tr\", className)} />;\n}\n"],"mappings":";;;AAUA,SAAgB,GAAG,EAAE,WAAW,GAAG,QAAiB;CAClD,OAAO,oBAAC,MAAD;EAAI,GAAI;EAAM,WAAW,GAAG,YAAY,SAAS;CAAI,CAAA;AAC9D"}
|