components-test-pb 0.2.5 → 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 (98) hide show
  1. package/dist/components/index.d.ts +1 -2
  2. package/dist/components/index.js +1 -1
  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/src/Text/Text.js +8 -0
  15. package/dist/components/src/Text/Text.types.d.ts +10 -0
  16. package/dist/components/src/Text/index.d.ts +5 -0
  17. package/dist/components/src/Text/index.js +4 -0
  18. package/dist/components/src/Text/renderText.d.ts +3 -0
  19. package/dist/components/src/Text/renderText.js +6 -0
  20. package/dist/components/src/Text/useText.d.ts +2 -0
  21. package/dist/components/src/Text/useText.js +14 -0
  22. package/dist/components/src/Text/useTextStyles.styles.d.ts +4 -0
  23. package/dist/components/src/Text/useTextStyles.styles.js +41 -0
  24. package/dist/components/src/index.d.ts +4 -0
  25. package/dist/components/src/index.js +2 -0
  26. package/dist/index.d.ts +6 -6
  27. package/dist/index.js +3 -3
  28. package/dist/utilities/index.d.ts +2 -2
  29. package/dist/utilities/index.js +1 -1
  30. package/dist/utilities/src/compose/assertSlots.d.ts +9 -0
  31. package/dist/utilities/src/compose/assertSlots.js +24 -9
  32. package/dist/utilities/src/compose/getIntrinsicElementProps.d.ts +3 -0
  33. package/dist/utilities/src/compose/getIntrinsicElementProps.js +54 -0
  34. package/dist/utilities/src/compose/index.d.ts +2 -1
  35. package/dist/utilities/src/compose/index.js +1 -0
  36. package/dist/utilities/src/compose/slot.d.ts +19 -8
  37. package/dist/utilities/src/compose/slot.js +23 -14
  38. package/dist/utilities/src/compose/types.d.ts +1 -1
  39. package/dist/utilities/src/index.d.ts +2 -4
  40. package/dist/utilities/src/index.js +1 -2
  41. package/package.json +1 -1
  42. package/src/components/index.ts +1 -16
  43. package/src/components/{Button/src → src/Button}/Button.tsx +10 -10
  44. package/src/components/src/Button/Button.types.ts +23 -0
  45. package/src/components/src/Button/index.ts +5 -0
  46. package/src/components/{Button/src → src/Button}/renderButton.tsx +4 -3
  47. package/src/components/src/Button/useButton.ts +24 -0
  48. package/src/components/src/Button/useButtonStyles.styles.ts +59 -0
  49. package/src/components/src/Text/Text.tsx +13 -0
  50. package/src/components/src/Text/Text.types.ts +21 -0
  51. package/src/components/src/Text/index.ts +5 -0
  52. package/src/components/src/Text/renderText.tsx +9 -0
  53. package/src/components/src/Text/useText.ts +23 -0
  54. package/src/components/src/Text/useTextStyles.styles.ts +62 -0
  55. package/src/components/src/index.ts +5 -0
  56. package/src/index.ts +9 -29
  57. package/src/utilities/index.ts +3 -9
  58. package/src/utilities/src/compose/assertSlots.ts +31 -13
  59. package/src/utilities/src/compose/getIntrinsicElementProps.ts +66 -0
  60. package/src/utilities/src/compose/index.ts +5 -4
  61. package/src/utilities/src/compose/slot.ts +53 -49
  62. package/src/utilities/src/compose/types.ts +157 -120
  63. package/src/utilities/src/index.ts +2 -13
  64. package/dist/components/Button/src/Button.d.ts +0 -2
  65. package/dist/components/Button/src/Button.types.d.ts +0 -17
  66. package/dist/components/Button/src/index.d.ts +0 -5
  67. package/dist/components/Button/src/useButton.js +0 -15
  68. package/dist/components/Button/src/useButtonStyles.styles.js +0 -143
  69. package/dist/theme/defaultTheme.d.ts +0 -2
  70. package/dist/theme/defaultTheme.js +0 -139
  71. package/dist/theme/index.d.ts +0 -4
  72. package/dist/theme/index.js +0 -3
  73. package/dist/theme/themeToCSS.d.ts +0 -3
  74. package/dist/theme/themeToCSS.js +0 -21
  75. package/dist/theme/tokens.d.ts +0 -2
  76. package/dist/theme/tokens.js +0 -2
  77. package/dist/theme/types.d.ts +0 -121
  78. package/dist/utilities/src/ARIA/index.d.ts +0 -2
  79. package/dist/utilities/src/ARIA/index.js +0 -1
  80. package/dist/utilities/src/ARIA/types.d.ts +0 -18
  81. package/dist/utilities/src/ARIA/types.js +0 -1
  82. package/dist/utilities/src/ARIA/useARIAButtonProps.d.ts +0 -2
  83. package/dist/utilities/src/ARIA/useARIAButtonProps.js +0 -61
  84. package/src/components/Button/src/Button.types.ts +0 -32
  85. package/src/components/Button/src/index.ts +0 -12
  86. package/src/components/Button/src/useButton.ts +0 -26
  87. package/src/components/Button/src/useButtonStyles.styles.ts +0 -194
  88. package/src/theme/defaultTheme.ts +0 -158
  89. package/src/theme/index.ts +0 -4
  90. package/src/theme/themeToCSS.ts +0 -27
  91. package/src/theme/tokens.ts +0 -6
  92. package/src/theme/types.ts +0 -156
  93. package/src/utilities/src/ARIA/index.ts +0 -11
  94. package/src/utilities/src/ARIA/types.ts +0 -58
  95. package/src/utilities/src/ARIA/useARIAButtonProps.ts +0 -74
  96. /package/dist/components/{Button/src → src/Button}/Button.types.js +0 -0
  97. /package/dist/components/{Button/src → src/Button}/useButton.d.ts +0 -0
  98. /package/dist/{theme/types.js → components/src/Text/Text.types.js} +0 -0
@@ -1,27 +0,0 @@
1
- import type { Theme } from './types';
2
-
3
- let themeStyleElement: HTMLStyleElement | null = null;
4
-
5
- export function themeToCSS(theme: Theme): string {
6
- return (Object.keys(theme) as (keyof Theme)[])
7
- .map((key) => `--${key}: ${theme[key]};`)
8
- .join(' ');
9
- }
10
-
11
- export function insertTheme(theme: Theme): void {
12
- if (!themeStyleElement) {
13
- themeStyleElement = document.createElement('style');
14
- themeStyleElement.setAttribute('data-theme', 'default');
15
- document.head.appendChild(themeStyleElement);
16
- }
17
-
18
- const rule = `:root { ${themeToCSS(theme)} }`;
19
-
20
- const sheet = themeStyleElement.sheet;
21
- if (sheet) {
22
- while (sheet.cssRules.length > 0) {
23
- sheet.deleteRule(0);
24
- }
25
- sheet.insertRule(rule, 0);
26
- }
27
- }
@@ -1,6 +0,0 @@
1
- import type { Theme } from './types';
2
- import { defaultTheme } from './defaultTheme';
3
-
4
- export const tokens: Record<keyof Theme, string> = Object.fromEntries(
5
- (Object.keys(defaultTheme) as (keyof Theme)[]).map((key) => [key, `var(--${key})`]),
6
- ) as Record<keyof Theme, string>;
@@ -1,156 +0,0 @@
1
- export interface Theme {
2
- // Colors — Brand
3
- colorBrandBackground: string;
4
- colorBrandBackgroundHover: string;
5
- colorBrandBackgroundPressed: string;
6
- colorBrandBackgroundSelected: string;
7
- colorBrandForeground: string;
8
- colorBrandForegroundHover: string;
9
- colorBrandForegroundPressed: string;
10
- colorNeutralForegroundOnBrand: string;
11
- colorBrandStroke: string;
12
-
13
- // Colors — Neutral Foreground
14
- colorNeutralForeground1: string;
15
- colorNeutralForeground1Hover: string;
16
- colorNeutralForeground1Pressed: string;
17
- colorNeutralForeground2: string;
18
- colorNeutralForeground2Hover: string;
19
- colorNeutralForeground2Pressed: string;
20
- colorNeutralForeground2BrandHover: string;
21
- colorNeutralForeground2BrandPressed: string;
22
- colorNeutralForeground2BrandSelected: string;
23
- colorNeutralForeground3: string;
24
- colorNeutralForegroundDisabled: string;
25
-
26
- // Colors — Neutral Background
27
- colorNeutralBackground1: string;
28
- colorNeutralBackground1Hover: string;
29
- colorNeutralBackground1Pressed: string;
30
- colorNeutralBackground1Selected: string;
31
- colorNeutralBackground2: string;
32
- colorNeutralBackground3: string;
33
- colorNeutralBackgroundDisabled: string;
34
-
35
- // Colors — Neutral Stroke
36
- colorNeutralStroke1: string;
37
- colorNeutralStroke1Hover: string;
38
- colorNeutralStroke1Pressed: string;
39
- colorNeutralStroke2: string;
40
- colorNeutralStrokeDisabled: string;
41
-
42
- // Colors — Transparent
43
- colorTransparentBackground: string;
44
- colorTransparentBackgroundHover: string;
45
- colorTransparentBackgroundPressed: string;
46
-
47
- // Colors — Subtle
48
- colorSubtleBackground: string;
49
- colorSubtleBackgroundHover: string;
50
- colorSubtleBackgroundPressed: string;
51
- colorSubtleBackgroundSelected: string;
52
- colorSubtleForeground: string;
53
-
54
- // Colors — Status
55
- colorStatusDangerBackground: string;
56
- colorStatusDangerForeground: string;
57
- colorStatusDangerStroke: string;
58
- colorStatusSuccessBackground: string;
59
- colorStatusSuccessForeground: string;
60
- colorStatusSuccessStroke: string;
61
- colorStatusWarningBackground: string;
62
- colorStatusWarningForeground: string;
63
- colorStatusWarningStroke: string;
64
-
65
- // Spacing — Horizontal
66
- spacingHorizontalXXS: string;
67
- spacingHorizontalXS: string;
68
- spacingHorizontalSNudge: string;
69
- spacingHorizontalS: string;
70
- spacingHorizontalMNudge: string;
71
- spacingHorizontalM: string;
72
- spacingHorizontalL: string;
73
- spacingHorizontalXL: string;
74
- spacingHorizontalXXL: string;
75
- spacingHorizontalXXXL: string;
76
-
77
- // Spacing — Vertical
78
- spacingVerticalXXS: string;
79
- spacingVerticalXS: string;
80
- spacingVerticalSNudge: string;
81
- spacingVerticalS: string;
82
- spacingVerticalMNudge: string;
83
- spacingVerticalM: string;
84
- spacingVerticalL: string;
85
- spacingVerticalXL: string;
86
- spacingVerticalXXL: string;
87
- spacingVerticalXXXL: string;
88
-
89
- // Border Radius
90
- borderRadiusNone: string;
91
- borderRadiusSmall: string;
92
- borderRadiusMedium: string;
93
- borderRadiusLarge: string;
94
- borderRadiusXLarge: string;
95
- borderRadiusCircular: string;
96
-
97
- // Font Family
98
- fontFamilyBase: string;
99
- fontFamilyMonospace: string;
100
- fontFamilyNumeric: string;
101
-
102
- // Font Size
103
- fontSizeBase100: string;
104
- fontSizeBase200: string;
105
- fontSizeBase300: string;
106
- fontSizeBase400: string;
107
- fontSizeBase500: string;
108
- fontSizeBase600: string;
109
-
110
- // Font Weight
111
- fontWeightRegular: string;
112
- fontWeightMedium: string;
113
- fontWeightSemibold: string;
114
- fontWeightBold: string;
115
-
116
- // Line Height
117
- lineHeightBase100: string;
118
- lineHeightBase200: string;
119
- lineHeightBase300: string;
120
- lineHeightBase400: string;
121
- lineHeightBase500: string;
122
- lineHeightBase600: string;
123
-
124
- // Shadows
125
- shadow2: string;
126
- shadow4: string;
127
- shadow8: string;
128
- shadow16: string;
129
- shadow28: string;
130
- shadow64: string;
131
-
132
- // Stroke Width
133
- strokeWidthThin: string;
134
- strokeWidthThick: string;
135
- strokeWidthThicker: string;
136
- strokeWidthThickest: string;
137
-
138
- // Duration
139
- durationUltraFast: string;
140
- durationFaster: string;
141
- durationFast: string;
142
- durationNormal: string;
143
- durationGentle: string;
144
- durationSlow: string;
145
- durationSlower: string;
146
-
147
- // Easing
148
- curveAccelerateMax: string;
149
- curveAccelerateMid: string;
150
- curveAccelerateMin: string;
151
- curveDecelerateMax: string;
152
- curveDecelerateMid: string;
153
- curveDecelerateMin: string;
154
- curveEasyEase: string;
155
- curveLinear: string;
156
- }
@@ -1,11 +0,0 @@
1
- export { useARIAButtonProps } from './useARIAButtonProps';
2
-
3
- export type {
4
- ARIAButtonType,
5
- ARIAButtonElement,
6
- ARIAButtonElementIntersection,
7
- ARIAButtonProps,
8
- ARIAButtonSlotProps,
9
- ARIAButtonAlteredProps,
10
- ARIAButtonResultProps,
11
- } from './types';
@@ -1,58 +0,0 @@
1
- import type {
2
- DistributiveOmit,
3
- ExtractSlotProps,
4
- Slot,
5
- UnionToIntersection,
6
- JSXIntrinsicElement,
7
- } from '../compose/types';
8
-
9
- export type ARIAButtonType = 'button' | 'a' | 'div';
10
-
11
- export type ARIAButtonElement<AlternateAs extends 'a' | 'div' = 'a' | 'div'> =
12
- | HTMLButtonElement
13
- | (AlternateAs extends 'a' ? HTMLAnchorElement : never)
14
- | (AlternateAs extends 'div' ? HTMLDivElement : never);
15
-
16
- export type ARIAButtonElementIntersection<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = UnionToIntersection<
17
- ARIAButtonElement<AlternateAs>
18
- >;
19
-
20
- export type ARIAButtonProps<Type extends ARIAButtonType = ARIAButtonType> = DistributiveOmit<
21
- JSXIntrinsicElement<Type>,
22
- 'children'
23
- > & {
24
- disabled?: boolean;
25
- /**
26
- * When set, allows the button to be focusable even when it has been disabled.
27
- * This is used in scenarios where it is important to keep a consistent tab order
28
- * for screen reader and keyboard users.
29
- *
30
- * @default false
31
- */
32
- disabledFocusable?: boolean;
33
- };
34
-
35
- export type ARIAButtonSlotProps<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = ExtractSlotProps<
36
- Slot<'button', AlternateAs>
37
- > &
38
- Pick<ARIAButtonProps<ARIAButtonType>, 'disabled' | 'disabledFocusable'>;
39
-
40
- export type ARIAButtonAlteredProps<Type extends ARIAButtonType> =
41
- | (Type extends 'button'
42
- ? Pick<
43
- JSXIntrinsicElement<'button'>,
44
- 'onClick' | 'onKeyDown' | 'onKeyUp' | 'disabled' | 'aria-disabled' | 'tabIndex'
45
- >
46
- : never)
47
- | (Type extends 'a'
48
- ? Pick<
49
- JSXIntrinsicElement<'a'>,
50
- 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role' | 'href'
51
- >
52
- : never)
53
- | (Type extends 'div'
54
- ? Pick<JSXIntrinsicElement<'div'>, 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role'>
55
- : never);
56
-
57
- export type ARIAButtonResultProps<Type extends ARIAButtonType, Props> = Props &
58
- UnionToIntersection<ARIAButtonAlteredProps<Type>>;
@@ -1,74 +0,0 @@
1
- import type { ARIAButtonProps, ARIAButtonResultProps, ARIAButtonType } from './types';
2
-
3
- export function useARIAButtonProps<Type extends ARIAButtonType>(
4
- type: Type,
5
- props: ARIAButtonProps<Type>,
6
- ): ARIAButtonResultProps<Type, ARIAButtonProps<Type>> {
7
- const { disabled, disabledFocusable, onClick, onKeyDown, onKeyUp, ...rest } =
8
- props as ARIAButtonProps<ARIAButtonType>;
9
-
10
- const isDisabled = disabled || disabledFocusable;
11
-
12
- if (type === 'button') {
13
- return {
14
- ...rest,
15
- disabled: isDisabled && !disabledFocusable,
16
- onClick: isDisabled
17
- ? (e: MouseEvent) => {
18
- e.preventDefault();
19
- e.stopPropagation();
20
- }
21
- : onClick,
22
- onKeyDown,
23
- onKeyUp,
24
- ...(isDisabled && { 'aria-disabled': true }),
25
- } as unknown as ARIAButtonResultProps<Type, ARIAButtonProps<Type>>;
26
- }
27
-
28
- // Non-native: 'a' | 'div'
29
- const handleClick = isDisabled
30
- ? (e: MouseEvent) => {
31
- e.preventDefault();
32
- e.stopPropagation();
33
- }
34
- : onClick;
35
-
36
- const handleKeyDown = (e: KeyboardEvent) => {
37
- onKeyDown?.(e);
38
-
39
- if (e.defaultPrevented) return;
40
-
41
- if (isDisabled) return;
42
-
43
- if (e.key === 'Enter') {
44
- e.preventDefault();
45
- (e.currentTarget as HTMLElement).click();
46
- } else if (e.key === ' ') {
47
- e.preventDefault(); // Prevent scroll
48
- }
49
- };
50
-
51
- const handleKeyUp = (e: KeyboardEvent) => {
52
- onKeyUp?.(e);
53
-
54
- if (e.defaultPrevented) return;
55
-
56
- if (isDisabled) return;
57
-
58
- if (e.key === ' ') {
59
- e.preventDefault();
60
- (e.currentTarget as HTMLElement).click();
61
- }
62
- };
63
-
64
- return {
65
- ...rest,
66
- role: 'button',
67
- tabIndex: isDisabled && !disabledFocusable ? undefined : (rest as Record<string, unknown>).tabIndex ?? 0,
68
- onClick: handleClick,
69
- onKeyDown: handleKeyDown,
70
- onKeyUp: handleKeyUp,
71
- ...(isDisabled && { 'aria-disabled': true }),
72
- ...(type === 'a' && isDisabled && { href: undefined }),
73
- } as unknown as ARIAButtonResultProps<Type, ARIAButtonProps<Type>>;
74
- }