@carbonbits/sixr 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +204 -66
- package/dist/button.cjs +223 -0
- package/dist/button.cjs.map +1 -0
- package/dist/button.d.cts +34 -0
- package/dist/button.d.ts +34 -0
- package/dist/button.js +4 -0
- package/dist/button.js.map +1 -0
- package/dist/chunk-HDTW4FRT.js +111 -0
- package/dist/chunk-HDTW4FRT.js.map +1 -0
- package/dist/chunk-NZHHNVXZ.js +118 -0
- package/dist/chunk-NZHHNVXZ.js.map +1 -0
- package/dist/email-input.cjs +433 -0
- package/dist/email-input.cjs.map +1 -0
- package/dist/email-input.d.cts +12 -0
- package/dist/email-input.d.ts +12 -0
- package/dist/email-input.js +416 -0
- package/dist/email-input.js.map +1 -0
- package/dist/field.cjs +206 -0
- package/dist/field.cjs.map +1 -0
- package/dist/field.d.cts +80 -0
- package/dist/field.d.ts +80 -0
- package/dist/field.js +186 -0
- package/dist/field.js.map +1 -0
- package/dist/form.cjs +283 -42
- package/dist/form.cjs.map +1 -1
- package/dist/form.d.cts +79 -10
- package/dist/form.d.ts +79 -10
- package/dist/form.js +285 -45
- package/dist/form.js.map +1 -1
- package/dist/index-CdYkd6zz.d.cts +22 -0
- package/dist/index-CdYkd6zz.d.ts +22 -0
- package/dist/index.cjs +217 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +146 -46
- package/dist/index.d.ts +146 -46
- package/dist/index.js +2 -0
- package/dist/password-input.cjs +449 -0
- package/dist/password-input.cjs.map +1 -0
- package/dist/password-input.d.cts +19 -0
- package/dist/password-input.d.ts +19 -0
- package/dist/password-input.js +434 -0
- package/dist/password-input.js.map +1 -0
- package/dist/phone-input.cjs +429 -0
- package/dist/phone-input.cjs.map +1 -0
- package/dist/phone-input.d.cts +12 -0
- package/dist/phone-input.d.ts +12 -0
- package/dist/phone-input.js +412 -0
- package/dist/phone-input.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/text-input.cjs +359 -147
- package/dist/text-input.cjs.map +1 -1
- package/dist/text-input.d.cts +9 -58
- package/dist/text-input.d.ts +9 -58
- package/dist/text-input.js +365 -150
- package/dist/text-input.js.map +1 -1
- package/dist/typography.cjs +120 -0
- package/dist/typography.cjs.map +1 -0
- package/dist/typography.d.cts +46 -0
- package/dist/typography.d.ts +46 -0
- package/dist/typography.js +3 -0
- package/dist/typography.js.map +1 -0
- package/package.json +69 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var reactSlot = require('@radix-ui/react-slot');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
// src/components/typography/index.tsx
|
|
7
|
+
var DEFAULT_ELEMENT = {
|
|
8
|
+
display: "h1",
|
|
9
|
+
heading: "h2",
|
|
10
|
+
subheading: "h3",
|
|
11
|
+
body: "p",
|
|
12
|
+
label: "span",
|
|
13
|
+
hint: "p",
|
|
14
|
+
code: "code"
|
|
15
|
+
};
|
|
16
|
+
var DEFAULT_WEIGHT = {
|
|
17
|
+
display: "semibold",
|
|
18
|
+
heading: "semibold",
|
|
19
|
+
subheading: "medium",
|
|
20
|
+
body: "regular",
|
|
21
|
+
label: "semibold",
|
|
22
|
+
hint: "regular",
|
|
23
|
+
code: "regular"
|
|
24
|
+
};
|
|
25
|
+
var VARIANT_CLASSES = {
|
|
26
|
+
display: "text-display leading-tight tracking-tight",
|
|
27
|
+
heading: "text-heading leading-tight tracking-tight",
|
|
28
|
+
subheading: "text-subheading leading-snug",
|
|
29
|
+
body: "text-field leading-normal",
|
|
30
|
+
label: "text-label leading-normal",
|
|
31
|
+
hint: "text-hint leading-normal",
|
|
32
|
+
code: "font-code text-field leading-normal"
|
|
33
|
+
};
|
|
34
|
+
var TONE_CLASSES = {
|
|
35
|
+
default: "text-fg",
|
|
36
|
+
muted: "text-fg-muted",
|
|
37
|
+
subtle: "text-fg-subtle",
|
|
38
|
+
accent: "text-accent",
|
|
39
|
+
"on-accent": "text-on-accent",
|
|
40
|
+
success: "text-success",
|
|
41
|
+
warning: "text-warning",
|
|
42
|
+
info: "text-info",
|
|
43
|
+
danger: "text-danger"
|
|
44
|
+
};
|
|
45
|
+
var WEIGHT_CLASSES = {
|
|
46
|
+
regular: "font-normal",
|
|
47
|
+
medium: "font-medium",
|
|
48
|
+
semibold: "font-semibold",
|
|
49
|
+
bold: "font-bold"
|
|
50
|
+
};
|
|
51
|
+
var ALIGN_CLASSES = {
|
|
52
|
+
start: "text-start",
|
|
53
|
+
center: "text-center",
|
|
54
|
+
end: "text-end"
|
|
55
|
+
};
|
|
56
|
+
var ICON_CLASSES = "inline-flex shrink-0 items-center [&>svg]:h-[1em] [&>svg]:w-[1em]";
|
|
57
|
+
function typographyClassName({
|
|
58
|
+
variant,
|
|
59
|
+
tone,
|
|
60
|
+
weight,
|
|
61
|
+
align,
|
|
62
|
+
truncate,
|
|
63
|
+
hasIcon,
|
|
64
|
+
className
|
|
65
|
+
}) {
|
|
66
|
+
return [
|
|
67
|
+
VARIANT_CLASSES[variant],
|
|
68
|
+
TONE_CLASSES[tone],
|
|
69
|
+
WEIGHT_CLASSES[weight],
|
|
70
|
+
align ? ALIGN_CLASSES[align] : "",
|
|
71
|
+
hasIcon ? "inline-flex items-center gap-1.5" : "",
|
|
72
|
+
// With an icon the root is a flex container, and text-overflow only
|
|
73
|
+
// clips block text, so the text span carries the truncation instead.
|
|
74
|
+
truncate && !hasIcon ? "truncate" : "",
|
|
75
|
+
className ?? ""
|
|
76
|
+
].filter(Boolean).join(" ");
|
|
77
|
+
}
|
|
78
|
+
function Typography({
|
|
79
|
+
variant = "body",
|
|
80
|
+
tone = "default",
|
|
81
|
+
weight,
|
|
82
|
+
align,
|
|
83
|
+
truncate = false,
|
|
84
|
+
icon,
|
|
85
|
+
iconPosition = "leading",
|
|
86
|
+
as,
|
|
87
|
+
asChild = false,
|
|
88
|
+
className,
|
|
89
|
+
children,
|
|
90
|
+
...rest
|
|
91
|
+
}) {
|
|
92
|
+
const hasIcon = icon !== void 0 && icon !== null;
|
|
93
|
+
const Component = asChild ? reactSlot.Slot : as ?? DEFAULT_ELEMENT[variant];
|
|
94
|
+
const iconNode = hasIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: ICON_CLASSES, children: icon }) : null;
|
|
95
|
+
const content = hasIcon ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
96
|
+
iconPosition === "leading" ? iconNode : null,
|
|
97
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: truncate ? "min-w-0 truncate" : void 0, children }),
|
|
98
|
+
iconPosition === "trailing" ? iconNode : null
|
|
99
|
+
] }) : children;
|
|
100
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
101
|
+
Component,
|
|
102
|
+
{
|
|
103
|
+
...rest,
|
|
104
|
+
className: typographyClassName({
|
|
105
|
+
variant,
|
|
106
|
+
tone,
|
|
107
|
+
weight: weight ?? DEFAULT_WEIGHT[variant],
|
|
108
|
+
align,
|
|
109
|
+
truncate,
|
|
110
|
+
hasIcon,
|
|
111
|
+
className
|
|
112
|
+
}),
|
|
113
|
+
children: content
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
exports.Typography = Typography;
|
|
119
|
+
//# sourceMappingURL=typography.cjs.map
|
|
120
|
+
//# sourceMappingURL=typography.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/typography/index.tsx"],"names":["Slot","jsx","jsxs","Fragment"],"mappings":";;;;;;AA+EA,IAAM,eAAA,GAAgE;AAAA,EACpE,OAAA,EAAS,IAAA;AAAA,EACT,OAAA,EAAS,IAAA;AAAA,EACT,UAAA,EAAY,IAAA;AAAA,EACZ,IAAA,EAAM,GAAA;AAAA,EACN,KAAA,EAAO,MAAA;AAAA,EACP,I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,GAAqB,QAC9C,QAAA,EACH,CAAA;AAAA,IACC,YAAA,KAAiB,aAAa,QAAA,GAAW;AAAA,GAAA,EAC5C,CAAA,GAEA,QAAA;AAGF,EAAA,uBACEF,cAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,WAAW,mBAAA,CAAoB;AAAA,QAC7B,OAAA;AAAA,QACA,IAAA;AAAA,QACA,MAAA,EAAQ,MAAA,IAAU,cAAA,CAAe,OAAO,CAAA;AAAA,QACxC,KAAA;AAAA,QACA,QAAA;AAAA,QACA,OAAA;AAAA,QACA;AAAA,OACD,CAAA;AAAA,MAEA,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"typography.cjs","sourcesContent":["import { Slot } from \"@radix-ui/react-slot\";\nimport type { ElementType, HTMLAttributes, ReactNode, Ref } from \"react\";\n\n/**\n * The library's type scale. Everything that renders text — field labels, hints,\n * form errors, headings — goes through here, so a size or colour lives in one\n * place and the tokens in `src/styles/index.css` stay the single source of\n * truth for what \"hint\" or \"muted\" means.\n *\n * Server-safe: no state, no handlers, no directive. It composes Radix `Slot`\n * for `asChild`, which is how a consumer puts these styles on their own\n * element (a `next/link`, a Radix `Label`) without an extra wrapper.\n */\n\nexport type TypographyVariant =\n | \"display\"\n | \"heading\"\n | \"subheading\"\n | \"body\"\n | \"label\"\n | \"hint\"\n | \"code\";\n\nexport type TypographyTone =\n | \"default\"\n | \"muted\"\n | \"subtle\"\n | \"accent\"\n | \"on-accent\"\n | \"success\"\n | \"warning\"\n | \"info\"\n | \"danger\";\n\nexport type TypographyWeight = \"regular\" | \"medium\" | \"semibold\" | \"bold\";\n\nexport type TypographyElement =\n | \"p\"\n | \"span\"\n | \"div\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"label\"\n | \"code\"\n | \"strong\"\n | \"em\"\n | \"small\";\n\nexport type TypographyProps = Omit<HTMLAttributes<HTMLElement>, \"color\"> & {\n /** Size and default element. `body` unless told otherwise. */\n variant?: TypographyVariant;\n /** Colour role, from the design tokens. */\n tone?: TypographyTone;\n /** Overrides the variant's default weight. */\n weight?: TypographyWeight;\n align?: \"start\" | \"center\" | \"end\";\n /** Clip to one line with an ellipsis. */\n truncate?: boolean;\n /**\n * An icon rendered beside the text, hidden from assistive tech. Sized to the\n * text with `1em`, so the same SVG fits every variant.\n */\n icon?: ReactNode;\n iconPosition?: \"leading\" | \"trailing\";\n /** The element to render. Defaults per variant (`h2` for a heading, and so on). */\n as?: TypographyElement;\n /**\n * Radix-style composition: render the child element itself, with these\n * styles merged onto it, instead of a wrapper. Takes precedence over `as`.\n */\n asChild?: boolean;\n ref?: Ref<HTMLElement>;\n children?: ReactNode;\n};\n\nconst DEFAULT_ELEMENT: Record<TypographyVariant, TypographyElement> = {\n display: \"h1\",\n heading: \"h2\",\n subheading: \"h3\",\n body: \"p\",\n label: \"span\",\n hint: \"p\",\n code: \"code\",\n};\n\nconst DEFAULT_WEIGHT: Record<TypographyVariant, TypographyWeight> = {\n display: \"semibold\",\n heading: \"semibold\",\n subheading: \"medium\",\n body: \"regular\",\n label: \"semibold\",\n hint: \"regular\",\n code: \"regular\",\n};\n\nconst VARIANT_CLASSES: Record<TypographyVariant, string> = {\n display: \"text-display leading-tight tracking-tight\",\n heading: \"text-heading leading-tight tracking-tight\",\n subheading: \"text-subheading leading-snug\",\n body: \"text-field leading-normal\",\n label: \"text-label leading-normal\",\n hint: \"text-hint leading-normal\",\n code: \"font-code text-field leading-normal\",\n};\n\nconst TONE_CLASSES: Record<TypographyTone, string> = {\n default: \"text-fg\",\n muted: \"text-fg-muted\",\n subtle: \"text-fg-subtle\",\n accent: \"text-accent\",\n \"on-accent\": \"text-on-accent\",\n success: \"text-success\",\n warning: \"text-warning\",\n info: \"text-info\",\n danger: \"text-danger\",\n};\n\nconst WEIGHT_CLASSES: Record<TypographyWeight, string> = {\n regular: \"font-normal\",\n medium: \"font-medium\",\n semibold: \"font-semibold\",\n bold: \"font-bold\",\n};\n\nconst ALIGN_CLASSES = {\n start: \"text-start\",\n center: \"text-center\",\n end: \"text-end\",\n} as const;\n\nconst ICON_CLASSES =\n \"inline-flex shrink-0 items-center [&>svg]:h-[1em] [&>svg]:w-[1em]\";\n\nfunction typographyClassName({\n variant,\n tone,\n weight,\n align,\n truncate,\n hasIcon,\n className,\n}: {\n variant: TypographyVariant;\n tone: TypographyTone;\n weight: TypographyWeight;\n align: \"start\" | \"center\" | \"end\" | undefined;\n truncate: boolean;\n hasIcon: boolean;\n className: string | undefined;\n}): string {\n return [\n VARIANT_CLASSES[variant],\n TONE_CLASSES[tone],\n WEIGHT_CLASSES[weight],\n align ? ALIGN_CLASSES[align] : \"\",\n hasIcon ? \"inline-flex items-center gap-1.5\" : \"\",\n // With an icon the root is a flex container, and text-overflow only\n // clips block text, so the text span carries the truncation instead.\n truncate && !hasIcon ? \"truncate\" : \"\",\n className ?? \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n}\n\nexport function Typography({\n variant = \"body\",\n tone = \"default\",\n weight,\n align,\n truncate = false,\n icon,\n iconPosition = \"leading\",\n as,\n asChild = false,\n className,\n children,\n ...rest\n}: TypographyProps) {\n const hasIcon = icon !== undefined && icon !== null;\n // Widened to `ElementType`: the union of intrinsic tags would otherwise\n // demand a `ref` typed to one specific element.\n const Component: ElementType = asChild\n ? Slot\n : (as ?? DEFAULT_ELEMENT[variant]);\n\n const iconNode = hasIcon ? (\n <span aria-hidden=\"true\" className={ICON_CLASSES}>\n {icon}\n </span>\n ) : null;\n\n const content = hasIcon ? (\n <>\n {iconPosition === \"leading\" ? iconNode : null}\n <span className={truncate ? \"min-w-0 truncate\" : undefined}>\n {children}\n </span>\n {iconPosition === \"trailing\" ? iconNode : null}\n </>\n ) : (\n children\n );\n\n return (\n <Component\n {...rest}\n className={typographyClassName({\n variant,\n tone,\n weight: weight ?? DEFAULT_WEIGHT[variant],\n align,\n truncate,\n hasIcon,\n className,\n })}\n >\n {content}\n </Component>\n );\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes, ReactNode, Ref } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The library's type scale. Everything that renders text — field labels, hints,
|
|
6
|
+
* form errors, headings — goes through here, so a size or colour lives in one
|
|
7
|
+
* place and the tokens in `src/styles/index.css` stay the single source of
|
|
8
|
+
* truth for what "hint" or "muted" means.
|
|
9
|
+
*
|
|
10
|
+
* Server-safe: no state, no handlers, no directive. It composes Radix `Slot`
|
|
11
|
+
* for `asChild`, which is how a consumer puts these styles on their own
|
|
12
|
+
* element (a `next/link`, a Radix `Label`) without an extra wrapper.
|
|
13
|
+
*/
|
|
14
|
+
type TypographyVariant = "display" | "heading" | "subheading" | "body" | "label" | "hint" | "code";
|
|
15
|
+
type TypographyTone = "default" | "muted" | "subtle" | "accent" | "on-accent" | "success" | "warning" | "info" | "danger";
|
|
16
|
+
type TypographyWeight = "regular" | "medium" | "semibold" | "bold";
|
|
17
|
+
type TypographyElement = "p" | "span" | "div" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "label" | "code" | "strong" | "em" | "small";
|
|
18
|
+
type TypographyProps = Omit<HTMLAttributes<HTMLElement>, "color"> & {
|
|
19
|
+
/** Size and default element. `body` unless told otherwise. */
|
|
20
|
+
variant?: TypographyVariant;
|
|
21
|
+
/** Colour role, from the design tokens. */
|
|
22
|
+
tone?: TypographyTone;
|
|
23
|
+
/** Overrides the variant's default weight. */
|
|
24
|
+
weight?: TypographyWeight;
|
|
25
|
+
align?: "start" | "center" | "end";
|
|
26
|
+
/** Clip to one line with an ellipsis. */
|
|
27
|
+
truncate?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* An icon rendered beside the text, hidden from assistive tech. Sized to the
|
|
30
|
+
* text with `1em`, so the same SVG fits every variant.
|
|
31
|
+
*/
|
|
32
|
+
icon?: ReactNode;
|
|
33
|
+
iconPosition?: "leading" | "trailing";
|
|
34
|
+
/** The element to render. Defaults per variant (`h2` for a heading, and so on). */
|
|
35
|
+
as?: TypographyElement;
|
|
36
|
+
/**
|
|
37
|
+
* Radix-style composition: render the child element itself, with these
|
|
38
|
+
* styles merged onto it, instead of a wrapper. Takes precedence over `as`.
|
|
39
|
+
*/
|
|
40
|
+
asChild?: boolean;
|
|
41
|
+
ref?: Ref<HTMLElement>;
|
|
42
|
+
children?: ReactNode;
|
|
43
|
+
};
|
|
44
|
+
declare function Typography({ variant, tone, weight, align, truncate, icon, iconPosition, as, asChild, className, children, ...rest }: TypographyProps): react.JSX.Element;
|
|
45
|
+
|
|
46
|
+
export { Typography, type TypographyElement, type TypographyProps, type TypographyTone, type TypographyVariant, type TypographyWeight };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes, ReactNode, Ref } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The library's type scale. Everything that renders text — field labels, hints,
|
|
6
|
+
* form errors, headings — goes through here, so a size or colour lives in one
|
|
7
|
+
* place and the tokens in `src/styles/index.css` stay the single source of
|
|
8
|
+
* truth for what "hint" or "muted" means.
|
|
9
|
+
*
|
|
10
|
+
* Server-safe: no state, no handlers, no directive. It composes Radix `Slot`
|
|
11
|
+
* for `asChild`, which is how a consumer puts these styles on their own
|
|
12
|
+
* element (a `next/link`, a Radix `Label`) without an extra wrapper.
|
|
13
|
+
*/
|
|
14
|
+
type TypographyVariant = "display" | "heading" | "subheading" | "body" | "label" | "hint" | "code";
|
|
15
|
+
type TypographyTone = "default" | "muted" | "subtle" | "accent" | "on-accent" | "success" | "warning" | "info" | "danger";
|
|
16
|
+
type TypographyWeight = "regular" | "medium" | "semibold" | "bold";
|
|
17
|
+
type TypographyElement = "p" | "span" | "div" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "label" | "code" | "strong" | "em" | "small";
|
|
18
|
+
type TypographyProps = Omit<HTMLAttributes<HTMLElement>, "color"> & {
|
|
19
|
+
/** Size and default element. `body` unless told otherwise. */
|
|
20
|
+
variant?: TypographyVariant;
|
|
21
|
+
/** Colour role, from the design tokens. */
|
|
22
|
+
tone?: TypographyTone;
|
|
23
|
+
/** Overrides the variant's default weight. */
|
|
24
|
+
weight?: TypographyWeight;
|
|
25
|
+
align?: "start" | "center" | "end";
|
|
26
|
+
/** Clip to one line with an ellipsis. */
|
|
27
|
+
truncate?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* An icon rendered beside the text, hidden from assistive tech. Sized to the
|
|
30
|
+
* text with `1em`, so the same SVG fits every variant.
|
|
31
|
+
*/
|
|
32
|
+
icon?: ReactNode;
|
|
33
|
+
iconPosition?: "leading" | "trailing";
|
|
34
|
+
/** The element to render. Defaults per variant (`h2` for a heading, and so on). */
|
|
35
|
+
as?: TypographyElement;
|
|
36
|
+
/**
|
|
37
|
+
* Radix-style composition: render the child element itself, with these
|
|
38
|
+
* styles merged onto it, instead of a wrapper. Takes precedence over `as`.
|
|
39
|
+
*/
|
|
40
|
+
asChild?: boolean;
|
|
41
|
+
ref?: Ref<HTMLElement>;
|
|
42
|
+
children?: ReactNode;
|
|
43
|
+
};
|
|
44
|
+
declare function Typography({ variant, tone, weight, align, truncate, icon, iconPosition, as, asChild, className, children, ...rest }: TypographyProps): react.JSX.Element;
|
|
45
|
+
|
|
46
|
+
export { Typography, type TypographyElement, type TypographyProps, type TypographyTone, type TypographyVariant, type TypographyWeight };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"typography.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbonbits/sixr",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "e-commerce geared component library",
|
|
5
5
|
"homepage": "https://carbonbits.co.ke/sixr",
|
|
6
6
|
"repository": {
|
|
@@ -32,6 +32,16 @@
|
|
|
32
32
|
"default": "./dist/index.cjs"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
+
"./button": {
|
|
36
|
+
"import": {
|
|
37
|
+
"types": "./dist/button.d.ts",
|
|
38
|
+
"default": "./dist/button.js"
|
|
39
|
+
},
|
|
40
|
+
"require": {
|
|
41
|
+
"types": "./dist/button.d.cts",
|
|
42
|
+
"default": "./dist/button.cjs"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
35
45
|
"./cart": {
|
|
36
46
|
"import": {
|
|
37
47
|
"types": "./dist/cart.d.ts",
|
|
@@ -42,6 +52,16 @@
|
|
|
42
52
|
"default": "./dist/cart.cjs"
|
|
43
53
|
}
|
|
44
54
|
},
|
|
55
|
+
"./typography": {
|
|
56
|
+
"import": {
|
|
57
|
+
"types": "./dist/typography.d.ts",
|
|
58
|
+
"default": "./dist/typography.js"
|
|
59
|
+
},
|
|
60
|
+
"require": {
|
|
61
|
+
"types": "./dist/typography.d.cts",
|
|
62
|
+
"default": "./dist/typography.cjs"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
45
65
|
"./text-input": {
|
|
46
66
|
"import": {
|
|
47
67
|
"types": "./dist/text-input.d.ts",
|
|
@@ -52,6 +72,46 @@
|
|
|
52
72
|
"default": "./dist/text-input.cjs"
|
|
53
73
|
}
|
|
54
74
|
},
|
|
75
|
+
"./email-input": {
|
|
76
|
+
"import": {
|
|
77
|
+
"types": "./dist/email-input.d.ts",
|
|
78
|
+
"default": "./dist/email-input.js"
|
|
79
|
+
},
|
|
80
|
+
"require": {
|
|
81
|
+
"types": "./dist/email-input.d.cts",
|
|
82
|
+
"default": "./dist/email-input.cjs"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"./password-input": {
|
|
86
|
+
"import": {
|
|
87
|
+
"types": "./dist/password-input.d.ts",
|
|
88
|
+
"default": "./dist/password-input.js"
|
|
89
|
+
},
|
|
90
|
+
"require": {
|
|
91
|
+
"types": "./dist/password-input.d.cts",
|
|
92
|
+
"default": "./dist/password-input.cjs"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"./phone-input": {
|
|
96
|
+
"import": {
|
|
97
|
+
"types": "./dist/phone-input.d.ts",
|
|
98
|
+
"default": "./dist/phone-input.js"
|
|
99
|
+
},
|
|
100
|
+
"require": {
|
|
101
|
+
"types": "./dist/phone-input.d.cts",
|
|
102
|
+
"default": "./dist/phone-input.cjs"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"./field": {
|
|
106
|
+
"import": {
|
|
107
|
+
"types": "./dist/field.d.ts",
|
|
108
|
+
"default": "./dist/field.js"
|
|
109
|
+
},
|
|
110
|
+
"require": {
|
|
111
|
+
"types": "./dist/field.d.cts",
|
|
112
|
+
"default": "./dist/field.cjs"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
55
115
|
"./form": {
|
|
56
116
|
"import": {
|
|
57
117
|
"types": "./dist/form.d.ts",
|
|
@@ -99,6 +159,7 @@
|
|
|
99
159
|
"peerDependencies": {
|
|
100
160
|
"react": "^19.0.0",
|
|
101
161
|
"react-dom": "^19.0.0",
|
|
162
|
+
"react-hook-form": "^7.89.0",
|
|
102
163
|
"zod": "^4.0.0"
|
|
103
164
|
},
|
|
104
165
|
"peerDependenciesMeta": {
|
|
@@ -131,6 +192,7 @@
|
|
|
131
192
|
"jsdom": "^30.1.0",
|
|
132
193
|
"react": "^19.3.0",
|
|
133
194
|
"react-dom": "^19.3.0",
|
|
195
|
+
"react-hook-form": "^7.89.0",
|
|
134
196
|
"semantic-release": "^25.0.9",
|
|
135
197
|
"storybook": "^10.6.0",
|
|
136
198
|
"tailwindcss": "^4.3.3",
|
|
@@ -139,5 +201,11 @@
|
|
|
139
201
|
"vite": "^8.3.0",
|
|
140
202
|
"vitest": "^5.0.1",
|
|
141
203
|
"zod": "^4.0.0"
|
|
204
|
+
},
|
|
205
|
+
"dependencies": {
|
|
206
|
+
"@hookform/resolvers": "^5.9.1",
|
|
207
|
+
"@radix-ui/react-label": "^2.1.15",
|
|
208
|
+
"@radix-ui/react-slot": "^1.3.3",
|
|
209
|
+
"@standard-schema/spec": "^1.1.0"
|
|
142
210
|
}
|
|
143
211
|
}
|