@ahrowe/ui 0.4.2 → 0.4.3

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 (69) hide show
  1. package/dist/esm/common/accordion/accordion.mjs +1 -1
  2. package/dist/esm/common/accordion/accordion.mjs.map +1 -1
  3. package/dist/esm/common/actionButtons/actionButtons.mjs +1 -1
  4. package/dist/esm/common/actionButtons/actionButtons.mjs.map +1 -1
  5. package/dist/esm/common/badge/badge.mjs +1 -1
  6. package/dist/esm/common/badge/badge.mjs.map +1 -1
  7. package/dist/esm/common/button/button.mjs +1 -1
  8. package/dist/esm/common/button/button.mjs.map +1 -1
  9. package/dist/esm/common/card/Card.mjs +1 -1
  10. package/dist/esm/common/card/Card.mjs.map +1 -1
  11. package/dist/esm/common/checkbox/checkbox.mjs +1 -1
  12. package/dist/esm/common/checkbox/checkbox.mjs.map +1 -1
  13. package/dist/esm/common/chip/chip.mjs +1 -1
  14. package/dist/esm/common/chip/chip.mjs.map +1 -1
  15. package/dist/esm/common/configProvider/configProvider.mjs +2 -0
  16. package/dist/esm/common/configProvider/configProvider.mjs.map +1 -0
  17. package/dist/esm/common/configProvider/useComponentDefaults.mjs +2 -0
  18. package/dist/esm/common/configProvider/useComponentDefaults.mjs.map +1 -0
  19. package/dist/esm/common/datePicker/datePicker.mjs +1 -1
  20. package/dist/esm/common/datePicker/datePicker.mjs.map +1 -1
  21. package/dist/esm/common/dropdown/dropdown.mjs +1 -1
  22. package/dist/esm/common/dropdown/dropdown.mjs.map +1 -1
  23. package/dist/esm/common/dropdown/dropdown.module.mjs.map +1 -1
  24. package/dist/esm/common/input/input.mjs +1 -1
  25. package/dist/esm/common/input/input.mjs.map +1 -1
  26. package/dist/esm/common/input/input.module.mjs.map +1 -1
  27. package/dist/esm/common/input/input.types.mjs.map +1 -1
  28. package/dist/esm/common/inputDropdown/inputDropdown.mjs +1 -1
  29. package/dist/esm/common/inputDropdown/inputDropdown.mjs.map +1 -1
  30. package/dist/esm/common/numberInput/numberInput.mjs +1 -1
  31. package/dist/esm/common/numberInput/numberInput.mjs.map +1 -1
  32. package/dist/esm/common/skeleton/skeleton.mjs +1 -1
  33. package/dist/esm/common/skeleton/skeleton.mjs.map +1 -1
  34. package/dist/esm/common/switch/switch.mjs +1 -1
  35. package/dist/esm/common/switch/switch.mjs.map +1 -1
  36. package/dist/esm/common/textarea/textarea.mjs +1 -1
  37. package/dist/esm/common/textarea/textarea.mjs.map +1 -1
  38. package/dist/esm/index.mjs +1 -1
  39. package/dist/index.cjs +4 -4
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/style.css +1 -1
  42. package/dist/types/package/common/accordion/accordion.d.ts +1 -1
  43. package/dist/types/package/common/actionButtons/actionButtons.d.ts +1 -1
  44. package/dist/types/package/common/badge/badge.d.ts +1 -1
  45. package/dist/types/package/common/button/button.d.ts +1 -1
  46. package/dist/types/package/common/card/Card.d.ts +1 -1
  47. package/dist/types/package/common/checkbox/checkbox.d.ts +1 -1
  48. package/dist/types/package/common/chip/chip.d.ts +1 -1
  49. package/dist/types/package/common/configProvider/configProvider.d.ts +5 -0
  50. package/dist/types/package/common/configProvider/configProvider.types.d.ts +52 -0
  51. package/dist/types/package/common/configProvider/index.d.ts +3 -0
  52. package/dist/types/package/common/configProvider/useComponentDefaults.d.ts +17 -0
  53. package/dist/types/package/common/datePicker/datePicker.d.ts +2 -3
  54. package/dist/types/package/common/dropdown/dropdown.d.ts +1 -1
  55. package/dist/types/package/common/dropdown/dropdown.types.d.ts +1 -0
  56. package/dist/types/package/common/input/input.d.ts +1 -1
  57. package/dist/types/package/common/input/input.types.d.ts +1 -0
  58. package/dist/types/package/common/inputDropdown/inputDropdown.d.ts +1 -1
  59. package/dist/types/package/common/numberInput/numberInput.d.ts +2 -2
  60. package/dist/types/package/common/skeleton/skeleton.d.ts +1 -1
  61. package/dist/types/package/common/switch/switch.d.ts +1 -1
  62. package/dist/types/package/common/themeProvider/theme.types.d.ts +2 -0
  63. package/dist/types/package/index.d.ts +2 -0
  64. package/docs/CLAUDE.md +1 -0
  65. package/docs/ConfigProvider.md +81 -0
  66. package/docs/Dropdown.md +1 -0
  67. package/docs/Input.md +1 -0
  68. package/docs/ThemeProvider.md +2 -0
  69. package/package.json +1 -1
@@ -0,0 +1,81 @@
1
+ # ConfigProvider
2
+
3
+ **When to use:** Set global **default props** for library components once, near the root of your app, instead of repeating the same prop on every instance. If your app always wants floating labels, set `Input.alwaysFloatLabel` here and every `Input` picks it up.
4
+
5
+ **Import:** `import { ConfigProvider } from '@ahrowe/ui'`
6
+ **Types:** `import type { ComponentDefaults, ConfigProviderProps } from '@ahrowe/ui'`
7
+
8
+ Place it inside `ThemeProvider` (it's a separate concern from theming — theme = CSS variables, config = default props):
9
+
10
+ ```tsx
11
+ import { ThemeProvider, ConfigProvider } from '@ahrowe/ui';
12
+
13
+ <ThemeProvider>
14
+ <ConfigProvider defaultProps={{ Input: { alwaysFloatLabel: true } }}>
15
+ <App />
16
+ </ConfigProvider>
17
+ </ThemeProvider>
18
+ ```
19
+
20
+ ## How defaults resolve
21
+
22
+ For each prop, the value is chosen in this order (first that's set wins):
23
+
24
+ 1. The prop **explicitly passed** to the component instance
25
+ 2. The matching **global default** from the nearest `ConfigProvider`
26
+ 3. The component's own **built-in default**
27
+
28
+ So a global default only fills in props a given instance left out — any instance can still override it:
29
+
30
+ ```tsx
31
+ <ConfigProvider defaultProps={{ Input: { alwaysFloatLabel: true } }}>
32
+ <Input label="Name" /> {/* floats — inherits the global default */}
33
+ <Input label="Note" alwaysFloatLabel={false} />{/* opts out — explicit prop wins */}
34
+ </ConfigProvider>
35
+ ```
36
+
37
+ ## Nesting
38
+
39
+ `ConfigProvider`s compose. A nested provider extends the outer one per component, overriding only the keys it sets:
40
+
41
+ ```tsx
42
+ <ConfigProvider defaultProps={{ Input: { alwaysFloatLabel: true, useMatLabelStyle: true } }}>
43
+ {/* Inputs here float and use the material label */}
44
+ <ConfigProvider defaultProps={{ Input: { alwaysFloatLabel: false } }}>
45
+ {/* Inputs here don't float, but still use the material label from the outer provider */}
46
+ </ConfigProvider>
47
+ </ConfigProvider>
48
+ ```
49
+
50
+ ## Key props
51
+
52
+ | Prop | Type | Description |
53
+ |------|------|-------------|
54
+ | `defaultProps` | `ComponentDefaults` | Default props keyed by component name, e.g. `{ Input: { alwaysFloatLabel: true } }` |
55
+ | `children` | `ReactNode` | Your app content |
56
+
57
+ ## Supported components
58
+
59
+ Each entry is a `Partial<...Props>`, so any of that component's props can be defaulted:
60
+
61
+ - **Form inputs:** `Input` · `Textarea` · `NumberInput` · `Dropdown` · `InputDropdown` · `Checkbox` · `Switch` · `DatePicker`
62
+ - **Display:** `Button` · `ActionButtons` · `Badge` · `Chip` · `Card` · `Skeleton` · `Accordion`
63
+
64
+ ```tsx
65
+ <ConfigProvider
66
+ defaultProps={{
67
+ Input: { alwaysFloatLabel: true },
68
+ Dropdown: { useMatLabelStyle: true },
69
+ NumberInput: { decimalScale: 2, thousandSeparator: '.' },
70
+ Button: { styleType: ButtonStyleType.Primary },
71
+ Card: { styleType: CardStyleType.Outlined },
72
+ Skeleton: { animation: SkeletonAnimation.Pulse },
73
+ }}
74
+ >
75
+ <App />
76
+ </ConfigProvider>
77
+ ```
78
+
79
+ `Textarea`, `NumberInput`, and `DatePicker` are built on top of `Input`, so they **also** inherit `Input` defaults for the props they forward to it. Their own component-keyed defaults take precedence for props they handle themselves. Example: with `Input: { alwaysFloatLabel: true }` set, every `Textarea` / `NumberInput` / `DatePicker` floats its label too, without needing a separate entry.
80
+
81
+ The `ComponentDefaults` type is the source of truth for which keys are currently supported — more components adopt it over time.
package/docs/Dropdown.md CHANGED
@@ -53,5 +53,6 @@ const statusValidator = new FormValidator('', [Validators.required()]);
53
53
  | `placeholder` | `string` | Placeholder when no selection |
54
54
  | `onScroll` | `() => Promise<void>` | Load more on list scroll |
55
55
  | `useMatLabelStyle` | `boolean` | Material-style floating label |
56
+ | `alwaysFloatLabel` | `boolean` | Keep the material label floated in the border notch even when nothing is selected, so an empty dropdown reads as blank instead of showing the label as if it were the selected value. Only applies with `useMatLabelStyle` (default) |
56
57
 
57
58
  The list is rendered through a portal and tracks the trigger across scroll, so it always escapes clipping ancestors (cards, scroll containers, virtualized lists). It flips to open upward automatically when there's no room below, and hides (without closing) if the trigger itself scrolls behind a clipping ancestor, reappearing once it's back in view.
package/docs/Input.md CHANGED
@@ -66,6 +66,7 @@ const emailValidator = new FormValidator('', [Validators.required(), Validators.
66
66
  | `onClearClicked` | `() => void` | Clear button handler |
67
67
  | `isRow` | `boolean` | Horizontal layout |
68
68
  | `labelInBorder` | `boolean` | Label inside fieldset border |
69
+ | `alwaysFloatLabel` | `boolean` | Keep the material label floated in the border notch even when empty and unfocused, so an empty field reads as blank instead of showing the label as if it were a value. Only applies with `useMatLabelStyle` (default) |
69
70
  | `readOnly` | `boolean` | |
70
71
  | `autoFocus` | `boolean` | |
71
72
  | `placeholder` | `string` | |
@@ -70,6 +70,8 @@ interface Theme {
70
70
  | `--error-color` / `--success-color` / `--warn-color` / `--info-color` | Semantic colours |
71
71
  | `--default-border-radius` | Border radii |
72
72
  | `--avatar-radius` | `Avatar` corner radius — falls back to `--default-border-radius` when unset (set to `50%` theme-wide for fully circular avatars) |
73
+ | `--input-label-resting-color` | Resting (not-floated) material label colour for `Input` & `Dropdown` — falls back to `--text-light` when unset |
74
+ | `--input-label-floating-color` | Floating (active) material label colour for `Input` & `Dropdown` — falls back to `--text-color` when unset |
73
75
  | `--card-shadow` | Elevation shadows |
74
76
 
75
77
  **Key props:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahrowe/ui",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },