components-test-pb 0.2.6 → 0.2.7

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 (106) hide show
  1. package/dist/components/index.d.ts +1 -4
  2. package/dist/components/index.js +1 -3
  3. package/dist/components/src/Button/Button.d.ts +3 -0
  4. package/dist/components/{Button/src → src/Button}/Button.js +0 -2
  5. package/dist/components/src/Button/Button.types.d.ts +11 -0
  6. package/dist/components/src/Button/index.d.ts +5 -0
  7. package/dist/components/{Button/src → src/Button}/index.js +2 -2
  8. package/dist/components/{Button/src → src/Button}/renderButton.d.ts +1 -1
  9. package/dist/components/{Button/src → src/Button}/renderButton.js +1 -1
  10. package/dist/components/src/Button/useButton.js +15 -0
  11. package/dist/components/{Button/src → src/Button}/useButtonStyles.styles.d.ts +2 -2
  12. package/dist/components/src/Button/useButtonStyles.styles.js +31 -0
  13. package/dist/components/src/Text/Text.d.ts +3 -0
  14. package/dist/components/{Text → src/Text}/Text.types.d.ts +2 -8
  15. package/dist/components/src/Text/index.d.ts +5 -0
  16. package/dist/components/{Text → src/Text}/index.js +2 -2
  17. package/dist/components/{Text → src/Text}/renderText.d.ts +1 -1
  18. package/dist/components/{Text → src/Text}/renderText.js +2 -2
  19. package/dist/components/src/Text/useText.js +14 -0
  20. package/dist/components/{Text → src/Text}/useTextStyles.styles.d.ts +1 -1
  21. package/dist/components/src/Text/useTextStyles.styles.js +41 -0
  22. package/dist/components/src/index.d.ts +4 -0
  23. package/dist/components/src/index.js +2 -0
  24. package/dist/index.d.ts +6 -8
  25. package/dist/index.js +3 -4
  26. package/dist/utilities/index.d.ts +2 -2
  27. package/dist/utilities/index.js +1 -1
  28. package/dist/utilities/src/compose/assertSlots.d.ts +9 -0
  29. package/dist/utilities/src/compose/assertSlots.js +24 -9
  30. package/dist/utilities/src/compose/getIntrinsicElementProps.d.ts +3 -2
  31. package/dist/utilities/src/compose/getIntrinsicElementProps.js +46 -45
  32. package/dist/utilities/src/compose/index.d.ts +1 -1
  33. package/dist/utilities/src/compose/slot.d.ts +19 -8
  34. package/dist/utilities/src/compose/slot.js +23 -14
  35. package/dist/utilities/src/compose/types.d.ts +1 -1
  36. package/dist/utilities/src/index.d.ts +1 -3
  37. package/dist/utilities/src/index.js +0 -1
  38. package/package.json +1 -1
  39. package/src/components/index.ts +1 -35
  40. package/src/components/{Button/src → src/Button}/Button.tsx +10 -10
  41. package/src/components/src/Button/Button.types.ts +23 -0
  42. package/src/components/src/Button/index.ts +5 -0
  43. package/src/components/{Button/src → src/Button}/renderButton.tsx +4 -4
  44. package/src/components/src/Button/useButton.ts +24 -0
  45. package/src/components/src/Button/useButtonStyles.styles.ts +59 -0
  46. package/src/components/{Text → src/Text}/Text.tsx +13 -10
  47. package/src/components/{Text → src/Text}/Text.types.ts +2 -15
  48. package/src/components/src/Text/index.ts +5 -0
  49. package/src/components/src/Text/renderText.tsx +9 -0
  50. package/src/components/src/Text/useText.ts +23 -0
  51. package/src/components/src/Text/useTextStyles.styles.ts +62 -0
  52. package/src/components/src/index.ts +5 -0
  53. package/src/index.ts +9 -43
  54. package/src/utilities/index.ts +3 -9
  55. package/src/utilities/src/compose/assertSlots.ts +31 -13
  56. package/src/utilities/src/compose/getIntrinsicElementProps.ts +66 -67
  57. package/src/utilities/src/compose/index.ts +5 -5
  58. package/src/utilities/src/compose/slot.ts +53 -49
  59. package/src/utilities/src/compose/types.ts +157 -120
  60. package/src/utilities/src/index.ts +2 -13
  61. package/dist/components/Button/src/Button.d.ts +0 -2
  62. package/dist/components/Button/src/Button.types.d.ts +0 -17
  63. package/dist/components/Button/src/index.d.ts +0 -5
  64. package/dist/components/Button/src/useButton.js +0 -14
  65. package/dist/components/Button/src/useButtonStyles.styles.js +0 -143
  66. package/dist/components/Text/Text.d.ts +0 -2
  67. package/dist/components/Text/index.d.ts +0 -5
  68. package/dist/components/Text/useText.js +0 -19
  69. package/dist/components/Text/useTextStyles.styles.js +0 -71
  70. package/dist/theme/defaultTheme.d.ts +0 -2
  71. package/dist/theme/defaultTheme.js +0 -139
  72. package/dist/theme/index.d.ts +0 -4
  73. package/dist/theme/index.js +0 -3
  74. package/dist/theme/themeToCSS.d.ts +0 -3
  75. package/dist/theme/themeToCSS.js +0 -21
  76. package/dist/theme/tokens.d.ts +0 -2
  77. package/dist/theme/tokens.js +0 -2
  78. package/dist/theme/types.d.ts +0 -121
  79. package/dist/theme/types.js +0 -1
  80. package/dist/utilities/src/ARIA/index.d.ts +0 -2
  81. package/dist/utilities/src/ARIA/index.js +0 -1
  82. package/dist/utilities/src/ARIA/types.d.ts +0 -18
  83. package/dist/utilities/src/ARIA/types.js +0 -1
  84. package/dist/utilities/src/ARIA/useARIAButtonProps.d.ts +0 -2
  85. package/dist/utilities/src/ARIA/useARIAButtonProps.js +0 -61
  86. package/src/components/Button/src/Button.types.ts +0 -32
  87. package/src/components/Button/src/index.ts +0 -12
  88. package/src/components/Button/src/useButton.ts +0 -25
  89. package/src/components/Button/src/useButtonStyles.styles.ts +0 -194
  90. package/src/components/Text/index.ts +0 -9
  91. package/src/components/Text/renderText.tsx +0 -13
  92. package/src/components/Text/useText.ts +0 -25
  93. package/src/components/Text/useTextStyles.styles.ts +0 -100
  94. package/src/theme/defaultTheme.ts +0 -158
  95. package/src/theme/index.ts +0 -4
  96. package/src/theme/themeToCSS.ts +0 -27
  97. package/src/theme/tokens.ts +0 -6
  98. package/src/theme/types.ts +0 -156
  99. package/src/utilities/src/ARIA/index.ts +0 -11
  100. package/src/utilities/src/ARIA/types.ts +0 -58
  101. package/src/utilities/src/ARIA/useARIAButtonProps.ts +0 -74
  102. package/dist/components/{Button/src → src/Button}/Button.types.js +0 -0
  103. package/dist/components/{Button/src → src/Button}/useButton.d.ts +0 -0
  104. package/dist/components/{Text → src/Text}/Text.js +1 -1
  105. /package/dist/components/{Text → src/Text}/Text.types.js +0 -0
  106. /package/dist/components/{Text → src/Text}/useText.d.ts +0 -0
@@ -1,4 +1 @@
1
- export type { ButtonSlots, ButtonAppearance, ButtonShape, ButtonSize, ButtonProps, ButtonState, } from './Button/src';
2
- export { Button, useButton, renderButton, useButtonStyles, buttonClassNames, } from './Button/src';
3
- export type { TextSlots, TextProps, TextState, } from './Text';
4
- export { Text, useText, renderText, useTextStyles, textClassNames, } from './Text';
1
+ export * from './src';
@@ -1,3 +1 @@
1
- // <Button />
2
- export { Button, useButton, renderButton, useButtonStyles, buttonClassNames, } from './Button/src';
3
- export { Text, useText, renderText, useTextStyles, textClassNames, } from './Text';
1
+ export * from './src';
@@ -0,0 +1,3 @@
1
+ import type { FC } from 'jsx-framework-test-pb';
2
+ import type { ButtonProps } from './Button.types';
3
+ export declare const Button: FC<ButtonProps>;
@@ -1,8 +1,6 @@
1
1
  import { useButton } from './useButton';
2
- import { useButtonStyles } from './useButtonStyles.styles';
3
2
  import { renderButton } from './renderButton';
4
3
  export const Button = (props) => {
5
4
  const state = useButton(props);
6
- useButtonStyles(state);
7
5
  return renderButton(state);
8
6
  };
@@ -0,0 +1,11 @@
1
+ import type { ComponentProps, ComponentState, Slot } from '../../../utilities';
2
+ export type ButtonSlots = {
3
+ root: NonNullable<Slot<'a'>>;
4
+ };
5
+ export type ButtonProps = ComponentProps<ButtonSlots> & {
6
+ appearance?: 'primary' | 'secondary' | 'ghost';
7
+ disabled?: boolean;
8
+ shape?: 'rounded' | 'circular' | 'square';
9
+ size?: 'small' | 'medium' | 'large';
10
+ };
11
+ export type ButtonState = ComponentState<ButtonSlots> & Required<Pick<ButtonProps, 'appearance' | 'disabled' | 'shape' | 'size'>>;
@@ -0,0 +1,5 @@
1
+ export { Button } from './Button';
2
+ export type { ButtonProps, ButtonSlots, ButtonState } from './Button.types';
3
+ export { renderButton } from './renderButton';
4
+ export { useButton } from './useButton';
5
+ export { buttonClassNames, useButtonStyles } from './useButtonStyles.styles';
@@ -1,4 +1,4 @@
1
1
  export { Button } from './Button';
2
- export { useButton } from './useButton';
3
2
  export { renderButton } from './renderButton';
4
- export { useButtonStyles, buttonClassNames } from './useButtonStyles.styles';
3
+ export { useButton } from './useButton';
4
+ export { buttonClassNames, useButtonStyles } from './useButtonStyles.styles';
@@ -1,3 +1,3 @@
1
- import type { JSXElement } from '../../../utilities/src';
1
+ import type { JSXElement } from '../../../utilities';
2
2
  import type { ButtonState } from './Button.types';
3
3
  export declare const renderButton: (state: ButtonState) => JSXElement;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "jsx-framework-test-pb/jsx-runtime";
2
- import { assertSlots } from '../../../utilities/src';
2
+ import { assertSlots } from '../../../utilities';
3
3
  export const renderButton = (state) => {
4
4
  assertSlots(state);
5
5
  return (_jsx(state.root, { children: state.root.children }));
@@ -0,0 +1,15 @@
1
+ import { getIntrinsicElementProps, slot } from '../../../utilities';
2
+ export const useButton = (props) => {
3
+ const { appearance, disabled, shape, size } = props;
4
+ const state = {
5
+ appearance: appearance ?? 'secondary',
6
+ disabled: disabled ?? false,
7
+ shape: shape ?? 'rounded',
8
+ size: size ?? 'medium',
9
+ components: { root: 'a' },
10
+ root: slot.always(getIntrinsicElementProps('a', {
11
+ ...props
12
+ }), { elementType: 'a' }),
13
+ };
14
+ return state;
15
+ };
@@ -1,4 +1,4 @@
1
- import { SlotClassNames } from '../../../utilities';
2
- import { ButtonSlots, ButtonState } from './Button.types';
1
+ import type { SlotClassNames } from '../../../utilities';
2
+ import type { ButtonSlots, ButtonState } from './Button.types';
3
3
  export declare const buttonClassNames: SlotClassNames<ButtonSlots>;
4
4
  export declare const useButtonStyles: (state: ButtonState) => ButtonState;
@@ -0,0 +1,31 @@
1
+ import { makeResetStyles, makeStyles, mergeClasses } from 'css-engine-test-pb';
2
+ import { textClassNames } from '../Text';
3
+ export const buttonClassNames = {
4
+ root: 'c-button'
5
+ };
6
+ const useResetStyles = makeResetStyles({});
7
+ const useVariationStyles = makeStyles({
8
+ primary: {},
9
+ secondary: {},
10
+ ghost: {},
11
+ circular: {},
12
+ rounded: {},
13
+ square: {},
14
+ small: {},
15
+ medium: {},
16
+ large: {}
17
+ });
18
+ const useDisabledStyles = makeStyles({
19
+ base: {},
20
+ primary: {},
21
+ secondary: {},
22
+ ghost: {}
23
+ });
24
+ export const useButtonStyles = (state) => {
25
+ const resetStyles = useResetStyles();
26
+ const variationStyles = useVariationStyles();
27
+ const disabledStyles = useDisabledStyles();
28
+ const { appearance, disabled, shape, size } = state;
29
+ state.root.className = mergeClasses(textClassNames.root, resetStyles, appearance && variationStyles[appearance], variationStyles[shape], variationStyles[size], disabled && disabledStyles.base, appearance && disabled && disabledStyles[appearance], state.root.className);
30
+ return state;
31
+ };
@@ -0,0 +1,3 @@
1
+ import type { FC } from 'jsx-framework-test-pb';
2
+ import type { TextProps } from './Text.types';
3
+ export declare const Text: FC<TextProps>;
@@ -1,16 +1,10 @@
1
- import type { ComponentProps, ComponentState, Slot } from '../../utilities';
1
+ import type { ComponentProps, ComponentState, Slot } from '../../../utilities';
2
2
  export type TextSlots = {
3
3
  root: Slot<'span', 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'pre' | 'strong' | 'b' | 'em' | 'i'>;
4
4
  };
5
5
  export type TextProps = ComponentProps<TextSlots> & {
6
6
  font?: 'base' | 'monospace' | 'numeric';
7
- italic?: boolean;
8
7
  size?: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000;
9
- strikethrough?: boolean;
10
- truncate?: boolean;
11
- underline?: boolean;
12
8
  weight?: 'regular' | 'medium' | 'semibold' | 'bold';
13
- wrap?: boolean;
14
9
  };
15
- export type TextPresetprops = Omit<TextProps, 'font' | 'size' | 'weight'>;
16
- export type TextState = ComponentState<TextSlots> & Required<Pick<TextProps, 'font' | 'italic' | 'size' | 'strikethrough' | 'truncate' | 'underline' | 'weight' | 'wrap'>>;
10
+ export type TextState = ComponentState<TextSlots> & Required<Pick<TextProps, 'font' | 'size' | 'weight'>>;
@@ -0,0 +1,5 @@
1
+ export { Text } from './Text';
2
+ export type { TextProps, TextSlots, TextState } from './Text.types';
3
+ export { renderText } from './renderText';
4
+ export { useText } from './useText';
5
+ export { textClassNames, useTextStyles } from './useTextStyles.styles';
@@ -1,4 +1,4 @@
1
1
  export { Text } from './Text';
2
- export { useText } from './useText';
3
2
  export { renderText } from './renderText';
4
- export { useTextStyles, textClassNames } from './useTextStyles.styles';
3
+ export { useText } from './useText';
4
+ export { textClassNames, useTextStyles } from './useTextStyles.styles';
@@ -1,3 +1,3 @@
1
- import type { JSXElement } from '../../utilities/src/compose/types';
1
+ import type { JSXElement } from '../../../utilities';
2
2
  import type { TextState } from './Text.types';
3
3
  export declare const renderText: (state: TextState) => JSXElement;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "jsx-framework-test-pb/jsx-runtime";
2
- import { assertSlots } from '../../utilities/src';
2
+ import { assertSlots } from '../../../utilities';
3
3
  export const renderText = (state) => {
4
4
  assertSlots(state);
5
- return (_jsx(state.root, { children: state.root.children }));
5
+ return _jsx(state.root, {});
6
6
  };
@@ -0,0 +1,14 @@
1
+ import { getIntrinsicElementProps, slot } from '../../../utilities';
2
+ export const useText = (props) => {
3
+ const { font, size, weight } = props;
4
+ const state = {
5
+ font: font ?? 'base',
6
+ size: size ?? 300,
7
+ weight: weight ?? 'regular',
8
+ components: { root: 'span' },
9
+ root: slot.always(getIntrinsicElementProps('span', {
10
+ ...props
11
+ }), { elementType: 'span' })
12
+ };
13
+ return state;
14
+ };
@@ -1,4 +1,4 @@
1
- import type { SlotClassNames } from '../../utilities';
1
+ import type { SlotClassNames } from '../../../utilities';
2
2
  import type { TextSlots, TextState } from './Text.types';
3
3
  export declare const textClassNames: SlotClassNames<TextSlots>;
4
4
  export declare const useTextStyles: (state: TextState) => TextState;
@@ -0,0 +1,41 @@
1
+ import { makeResetStyles, makeStyles, mergeClasses } from 'css-engine-test-pb';
2
+ export const textClassNames = {
3
+ root: 'c-text'
4
+ };
5
+ const useResetStyles = makeResetStyles({
6
+ fontFamily: 'Neue Montreal',
7
+ fontSize: '14px',
8
+ lineHeight: '20px',
9
+ fontWeight: 450,
10
+ textAlign: 'start',
11
+ display: 'inline',
12
+ whiteSpace: 'normal',
13
+ overflow: 'visible',
14
+ textOverflow: 'clip'
15
+ });
16
+ const useVariationStyles = makeStyles({
17
+ base: {},
18
+ monospace: {},
19
+ numeric: {},
20
+ 100: {},
21
+ 200: {},
22
+ 300: {},
23
+ 400: {},
24
+ 500: {},
25
+ 600: {},
26
+ 700: {},
27
+ 800: {},
28
+ 900: {},
29
+ 1000: {},
30
+ regular: {},
31
+ medium: {},
32
+ semibold: {},
33
+ bold: {}
34
+ });
35
+ export const useTextStyles = (state) => {
36
+ const resetStyles = useResetStyles();
37
+ const variationStyles = useVariationStyles();
38
+ const { font, size, weight } = state;
39
+ state.root.className = mergeClasses(textClassNames.root, resetStyles, variationStyles[font], variationStyles[size], variationStyles[weight], state.root.className);
40
+ return state;
41
+ };
@@ -0,0 +1,4 @@
1
+ export { Button, buttonClassNames } from './Button';
2
+ export type { ButtonProps, ButtonSlots } from './Button';
3
+ export { Text, textClassNames } from './Text';
4
+ export type { TextProps, TextSlots } from './Text';
@@ -0,0 +1,2 @@
1
+ export { Button, buttonClassNames } from './Button';
2
+ export { Text, textClassNames } from './Text';
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- export { assertSlots, getIntrinsicElementProps, slot, useARIAButtonProps } from './utilities';
2
- export { tokens, defaultTheme, themeToCSS, insertTheme } from './theme';
3
- export type { Theme } from './theme';
4
- export { Button, useButton, renderButton, useButtonStyles, buttonClassNames, } from './components';
5
- export type { ButtonSlots, ButtonAppearance, ButtonShape, ButtonSize, ButtonProps, ButtonState, } from './components';
6
- export { Text, useText, renderText, useTextStyles, textClassNames, } from './components';
7
- export type { TextSlots, TextProps, TextState, } from './components';
8
- export type { JSXIntrinsicElementKeys, JSXIntrinsicElement, SlotRenderFunction, SlotPropsRecord, SlotShorthandValue, UnknownSlotProps, WithSlotRenderFunction, WithoutSlotRenderFunction, IsSingleton, AsIntrinsicElement, Slot, ExtractSlotProps, ComponentProps, ComponentState, SlotClassNames, EventData, EventHandler, DistributiveOmit, UnionToIntersection, ARIAButtonType, ARIAButtonElement, ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonAlteredProps, ARIAButtonResultProps, } from './utilities';
1
+ export type { JSXElement, JSXIntrinsicElementKeys, JSXIntrinsicElement, SlotRenderFunction, SlotPropsRecord, SlotShorthandValue, UnknownSlotProps, WithSlotRenderFunction, WithoutSlotRenderFunction, IsSingleton, AsIntrinsicElement, Slot, ExtractSlotProps, ComponentProps, ComponentState, SlotClassNames, EventData, EventHandler, DistributiveOmit, UnionToIntersection, } from './utilities';
2
+ export { assertSlots } from './utilities';
3
+ export { Button, buttonClassNames } from './components';
4
+ export type { ButtonProps, ButtonSlots } from './components';
5
+ export { Text, textClassNames } from './components';
6
+ export type { TextProps, TextSlots } from './components';
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export { assertSlots, getIntrinsicElementProps, slot, useARIAButtonProps } from './utilities';
2
- export { tokens, defaultTheme, themeToCSS, insertTheme } from './theme';
3
- export { Button, useButton, renderButton, useButtonStyles, buttonClassNames, } from './components';
4
- export { Text, useText, renderText, useTextStyles, textClassNames, } from './components';
1
+ export { assertSlots } from './utilities';
2
+ export { Button, buttonClassNames } from './components';
3
+ export { Text, textClassNames } from './components';
@@ -1,2 +1,2 @@
1
- export { assertSlots, getIntrinsicElementProps, slot, useARIAButtonProps } from './src';
2
- export type { JSXIntrinsicElementKeys, JSXIntrinsicElement, SlotRenderFunction, SlotPropsRecord, SlotShorthandValue, UnknownSlotProps, WithSlotRenderFunction, WithoutSlotRenderFunction, IsSingleton, AsIntrinsicElement, Slot, ExtractSlotProps, ComponentProps, ComponentState, SlotClassNames, EventData, EventHandler, DistributiveOmit, UnionToIntersection, ARIAButtonType, ARIAButtonElement, ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonAlteredProps, ARIAButtonResultProps, } from './src';
1
+ export type { JSXElement, JSXIntrinsicElementKeys, JSXIntrinsicElement, SlotRenderFunction, SlotPropsRecord, SlotShorthandValue, UnknownSlotProps, WithSlotRenderFunction, WithoutSlotRenderFunction, IsSingleton, AsIntrinsicElement, Slot, ExtractSlotProps, ComponentProps, ComponentState, SlotClassNames, EventData, EventHandler, DistributiveOmit, UnionToIntersection, } from './src';
2
+ export { assertSlots, getIntrinsicElementProps, slot } from './src';
@@ -1 +1 @@
1
- export { assertSlots, getIntrinsicElementProps, slot, useARIAButtonProps } from './src';
1
+ export { assertSlots, getIntrinsicElementProps, slot } from './src';
@@ -1,5 +1,14 @@
1
1
  import type { FC } from 'jsx-framework-test-pb';
2
2
  import type { ComponentState, SlotPropsRecord } from './types';
3
+ /**
4
+ * Asserts and transforms slot entries on `state` into callable JSX components.
5
+ *
6
+ * After calling this, each slot key (e.g. `state.root`, `state.icon`) becomes
7
+ * a function component that can be used directly in JSX: `<state.root />`.
8
+ *
9
+ * The component renders using the element type from `state.components[key]`
10
+ * and merges the resolved slot props with any props passed via JSX.
11
+ */
3
12
  export declare function assertSlots<Slots extends SlotPropsRecord>(state: ComponentState<Slots>): asserts state is ComponentState<Slots> & {
4
13
  [K in keyof Slots]: FC<any>;
5
14
  };
@@ -1,15 +1,30 @@
1
1
  import { jsx } from 'jsx-framework-test-pb/jsx-runtime';
2
+ /**
3
+ * Asserts and transforms slot entries on `state` into callable JSX components.
4
+ *
5
+ * After calling this, each slot key (e.g. `state.root`, `state.icon`) becomes
6
+ * a function component that can be used directly in JSX: `<state.root />`.
7
+ *
8
+ * The component renders using the element type from `state.components[key]`
9
+ * and merges the resolved slot props with any props passed via JSX.
10
+ */
2
11
  export function assertSlots(state) {
3
- const components = state.components;
4
- for (const name of Object.keys(components)) {
5
- const Component = components[name];
12
+ for (const name of Object.keys(state.components)) {
13
+ const elementType = state.components[name];
6
14
  const slotProps = state[name];
7
- if (slotProps != null) {
8
- const fn = (jsxProps) => {
9
- return jsx(Component, { ...slotProps, ...jsxProps });
10
- };
11
- fn.children = slotProps.children;
12
- state[name] = fn;
15
+ if (slotProps === undefined) {
16
+ // Optional slot not provided — render nothing
17
+ state[name] = () => null;
18
+ continue;
13
19
  }
20
+ const { children, elementType: slotElementType, ...restProps } = slotProps;
21
+ const resolvedElementType = slotElementType ?? elementType;
22
+ state[name] = (jsxProps) => {
23
+ const mergedProps = { ...restProps, ...jsxProps };
24
+ if (children !== undefined) {
25
+ mergedProps.children = jsxProps?.children ?? children;
26
+ }
27
+ return jsx(resolvedElementType, mergedProps);
28
+ };
14
29
  }
15
30
  }
@@ -1,2 +1,3 @@
1
- import type { UnknownSlotProps, JSXIntrinsicElementKeys } from './types';
2
- export declare function getIntrinsicElementProps<Props extends UnknownSlotProps & Record<string, any>>(tagName: JSXIntrinsicElementKeys, props: Props): Props;
1
+ import type { JSX } from 'jsx-framework-test-pb/jsx-runtime';
2
+ import type { JSXIntrinsicElementKeys } from './types';
3
+ export declare function getIntrinsicElementProps<Tag extends JSXIntrinsicElementKeys>(_elementType: Tag, props: Record<string, unknown>, excludedPropNames?: string[]): JSX.IntrinsicElements[Tag];
@@ -1,53 +1,54 @@
1
- // Global HTML attributes valid on all elements
2
- const nativeProps = new Set([
3
- // Core
4
- 'as', 'children', 'className', 'style', 'id', 'key',
5
- // HTML global attributes
6
- 'accessKey', 'autoFocus', 'contentEditable', 'dir', 'draggable',
7
- 'hidden', 'lang', 'nonce', 'placeholder', 'slot', 'spellCheck',
8
- 'tabIndex', 'title', 'translate', 'role',
9
- // Data & ARIA (handled separately via prefix check)
10
- // Event handlers
11
- 'onAbort', 'onAnimationEnd', 'onAnimationIteration', 'onAnimationStart',
12
- 'onBlur', 'onChange', 'onClick', 'onCompositionEnd', 'onCompositionStart',
13
- 'onCompositionUpdate', 'onContextMenu', 'onCopy', 'onCut', 'onDoubleClick',
14
- 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragExit', 'onDragLeave',
15
- 'onDragOver', 'onDragStart', 'onDrop', 'onError', 'onFocus', 'onFocusIn',
16
- 'onFocusOut', 'onGotPointerCapture', 'onInput', 'onInvalid', 'onKeyDown',
17
- 'onKeyPress', 'onKeyUp', 'onLoad', 'onLostPointerCapture', 'onMouseDown',
18
- 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseOut', 'onMouseOver',
19
- 'onMouseUp', 'onPaste', 'onPointerCancel', 'onPointerDown', 'onPointerEnter',
20
- 'onPointerLeave', 'onPointerMove', 'onPointerOut', 'onPointerOver',
21
- 'onPointerUp', 'onScroll', 'onSelect', 'onSubmit', 'onTouchCancel',
22
- 'onTouchEnd', 'onTouchMove', 'onTouchStart', 'onTransitionEnd', 'onWheel',
23
- // Form element attributes
24
- 'accept', 'acceptCharset', 'action', 'allowFullScreen', 'alt', 'async',
25
- 'autoCapitalize', 'autoComplete', 'autoPlay', 'capture', 'cellPadding',
26
- 'cellSpacing', 'charSet', 'checked', 'cite', 'colSpan', 'cols', 'controls',
27
- 'coords', 'crossOrigin', 'dateTime', 'default', 'defer', 'disabled',
28
- 'download', 'encType', 'form', 'formAction', 'formEncType', 'formMethod',
29
- 'formNoValidate', 'formTarget', 'frameBorder', 'headers', 'height', 'high',
30
- 'href', 'hrefLang', 'htmlFor', 'httpEquiv', 'icon', 'inputMode', 'integrity',
31
- 'is', 'kind', 'label', 'list', 'loop', 'low', 'max', 'maxLength', 'media',
32
- 'method', 'min', 'minLength', 'multiple', 'muted', 'name', 'noValidate',
33
- 'open', 'optimum', 'pattern', 'playsInline', 'poster', 'preload',
34
- 'readOnly', 'rel', 'required', 'reversed', 'rowSpan', 'rows', 'sandbox',
35
- 'scope', 'scoped', 'scrolling', 'seamless', 'selected', 'shape', 'size',
36
- 'sizes', 'span', 'src', 'srcDoc', 'srcLang', 'srcSet', 'start', 'step',
37
- 'summary', 'target', 'type', 'useMap', 'value', 'width', 'wrap',
1
+ // All valid HTML attribute names defined by the JSX framework's HTMLAttributes interfaces.
2
+ // aria-* and data-* are handled by prefix checks below.
3
+ // on* event handlers are handled by prefix check below.
4
+ const htmlAttributeNames = new Set([
5
+ // Global (HTMLAttributes)
6
+ 'className', 'id', 'style', 'title', 'lang', 'dir', 'hidden', 'tabIndex', 'role',
7
+ 'children', 'key', 'ref', 'as',
8
+ // Anchor (AnchorHTMLAttributes)
9
+ 'href', 'target', 'rel', 'download', 'hrefLang',
10
+ // Button (ButtonHTMLAttributes)
11
+ 'disabled', 'type', 'value', 'autoFocus', 'form',
12
+ 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget',
13
+ // Form (FormHTMLAttributes)
14
+ 'action', 'method', 'encType', 'noValidate', 'autoComplete',
15
+ // Input (InputHTMLAttributes)
16
+ 'accept', 'alt', 'capture', 'checked', 'max', 'maxLength', 'min', 'minLength',
17
+ 'multiple', 'name', 'pattern', 'placeholder', 'readOnly', 'required', 'size',
18
+ 'src', 'step',
19
+ // Textarea (TextareaHTMLAttributes)
20
+ 'cols', 'rows', 'wrap',
21
+ // Select/Option
22
+ 'selected', 'label',
23
+ // Img (ImgHTMLAttributes)
24
+ 'crossOrigin', 'decoding', 'height', 'loading', 'sizes', 'srcSet', 'width',
25
+ // Media (VideoHTMLAttributes / AudioHTMLAttributes)
26
+ 'autoPlay', 'controls', 'loop', 'muted', 'poster', 'preload',
27
+ // Table (TdHTMLAttributes / ThHTMLAttributes)
28
+ 'cellPadding', 'cellSpacing', 'colSpan', 'rowSpan', 'headers', 'scope',
29
+ // Iframe (IframeHTMLAttributes)
30
+ 'allow', 'allowFullScreen', 'sandbox', 'srcDoc',
31
+ // Label (LabelHTMLAttributes)
32
+ 'htmlFor',
33
+ // SVG (SVGAttributes)
34
+ 'viewBox', 'xmlns', 'fill', 'stroke', 'strokeWidth', 'strokeLinecap', 'strokeLinejoin',
35
+ // Meta (MetaHTMLAttributes) / Link (LinkHTMLAttributes)
36
+ 'charSet', 'content', 'httpEquiv', 'media',
37
+ // Details / Dialog
38
+ 'open',
38
39
  ]);
39
- function isNativeProp(key) {
40
- return nativeProps.has(key) || key.startsWith('data-') || key.startsWith('aria-');
41
- }
42
- export function getIntrinsicElementProps(tagName, props) {
40
+ export function getIntrinsicElementProps(_elementType, props, excludedPropNames) {
43
41
  const result = {};
44
42
  for (const key of Object.keys(props)) {
45
- if (isNativeProp(key)) {
43
+ if (excludedPropNames?.includes(key)) {
44
+ continue;
45
+ }
46
+ if (htmlAttributeNames.has(key) ||
47
+ key.startsWith('on') ||
48
+ key.startsWith('aria-') ||
49
+ key.startsWith('data-')) {
46
50
  result[key] = props[key];
47
51
  }
48
52
  }
49
- if (!result.as) {
50
- result.as = tagName;
51
- }
52
53
  return result;
53
54
  }
@@ -1,4 +1,4 @@
1
+ export type { JSXElement, JSXIntrinsicElementKeys, JSXIntrinsicElement, SlotRenderFunction, SlotPropsRecord, SlotShorthandValue, UnknownSlotProps, WithSlotRenderFunction, WithoutSlotRenderFunction, IsSingleton, AsIntrinsicElement, Slot, ExtractSlotProps, ComponentProps, ComponentState, SlotClassNames, EventData, EventHandler, DistributiveOmit, UnionToIntersection, } from './types';
1
2
  export { assertSlots } from './assertSlots';
2
3
  export { getIntrinsicElementProps } from './getIntrinsicElementProps';
3
4
  export { slot } from './slot';
4
- export type { JSXIntrinsicElementKeys, JSXIntrinsicElement, SlotRenderFunction, SlotPropsRecord, SlotShorthandValue, UnknownSlotProps, WithSlotRenderFunction, WithoutSlotRenderFunction, IsSingleton, AsIntrinsicElement, Slot, ExtractSlotProps, ComponentProps, ComponentState, SlotClassNames, EventData, EventHandler, DistributiveOmit, UnionToIntersection, JSXElement, } from './types';
@@ -1,11 +1,22 @@
1
- import type { SlotShorthandValue, UnknownSlotProps } from './types';
2
- type SlotValue = UnknownSlotProps | SlotShorthandValue | null | undefined;
3
- interface SlotOptions<Props extends UnknownSlotProps> {
4
- elementType: string;
5
- defaultProps?: Partial<Props>;
6
- }
1
+ import type { FC } from 'jsx-framework-test-pb';
2
+ import type { JSXIntrinsicElementKeys, SlotShorthandValue, UnknownSlotProps, WithoutSlotRenderFunction } from './types';
3
+ type SlotOptions<Tag extends JSXIntrinsicElementKeys | FC<any>> = {
4
+ elementType: Tag;
5
+ };
7
6
  export declare const slot: {
8
- always<Props extends UnknownSlotProps>(value: SlotValue, options: SlotOptions<Props>): Props;
9
- optional<Props extends UnknownSlotProps>(value: SlotValue, options: SlotOptions<Props>): Props | undefined;
7
+ /**
8
+ * Resolves a slot that is always rendered. If `value` is null or undefined,
9
+ * returns an empty props object (the slot still renders using its element type).
10
+ */
11
+ always<T extends UnknownSlotProps, Tag extends JSXIntrinsicElementKeys | FC<any>>(value: T | SlotShorthandValue | null | undefined, options: SlotOptions<Tag>): WithoutSlotRenderFunction<T> & (Tag extends JSXIntrinsicElementKeys ? {
12
+ as?: Tag;
13
+ } : {});
14
+ /**
15
+ * Resolves an optional slot. If `value` is null or undefined, returns undefined
16
+ * so that `assertSlots` skips rendering the slot entirely.
17
+ */
18
+ optional<T extends UnknownSlotProps, Tag extends JSXIntrinsicElementKeys | FC<any>>(value: T | SlotShorthandValue | null | undefined, options: SlotOptions<Tag>): (WithoutSlotRenderFunction<T> & (Tag extends JSXIntrinsicElementKeys ? {
19
+ as?: Tag;
20
+ } : {})) | undefined;
10
21
  };
11
22
  export {};
@@ -1,25 +1,34 @@
1
- import { isElement } from 'jsx-framework-test-pb';
2
- function isShorthand(value) {
3
- return typeof value === 'string' || typeof value === 'number' || isElement(value);
4
- }
5
- function resolveSlot(value, options) {
6
- const { defaultProps } = options;
7
- if (value == null) {
8
- return (defaultProps ?? {});
1
+ const ELEMENT_TYPE = Symbol.for('uraniyum.element');
2
+ function resolveSlotValue(value, elementType) {
3
+ if (value === null || value === undefined) {
4
+ return { elementType };
5
+ }
6
+ if (typeof value === 'string' || typeof value === 'number') {
7
+ return { elementType, children: value };
9
8
  }
10
- if (isShorthand(value)) {
11
- return { ...defaultProps, children: value };
9
+ // JSX Element shorthand — wrap as children
10
+ if (typeof value === 'object' && value.$$typeof === ELEMENT_TYPE) {
11
+ return { elementType, children: value };
12
12
  }
13
- return { ...defaultProps, ...value };
13
+ // Props object
14
+ return { elementType, ...value };
14
15
  }
15
16
  export const slot = {
17
+ /**
18
+ * Resolves a slot that is always rendered. If `value` is null or undefined,
19
+ * returns an empty props object (the slot still renders using its element type).
20
+ */
16
21
  always(value, options) {
17
- return resolveSlot(value, options);
22
+ return resolveSlotValue(value, options.elementType);
18
23
  },
24
+ /**
25
+ * Resolves an optional slot. If `value` is null or undefined, returns undefined
26
+ * so that `assertSlots` skips rendering the slot entirely.
27
+ */
19
28
  optional(value, options) {
20
- if (value == null) {
29
+ if (value === null || value === undefined) {
21
30
  return undefined;
22
31
  }
23
- return resolveSlot(value, options);
32
+ return resolveSlotValue(value, options.elementType);
24
33
  },
25
34
  };
@@ -8,7 +8,6 @@ type ReplaceNullWithUndefined<T> = T extends null ? undefined : T;
8
8
  type EmptyIntrinsicElements = 'area' | 'base' | 'br' | 'col' | 'embed' | 'hr' | 'img' | 'input' | 'link' | 'meta' | 'param' | 'source' | 'track' | 'wbr';
9
9
  type IntrinsicElementProps<Type extends JSXIntrinsicElementKeys> = Type extends EmptyIntrinsicElements ? PropsWithoutChildren<JSXIntrinsicElement<Type>> : JSXIntrinsicElement<Type>;
10
10
  export type SlotRenderFunction<Props> = (Component: FC<Props> | JSXIntrinsicElementKeys, props: Omit<Props, 'as'>) => ElementChild;
11
- export type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;
12
11
  export type SlotShorthandValue = Element | string | number;
13
12
  export type UnknownSlotProps = {
14
13
  className?: string | number;
@@ -16,6 +15,7 @@ export type UnknownSlotProps = {
16
15
  as?: JSXIntrinsicElementKeys;
17
16
  children?: ElementChild | ElementChild[] | SlotRenderFunction<any>;
18
17
  };
18
+ export type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;
19
19
  type WithSlotShorthandValue<Props> = Props | ('children' extends keyof Props ? Extract<SlotShorthandValue, Props['children']> : never);
20
20
  export type WithSlotRenderFunction<Props> = PropsWithoutChildren<Props> & {
21
21
  children?: 'children' extends keyof Props ? Props['children'] | SlotRenderFunction<Props> : never;
@@ -1,4 +1,2 @@
1
+ export type { JSXElement, JSXIntrinsicElementKeys, JSXIntrinsicElement, SlotRenderFunction, SlotPropsRecord, SlotShorthandValue, UnknownSlotProps, WithSlotRenderFunction, WithoutSlotRenderFunction, IsSingleton, AsIntrinsicElement, Slot, ExtractSlotProps, ComponentProps, ComponentState, SlotClassNames, EventData, EventHandler, DistributiveOmit, UnionToIntersection, } from './compose';
1
2
  export { assertSlots, getIntrinsicElementProps, slot } from './compose';
2
- export { useARIAButtonProps } from './ARIA';
3
- export type { JSXIntrinsicElementKeys, JSXIntrinsicElement, SlotRenderFunction, SlotPropsRecord, SlotShorthandValue, UnknownSlotProps, WithSlotRenderFunction, WithoutSlotRenderFunction, IsSingleton, AsIntrinsicElement, Slot, ExtractSlotProps, ComponentProps, ComponentState, SlotClassNames, EventData, EventHandler, DistributiveOmit, UnionToIntersection, JSXElement, } from './compose';
4
- export type { ARIAButtonType, ARIAButtonElement, ARIAButtonElementIntersection, ARIAButtonProps, ARIAButtonSlotProps, ARIAButtonAlteredProps, ARIAButtonResultProps, } from './ARIA';
@@ -1,2 +1 @@
1
1
  export { assertSlots, getIntrinsicElementProps, slot } from './compose';
2
- export { useARIAButtonProps } from './ARIA';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "components-test-pb",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",