@prizmui/components 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.
Files changed (49) hide show
  1. package/dist/components/Button/Button.d.ts +4 -0
  2. package/dist/components/Button/Button.d.ts.map +1 -0
  3. package/dist/components/Button/Button.js +8 -0
  4. package/dist/components/Button/Button.types.d.ts +24 -0
  5. package/dist/components/Button/Button.types.d.ts.map +1 -0
  6. package/dist/components/Button/Button.types.js +1 -0
  7. package/dist/components/Button/index.d.ts +4 -0
  8. package/dist/components/Button/index.d.ts.map +1 -0
  9. package/dist/components/Button/index.js +2 -0
  10. package/dist/components/Button/renderButton.d.ts +4 -0
  11. package/dist/components/Button/renderButton.d.ts.map +1 -0
  12. package/dist/components/Button/renderButton.js +6 -0
  13. package/dist/components/Button/useButton.d.ts +3 -0
  14. package/dist/components/Button/useButton.d.ts.map +1 -0
  15. package/dist/components/Button/useButton.js +14 -0
  16. package/dist/components/Button/useButtonStyles.styles.d.ts +5 -0
  17. package/dist/components/Button/useButtonStyles.styles.d.ts.map +1 -0
  18. package/dist/components/Button/useButtonStyles.styles.js +137 -0
  19. package/dist/components/FluidProvider/FluidProvider.d.ts +4 -0
  20. package/dist/components/FluidProvider/FluidProvider.d.ts.map +1 -0
  21. package/dist/components/FluidProvider/FluidProvider.js +28 -0
  22. package/dist/components/FluidProvider/FluidProvider.types.d.ts +7 -0
  23. package/dist/components/FluidProvider/FluidProvider.types.d.ts.map +1 -0
  24. package/dist/components/FluidProvider/FluidProvider.types.js +1 -0
  25. package/dist/components/FluidProvider/index.d.ts +3 -0
  26. package/dist/components/FluidProvider/index.d.ts.map +1 -0
  27. package/dist/components/FluidProvider/index.js +1 -0
  28. package/dist/components/PrizmProvider/PrizmProvider.d.ts +4 -0
  29. package/dist/components/PrizmProvider/PrizmProvider.d.ts.map +1 -0
  30. package/dist/components/PrizmProvider/PrizmProvider.js +28 -0
  31. package/dist/components/PrizmProvider/PrizmProvider.types.d.ts +7 -0
  32. package/dist/components/PrizmProvider/PrizmProvider.types.d.ts.map +1 -0
  33. package/dist/components/PrizmProvider/PrizmProvider.types.js +1 -0
  34. package/dist/components/PrizmProvider/index.d.ts +3 -0
  35. package/dist/components/PrizmProvider/index.d.ts.map +1 -0
  36. package/dist/components/PrizmProvider/index.js +1 -0
  37. package/dist/index.d.ts +5 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +2 -0
  40. package/dist/utilities/assertSlots.d.ts +31 -0
  41. package/dist/utilities/assertSlots.d.ts.map +1 -0
  42. package/dist/utilities/assertSlots.js +52 -0
  43. package/dist/utilities/index.d.ts +3 -0
  44. package/dist/utilities/index.d.ts.map +1 -0
  45. package/dist/utilities/index.js +1 -0
  46. package/dist/utilities/types.d.ts +117 -0
  47. package/dist/utilities/types.d.ts.map +1 -0
  48. package/dist/utilities/types.js +1 -0
  49. package/package.json +32 -0
@@ -0,0 +1,4 @@
1
+ import { FC } from 'jsx-framework-test-pb';
2
+ import type { ButtonProps } from './Button.types';
3
+ export declare const Button: FC<ButtonProps>;
4
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKlD,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,CAMlC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { useButton } from './useButton';
2
+ import { renderButton } from './renderButton';
3
+ import { useButtonStyles } from './useButtonStyles.styles';
4
+ export const Button = (props) => {
5
+ const state = useButton(props);
6
+ useButtonStyles(state);
7
+ return renderButton(state);
8
+ };
@@ -0,0 +1,24 @@
1
+ import type { ARIAButtonSlotProps, ComponentProps, ComponentState, Slot } from '../../utilities';
2
+ export type ButtonSlots = {
3
+ root: NonNullable<Slot<ARIAButtonSlotProps<'a'>>>;
4
+ };
5
+ export type ButtonProps = ComponentProps<ButtonSlots> & {
6
+ /**
7
+ * @default 'secondary'
8
+ */
9
+ appearance?: 'primary' | 'secondary' | 'tertiary' | 'ghost';
10
+ /**
11
+ * @default false
12
+ */
13
+ disabled?: boolean;
14
+ /**
15
+ * @default 'rounded'
16
+ */
17
+ shape?: 'rounded' | 'circular' | 'square';
18
+ /**
19
+ * @default 'medium'
20
+ */
21
+ size?: 'small' | 'medium' | 'large';
22
+ };
23
+ export type ButtonState = ComponentState<ButtonSlots> & Required<Pick<ButtonProps, 'appearance' | 'disabled' | 'shape' | 'size'>>;
24
+ //# sourceMappingURL=Button.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEjG,MAAM,MAAM,WAAW,GAAG;IACtB,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,GAAG;IACpD;;OAEG;IAEH,UAAU,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC;IAE5D;;OAEG;IAEH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IAEH,KAAK,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAE1C;;OAEG;IAEH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,GACjD,QAAQ,CACJ,IAAI,CACA,WAAW,EACX,YAAY,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAC/C,CACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export { Button } from './Button';
2
+ export type { ButtonProps, ButtonSlots, ButtonState } from './Button.types';
3
+ export { buttonClassNames } from './useButtonStyles.styles';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Button } from './Button';
2
+ export { buttonClassNames } from './useButtonStyles.styles';
@@ -0,0 +1,4 @@
1
+ import type { JSXElement } from '../../utilities';
2
+ import type { ButtonState } from './Button.types';
3
+ export declare const renderButton: (state: ButtonState) => JSXElement;
4
+ //# sourceMappingURL=renderButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderButton.d.ts","sourceRoot":"","sources":["../../../src/components/Button/renderButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/D,eAAO,MAAM,YAAY,GAAI,OAAO,WAAW,KAAG,UAQjD,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "jsx-framework-test-pb/jsx-runtime";
2
+ import { assertSlots } from '../../utilities';
3
+ export const renderButton = (state) => {
4
+ assertSlots(state);
5
+ return (_jsx(state.root, { children: state.root.children }));
6
+ };
@@ -0,0 +1,3 @@
1
+ import type { ButtonProps, ButtonState } from './Button.types';
2
+ export declare const useButton: (props: ButtonProps) => ButtonState;
3
+ //# sourceMappingURL=useButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useButton.d.ts","sourceRoot":"","sources":["../../../src/components/Button/useButton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/D,eAAO,MAAM,SAAS,GAAI,OAAO,WAAW,KAAG,WAiB9C,CAAC"}
@@ -0,0 +1,14 @@
1
+ export const useButton = (props) => {
2
+ const { appearance, disabled, shape, size } = props;
3
+ const state = {
4
+ appearance: appearance ?? 'secondary',
5
+ disabled: disabled ?? false,
6
+ shape: shape ?? 'rounded',
7
+ size: size ?? 'medium',
8
+ components: { root: 'button' },
9
+ root: {
10
+ type: props.as !== 'a' ? 'button' : undefined
11
+ }
12
+ };
13
+ return state;
14
+ };
@@ -0,0 +1,5 @@
1
+ import type { SlotClassNames } from '../../utilities';
2
+ import type { ButtonSlots, ButtonState } from './Button.types';
3
+ export declare const buttonClassNames: SlotClassNames<ButtonSlots>;
4
+ export declare const useButtonStyles: (state: ButtonState) => ButtonState;
5
+ //# sourceMappingURL=useButtonStyles.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useButtonStyles.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Button/useButtonStyles.styles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG/D,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAAC,WAAW,CAExD,CAAC;AA0JF,eAAO,MAAM,eAAe,GAAI,OAAO,WAAW,KAAG,WAsBpD,CAAC"}
@@ -0,0 +1,137 @@
1
+ import { makeResetStyles, makeStyles, mergeClasses, shorthands } from 'calame';
2
+ import { tokens } from '@prizmui/tokens';
3
+ export const buttonClassNames = {
4
+ root: 'c-button',
5
+ };
6
+ const useRootBaseClassName = makeResetStyles({
7
+ alignItems: 'center',
8
+ boxSizing: 'border-box',
9
+ display: 'inline-flex',
10
+ justifyContent: 'center',
11
+ textDecorationLine: 'none',
12
+ verticalAlign: 'middle',
13
+ margin: 0,
14
+ overflow: 'hidden',
15
+ cursor: 'pointer',
16
+ outlineStyle: 'none',
17
+ backgroundColor: tokens.colorNeutralBackground1,
18
+ color: tokens.colorNeutralForeground1,
19
+ border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke1}`,
20
+ fontFamily: tokens.fontFamilyBase,
21
+ fontSize: tokens.fontSizeBase300,
22
+ fontWeight: tokens.fontWeightSemibold,
23
+ lineHeight: tokens.lineHeightBase300,
24
+ padding: `5px ${tokens.spacingHorizontalM}`,
25
+ minWidth: '96px',
26
+ borderRadius: tokens.borderRadiusMedium,
27
+ transitionDuration: tokens.durationFaster,
28
+ transitionProperty: 'background, border, color',
29
+ transitionTimingFunction: tokens.curveEasyEase,
30
+ ':hover': {
31
+ backgroundColor: tokens.colorNeutralBackground1Hover,
32
+ ...shorthands.borderColor(tokens.colorNeutralStroke1),
33
+ color: tokens.colorNeutralForeground1,
34
+ },
35
+ ':active': {
36
+ backgroundColor: tokens.colorNeutralBackground1Pressed,
37
+ ...shorthands.borderColor(tokens.colorNeutralStroke1),
38
+ color: tokens.colorNeutralForeground1,
39
+ },
40
+ });
41
+ const useRootStyles = makeStyles({
42
+ primary: {
43
+ backgroundColor: tokens.colorBrandBackground,
44
+ ...shorthands.borderColor('transparent'),
45
+ color: tokens.colorNeutralForegroundOnBrand,
46
+ ':hover': {
47
+ backgroundColor: tokens.colorBrandBackgroundHover,
48
+ ...shorthands.borderColor('transparent'),
49
+ color: tokens.colorNeutralForegroundOnBrand,
50
+ },
51
+ ':active': {
52
+ backgroundColor: tokens.colorBrandBackgroundPressed,
53
+ ...shorthands.borderColor('transparent'),
54
+ color: tokens.colorNeutralForegroundOnBrand,
55
+ },
56
+ },
57
+ secondary: {},
58
+ tertiary: {
59
+ backgroundColor: 'transparent',
60
+ ...shorthands.borderColor('transparent'),
61
+ color: tokens.colorNeutralForeground1,
62
+ ':hover': {
63
+ backgroundColor: tokens.colorNeutralBackground1Hover,
64
+ ...shorthands.borderColor('transparent'),
65
+ },
66
+ ':active': {
67
+ backgroundColor: tokens.colorNeutralBackground1Pressed,
68
+ ...shorthands.borderColor('transparent'),
69
+ },
70
+ },
71
+ ghost: {
72
+ backgroundColor: 'transparent',
73
+ ...shorthands.borderColor('transparent'),
74
+ color: tokens.colorBrandForeground1,
75
+ ':hover': {
76
+ backgroundColor: tokens.colorNeutralBackground1Hover,
77
+ ...shorthands.borderColor('transparent'),
78
+ color: tokens.colorBrandForeground2,
79
+ },
80
+ ':active': {
81
+ backgroundColor: tokens.colorNeutralBackground1Pressed,
82
+ ...shorthands.borderColor('transparent'),
83
+ color: tokens.colorBrandForeground2,
84
+ },
85
+ },
86
+ rounded: {},
87
+ circular: {
88
+ borderRadius: tokens.borderRadiusCircular,
89
+ },
90
+ square: {
91
+ borderRadius: tokens.borderRadiusNone,
92
+ },
93
+ small: {
94
+ fontSize: tokens.fontSizeBase200,
95
+ fontWeight: tokens.fontWeightRegular,
96
+ lineHeight: tokens.lineHeightBase200,
97
+ padding: `3px ${tokens.spacingHorizontalS}`,
98
+ minWidth: '64px',
99
+ },
100
+ medium: {},
101
+ large: {
102
+ fontSize: tokens.fontSizeBase400,
103
+ lineHeight: tokens.lineHeightBase400,
104
+ padding: `8px ${tokens.spacingHorizontalL}`,
105
+ minWidth: '96px',
106
+ },
107
+ });
108
+ const useRootDisabledStyles = makeStyles({
109
+ base: {
110
+ cursor: 'not-allowed',
111
+ backgroundColor: tokens.colorNeutralBackgroundDisabled,
112
+ ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),
113
+ color: tokens.colorNeutralForegroundDisabled,
114
+ ':hover': {
115
+ backgroundColor: tokens.colorNeutralBackgroundDisabled,
116
+ ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),
117
+ color: tokens.colorNeutralForegroundDisabled,
118
+ },
119
+ ':active': {
120
+ backgroundColor: tokens.colorNeutralBackgroundDisabled,
121
+ ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),
122
+ color: tokens.colorNeutralForegroundDisabled,
123
+ },
124
+ },
125
+ primary: {},
126
+ secondary: {},
127
+ tertiary: {},
128
+ ghost: {},
129
+ });
130
+ export const useButtonStyles = (state) => {
131
+ const rootBaseClassName = useRootBaseClassName();
132
+ const rootStyles = useRootStyles();
133
+ const rootDisabledStyles = useRootDisabledStyles();
134
+ const { appearance, disabled, shape, size } = state;
135
+ state.root.className = mergeClasses(buttonClassNames.root, rootBaseClassName, rootStyles[appearance], rootStyles[shape], rootStyles[size], disabled && rootDisabledStyles.base, disabled && rootDisabledStyles[appearance], state.root.className);
136
+ return state;
137
+ };
@@ -0,0 +1,4 @@
1
+ import type { FC } from 'jsx-framework-test-pb';
2
+ import type { FluidProviderProps } from './FluidProvider.types';
3
+ export declare const FluidProvider: FC<FluidProviderProps>;
4
+ //# sourceMappingURL=FluidProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FluidProvider.d.ts","sourceRoot":"","sources":["../../../src/components/FluidProvider/FluidProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAgChE,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAGhD,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "jsx-framework-test-pb/jsx-runtime";
2
+ const injectedThemes = new Map();
3
+ function hashTheme(theme) {
4
+ const str = Object.entries(theme).join('');
5
+ let h = 5381;
6
+ for (let i = 0; i < str.length; i++) {
7
+ h = ((h << 5) + h) ^ str.charCodeAt(i);
8
+ }
9
+ return (h >>> 0).toString(36);
10
+ }
11
+ function getThemeClassName(theme) {
12
+ const hash = hashTheme(theme);
13
+ const className = `fluid-${hash}`;
14
+ if (!injectedThemes.has(className)) {
15
+ const vars = Object.entries(theme)
16
+ .map(([key, value]) => `--${key}: ${value}`)
17
+ .join('; ');
18
+ const style = document.createElement('style');
19
+ style.textContent = `.${className} { ${vars} }`;
20
+ document.head.appendChild(style);
21
+ injectedThemes.set(className, hash);
22
+ }
23
+ return className;
24
+ }
25
+ export const FluidProvider = ({ theme, children }) => {
26
+ const className = getThemeClassName(theme);
27
+ return _jsx("div", { className: className, children: children });
28
+ };
@@ -0,0 +1,7 @@
1
+ import type { ElementChild } from 'jsx-framework-test-pb';
2
+ import type { Theme } from '@fluidui/tokens';
3
+ export type FluidProviderProps = {
4
+ theme: Theme;
5
+ children?: ElementChild | ElementChild[];
6
+ };
7
+ //# sourceMappingURL=FluidProvider.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FluidProvider.types.d.ts","sourceRoot":"","sources":["../../../src/components/FluidProvider/FluidProvider.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;CAC5C,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { FluidProvider } from './FluidProvider';
2
+ export type { FluidProviderProps } from './FluidProvider.types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FluidProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1 @@
1
+ export { FluidProvider } from './FluidProvider';
@@ -0,0 +1,4 @@
1
+ import type { FC } from 'jsx-framework-test-pb';
2
+ import type { PrizmProviderProps } from './PrizmProvider.types';
3
+ export declare const PrizmProvider: FC<PrizmProviderProps>;
4
+ //# sourceMappingURL=PrizmProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrizmProvider.d.ts","sourceRoot":"","sources":["../../../src/components/PrizmProvider/PrizmProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAgChE,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAGhD,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "jsx-framework-test-pb/jsx-runtime";
2
+ const injectedThemes = new Map();
3
+ function hashTheme(theme) {
4
+ const str = Object.entries(theme).join('');
5
+ let h = 5381;
6
+ for (let i = 0; i < str.length; i++) {
7
+ h = ((h << 5) + h) ^ str.charCodeAt(i);
8
+ }
9
+ return (h >>> 0).toString(36);
10
+ }
11
+ function getThemeClassName(theme) {
12
+ const hash = hashTheme(theme);
13
+ const className = `fluid-${hash}`;
14
+ if (!injectedThemes.has(className)) {
15
+ const vars = Object.entries(theme)
16
+ .map(([key, value]) => `--${key}: ${value}`)
17
+ .join('; ');
18
+ const style = document.createElement('style');
19
+ style.textContent = `.${className} { ${vars} }`;
20
+ document.head.appendChild(style);
21
+ injectedThemes.set(className, hash);
22
+ }
23
+ return className;
24
+ }
25
+ export const PrizmProvider = ({ theme, children }) => {
26
+ const className = getThemeClassName(theme);
27
+ return _jsx("div", { className: className, children: children });
28
+ };
@@ -0,0 +1,7 @@
1
+ import type { ElementChild } from 'jsx-framework-test-pb';
2
+ import type { Theme } from '@prizmui/tokens';
3
+ export type PrizmProviderProps = {
4
+ theme: Theme;
5
+ children?: ElementChild | ElementChild[];
6
+ };
7
+ //# sourceMappingURL=PrizmProvider.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrizmProvider.types.d.ts","sourceRoot":"","sources":["../../../src/components/PrizmProvider/PrizmProvider.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;CAC5C,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { PrizmProvider } from './PrizmProvider';
2
+ export type { PrizmProviderProps } from './PrizmProvider.types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PrizmProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1 @@
1
+ export { PrizmProvider } from './PrizmProvider';
@@ -0,0 +1,5 @@
1
+ export { PrizmProvider } from './components/PrizmProvider';
2
+ export type { PrizmProviderProps } from './components/PrizmProvider';
3
+ export { Button, buttonClassNames } from './components/Button';
4
+ export type { ButtonProps, ButtonSlots, ButtonState } from './components/Button';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { PrizmProvider } from './components/PrizmProvider';
2
+ export { Button, buttonClassNames } from './components/Button';
@@ -0,0 +1,31 @@
1
+ import type { FC } from 'jsx-framework-test-pb';
2
+ import type { ComponentState, SlotPropsRecord } from './types';
3
+ /**
4
+ * Transforms each slot in `state` from a props object into a callable FC,
5
+ * then asserts the new type so TypeScript accepts `<state.root>` directly in JSX.
6
+ *
7
+ * **Why this is needed:**
8
+ * TypeScript only accepts a value as a JSX tag if it has call signatures (i.e. it
9
+ * is a function or class). Without this transformation `state.root` is a plain
10
+ * props object — TypeScript falls back to React class-component checking and
11
+ * emits "react/jsx-runtime not found". After `assertSlots`, every slot IS a
12
+ * function, so that check never runs.
13
+ *
14
+ * **Runtime behaviour:**
15
+ * - Replaces `state.root` (props object) with `(extraProps) => jsx(component, { ...slotProps, ...extraProps })`.
16
+ * - Explicit JSX children override baked-in children only when they are not `undefined`,
17
+ * so `<state.root>{children}</state.root>` works whether or not `children` is defined.
18
+ * - Null slots (intentionally hidden) are left as-is.
19
+ * - Throws if any component slot has not been assigned in `state.components`.
20
+ *
21
+ * @example
22
+ * export const renderButton = (state: ButtonState): JSXElement => {
23
+ * const { children } = state.root as Record<string, unknown>;
24
+ * assertSlots<ButtonSlots>(state);
25
+ * return <state.root>{children}</state.root>;
26
+ * };
27
+ */
28
+ export declare function assertSlots<TSlots extends SlotPropsRecord>(state: ComponentState<TSlots>): asserts state is ComponentState<TSlots> & {
29
+ [K in keyof TSlots]: FC<Record<string, unknown>>;
30
+ };
31
+ //# sourceMappingURL=assertSlots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertSlots.d.ts","sourceRoot":"","sources":["../../src/utilities/assertSlots.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAgB,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAS,eAAe,EACtD,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAC9B,OAAO,CAAC,KAAK,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAAE,CA6BhG"}
@@ -0,0 +1,52 @@
1
+ import { jsx } from 'jsx-framework-test-pb/jsx-runtime';
2
+ /**
3
+ * Transforms each slot in `state` from a props object into a callable FC,
4
+ * then asserts the new type so TypeScript accepts `<state.root>` directly in JSX.
5
+ *
6
+ * **Why this is needed:**
7
+ * TypeScript only accepts a value as a JSX tag if it has call signatures (i.e. it
8
+ * is a function or class). Without this transformation `state.root` is a plain
9
+ * props object — TypeScript falls back to React class-component checking and
10
+ * emits "react/jsx-runtime not found". After `assertSlots`, every slot IS a
11
+ * function, so that check never runs.
12
+ *
13
+ * **Runtime behaviour:**
14
+ * - Replaces `state.root` (props object) with `(extraProps) => jsx(component, { ...slotProps, ...extraProps })`.
15
+ * - Explicit JSX children override baked-in children only when they are not `undefined`,
16
+ * so `<state.root>{children}</state.root>` works whether or not `children` is defined.
17
+ * - Null slots (intentionally hidden) are left as-is.
18
+ * - Throws if any component slot has not been assigned in `state.components`.
19
+ *
20
+ * @example
21
+ * export const renderButton = (state: ButtonState): JSXElement => {
22
+ * const { children } = state.root as Record<string, unknown>;
23
+ * assertSlots<ButtonSlots>(state);
24
+ * return <state.root>{children}</state.root>;
25
+ * };
26
+ */
27
+ export function assertSlots(state) {
28
+ for (const slotName of Object.keys(state.components)) {
29
+ const Component = state.components[slotName];
30
+ const slotProps = state[slotName];
31
+ if (Component === null || Component === undefined) {
32
+ throw new Error(`assertSlots: slot "${slotName}" has no component in state.components. ` +
33
+ `Make sure every slot is assigned in the use* hook.`);
34
+ }
35
+ // Null slot = intentionally hidden — leave as null, skip transformation
36
+ if (slotProps === null || slotProps === undefined)
37
+ continue;
38
+ // Replace the props object with an FC that renders the actual element.
39
+ // Explicit JSX children (extraProps.children) only override baked-in
40
+ // children when they are not undefined, so callers can safely write
41
+ // <state.root>{someVar}</state.root> even when someVar is undefined.
42
+ state[slotName] =
43
+ (extraProps = {}) => {
44
+ const { children: explicitChildren, ...otherExtra } = extraProps;
45
+ return jsx(Component, {
46
+ ...slotProps,
47
+ ...otherExtra,
48
+ ...(explicitChildren !== undefined && { children: explicitChildren }),
49
+ });
50
+ };
51
+ }
52
+ }
@@ -0,0 +1,3 @@
1
+ export type { DistributiveOmit, IntrinsicElementTag, IntrinsicElementProps, ElementType, IntrinsicShorthandProps, Slot, SlotPropsRecord, ComponentsRecord, ComponentProps, ComponentState, SlotClassNames, ARIAButtonSlotProps, JSXElement, } from './types';
2
+ export { assertSlots } from './assertSlots';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,uBAAuB,EACvB,IAAI,EACJ,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,UAAU,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1 @@
1
+ export { assertSlots } from './assertSlots';
@@ -0,0 +1,117 @@
1
+ import type { FC, ElementChild } from 'jsx-framework-test-pb';
2
+ /**
3
+ * Like `Omit`, but distributes over union types so each union member is omitted
4
+ * independently — preventing the intersection from collapsing the union.
5
+ *
6
+ * @example
7
+ * type A = { x: 1; y: 2 } | { x: 3; z: 4 };
8
+ * type B = DistributiveOmit<A, 'x'>; // { y: 2 } | { z: 4 }
9
+ */
10
+ export type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never;
11
+ /** Any valid intrinsic JSX element tag name (`'button'`, `'div'`, `'a'`, …). */
12
+ export type IntrinsicElementTag = keyof JSX.IntrinsicElements;
13
+ /** The props object for a given intrinsic element tag. */
14
+ export type IntrinsicElementProps<T extends IntrinsicElementTag> = JSX.IntrinsicElements[T];
15
+ /**
16
+ * A component type: either an intrinsic element tag string or a function component.
17
+ * Used for the `components` map in `ComponentState`.
18
+ */
19
+ export type ElementType<TProps extends object = Record<string, unknown>> = IntrinsicElementTag | FC<TProps>;
20
+ /**
21
+ * Props for an intrinsic element slot with an optional `as` prop to swap the
22
+ * rendered element type.
23
+ *
24
+ * The second generic `TFallbackAs` is distributed over union types, producing a
25
+ * proper discriminated union for each fallback element.
26
+ *
27
+ * @example
28
+ * type RootSlot = IntrinsicShorthandProps<'button', 'a' | 'div'>;
29
+ * // { as?: 'button'; disabled?: boolean; … }
30
+ * // | { as: 'a'; href?: string; … }
31
+ * // | { as: 'div'; … }
32
+ */
33
+ export type IntrinsicShorthandProps<TDefaultAs extends IntrinsicElementTag, TFallbackAs extends IntrinsicElementTag = TDefaultAs> = (IntrinsicElementProps<TDefaultAs> & {
34
+ as?: TDefaultAs;
35
+ }) | (TFallbackAs extends IntrinsicElementTag ? IntrinsicElementProps<TFallbackAs> & {
36
+ as: TFallbackAs;
37
+ } : never);
38
+ /**
39
+ * A slot value — can be:
40
+ * - An object of props for the slot element (including optional `as` to change type)
41
+ * - `null` — explicitly suppress the slot (don't render it)
42
+ * - `undefined` — optional slot not provided by the consumer
43
+ */
44
+ export type Slot<TProps extends object> = TProps | null | undefined;
45
+ /**
46
+ * The shape of a component's slot definitions.
47
+ * `root` is always required; additional slots are optional.
48
+ */
49
+ export type SlotPropsRecord = {
50
+ root: object;
51
+ [key: string]: object | null | undefined;
52
+ };
53
+ /**
54
+ * Maps each slot name to the element type that will render it.
55
+ * Resolved in the `use*` hook from defaults + the consumer's `as` prop.
56
+ */
57
+ export type ComponentsRecord<TSlots extends SlotPropsRecord> = {
58
+ [K in keyof TSlots]: ElementType;
59
+ };
60
+ /**
61
+ * Extracts the public-facing props for a component from its slot definitions:
62
+ * - Spreads the primary slot's props onto the top level (minus `children`)
63
+ * - Adds each non-primary slot as an optional prop key
64
+ * - Re-adds `children` with the framework's `ElementChild` type
65
+ *
66
+ * @example
67
+ * type ButtonSlots = { root: ARIAButtonSlotProps; icon?: Slot<HTMLAttributes> };
68
+ * type ButtonProps = ComponentProps<ButtonSlots> & { appearance?: ButtonAppearance };
69
+ */
70
+ export type ComponentProps<TSlots extends SlotPropsRecord, TPrimarySlot extends keyof TSlots = 'root'> = DistributiveOmit<TSlots[TPrimarySlot], 'children'> & {
71
+ [K in Exclude<keyof TSlots, TPrimarySlot>]?: TSlots[K];
72
+ } & {
73
+ children?: ElementChild | ElementChild[];
74
+ };
75
+ /**
76
+ * The internal state object returned by a `use*` hook.
77
+ *
78
+ * Contains:
79
+ * - `components` — resolved element type per slot (what will actually render)
80
+ * - One resolved prop object per slot (`undefined` is removed; `null` means "don't render")
81
+ *
82
+ * @example
83
+ * type ButtonState = ComponentState<ButtonSlots> & { appearance: ButtonAppearance };
84
+ */
85
+ export type ComponentState<TSlots extends SlotPropsRecord> = {
86
+ components: ComponentsRecord<TSlots>;
87
+ } & {
88
+ [K in keyof TSlots]: Exclude<TSlots[K], undefined>;
89
+ };
90
+ /**
91
+ * Root slot props for a button-like element that can render as:
92
+ * - `<button>` (default) — native disabled support
93
+ * - `<a>` — uses `aria-disabled`, supports `href`/`target`
94
+ * - `<div>` — uses `aria-disabled`, needs `role` + `tabIndex` for accessibility
95
+ *
96
+ * Used as the root slot of any interactive/pressable component.
97
+ */
98
+ export type ARIAButtonSlotProps<TFallbackAs extends 'a' | 'div' = 'a' | 'div'> = IntrinsicShorthandProps<'button', TFallbackAs>;
99
+ /**
100
+ * Maps each slot name to a stable BEM-style CSS class name string.
101
+ * Exported from the styles file so consumers can target individual slots.
102
+ *
103
+ * @example
104
+ * export const buttonClassNames: SlotClassNames<ButtonSlots> = {
105
+ * root: 'c-button',
106
+ * icon: 'c-button__icon',
107
+ * };
108
+ */
109
+ export type SlotClassNames<TSlots extends SlotPropsRecord> = {
110
+ [K in keyof TSlots]: string;
111
+ };
112
+ /**
113
+ * The return type of a JSX expression / render function.
114
+ * Alias for `JSX.Element` so components don't need to import from the framework directly.
115
+ */
116
+ export type JSXElement = JSX.Element;
117
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utilities/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI9D;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,CAAC,SAAS,OAAO,GAClE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACV,KAAK,CAAC;AAIZ,gFAAgF;AAChF,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAC;AAE9D,0DAA0D;AAC1D,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,mBAAmB,IAC3D,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAE7B;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACnE,mBAAmB,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;AAIrC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,uBAAuB,CAC/B,UAAU,SAAS,mBAAmB,EACtC,WAAW,SAAS,mBAAmB,GAAG,UAAU,IAElD,CAAC,qBAAqB,CAAC,UAAU,CAAC,GAAG;IAAE,EAAE,CAAC,EAAE,UAAU,CAAA;CAAE,CAAC,GACzD,CAAC,WAAW,SAAS,mBAAmB,GAClC,qBAAqB,CAAC,WAAW,CAAC,GAAG;IAAE,EAAE,EAAE,WAAW,CAAA;CAAE,GACxD,KAAK,CAAC,CAAC;AAEnB;;;;;GAKG;AACH,MAAM,MAAM,IAAI,CAAC,MAAM,SAAS,MAAM,IAAI,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAIpE;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAC5C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,eAAe,IAAI;KAC1D,CAAC,IAAI,MAAM,MAAM,GAAG,WAAW;CACnC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,CACtB,MAAM,SAAS,eAAe,EAC9B,YAAY,SAAS,MAAM,MAAM,GAAG,MAAM,IAC1C,gBAAgB,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,UAAU,CAAC,GAClD;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;CAAE,GAC1D;IAAE,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAA;CAAE,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,eAAe,IAAI;IACzD,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACxC,GAAG;KAAG,CAAC,IAAI,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;CAAE,CAAC;AAI3D;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,CAAC,WAAW,SAAS,GAAG,GAAG,KAAK,GAAG,GAAG,GAAG,KAAK,IACzE,uBAAuB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAInD;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,eAAe,IAAI;KACxD,CAAC,IAAI,MAAM,MAAM,GAAG,MAAM;CAC9B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@prizmui/components",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "dev": "tsc --watch",
19
+ "typecheck": "tsc --noEmit"
20
+ },
21
+ "dependencies": {
22
+ "calame": "workspace:*",
23
+ "@prizmui/tokens": "workspace:*"
24
+ },
25
+ "peerDependencies": {
26
+ "jsx-framework-test-pb": "*"
27
+ },
28
+ "devDependencies": {
29
+ "jsx-framework-test-pb": "latest",
30
+ "typescript": "^5.9.3"
31
+ }
32
+ }