panelui-native 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/lib/module/components/area-chart/index.js +4 -1
  2. package/lib/module/components/area-chart/index.js.map +1 -1
  3. package/lib/module/components/bar-chart/index.js +4 -1
  4. package/lib/module/components/bar-chart/index.js.map +1 -1
  5. package/lib/module/components/bubble-chart/index.js +4 -1
  6. package/lib/module/components/bubble-chart/index.js.map +1 -1
  7. package/lib/module/components/bump-chart/index.js +4 -1
  8. package/lib/module/components/bump-chart/index.js.map +1 -1
  9. package/lib/module/components/calendar/index.js +15 -2
  10. package/lib/module/components/calendar/index.js.map +1 -1
  11. package/lib/module/components/candlestick-chart/index.js +4 -1
  12. package/lib/module/components/candlestick-chart/index.js.map +1 -1
  13. package/lib/module/components/checkbox/index.js +2 -1
  14. package/lib/module/components/checkbox/index.js.map +1 -1
  15. package/lib/module/components/combobox/index.js +28 -7
  16. package/lib/module/components/combobox/index.js.map +1 -1
  17. package/lib/module/components/heatmap-chart/index.js +4 -1
  18. package/lib/module/components/heatmap-chart/index.js.map +1 -1
  19. package/lib/module/components/line-chart/index.js +4 -1
  20. package/lib/module/components/line-chart/index.js.map +1 -1
  21. package/lib/module/components/live-line-chart/index.js +4 -1
  22. package/lib/module/components/live-line-chart/index.js.map +1 -1
  23. package/lib/module/components/mirror-area-chart/index.js +4 -1
  24. package/lib/module/components/mirror-area-chart/index.js.map +1 -1
  25. package/lib/module/components/plot/index.js +4 -1
  26. package/lib/module/components/plot/index.js.map +1 -1
  27. package/lib/module/components/pyramid-chart/index.js +4 -1
  28. package/lib/module/components/pyramid-chart/index.js.map +1 -1
  29. package/lib/module/components/questionnaire/index.js +1 -0
  30. package/lib/module/components/questionnaire/index.js.map +1 -1
  31. package/lib/module/components/radio-group/index.js +2 -1
  32. package/lib/module/components/radio-group/index.js.map +1 -1
  33. package/lib/module/components/scatter-chart/index.js +4 -1
  34. package/lib/module/components/scatter-chart/index.js.map +1 -1
  35. package/lib/module/components/scroll-blur/index.js +25 -7
  36. package/lib/module/components/scroll-blur/index.js.map +1 -1
  37. package/lib/module/components/scroll-header/index.js +44 -24
  38. package/lib/module/components/scroll-header/index.js.map +1 -1
  39. package/lib/module/components/search-bar/index.js +2 -1
  40. package/lib/module/components/search-bar/index.js.map +1 -1
  41. package/lib/module/components/section-progress/index.js +1 -1
  42. package/lib/module/components/section-progress/index.js.map +1 -1
  43. package/lib/module/components/section-rail/index.js +1 -1
  44. package/lib/module/components/section-rail/index.js.map +1 -1
  45. package/lib/module/components/select/index.js +28 -7
  46. package/lib/module/components/select/index.js.map +1 -1
  47. package/lib/module/components/switch/index.js +51 -15
  48. package/lib/module/components/switch/index.js.map +1 -1
  49. package/lib/module/components/table/index.js +17 -3
  50. package/lib/module/components/table/index.js.map +1 -1
  51. package/lib/module/components/toast/index.js +13 -3
  52. package/lib/module/components/toast/index.js.map +1 -1
  53. package/lib/module/components/waterfall-chart/index.js +4 -1
  54. package/lib/module/components/waterfall-chart/index.js.map +1 -1
  55. package/lib/module/components/week-hours-grid/index.js +187 -0
  56. package/lib/module/components/week-hours-grid/index.js.map +1 -0
  57. package/lib/module/components/week-strip/index.js +232 -0
  58. package/lib/module/components/week-strip/index.js.map +1 -0
  59. package/lib/module/index.js +3 -1
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/module/primitives/scrim.js +50 -2
  62. package/lib/module/primitives/scrim.js.map +1 -1
  63. package/lib/module/theme/use-theme.js +55 -4
  64. package/lib/module/theme/use-theme.js.map +1 -1
  65. package/lib/typescript/src/components/area-chart/index.d.ts.map +1 -1
  66. package/lib/typescript/src/components/bar-chart/index.d.ts.map +1 -1
  67. package/lib/typescript/src/components/bubble-chart/index.d.ts.map +1 -1
  68. package/lib/typescript/src/components/bump-chart/index.d.ts.map +1 -1
  69. package/lib/typescript/src/components/calendar/index.d.ts.map +1 -1
  70. package/lib/typescript/src/components/candlestick-chart/index.d.ts.map +1 -1
  71. package/lib/typescript/src/components/combobox/index.d.ts +2 -1
  72. package/lib/typescript/src/components/combobox/index.d.ts.map +1 -1
  73. package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
  74. package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
  75. package/lib/typescript/src/components/live-line-chart/index.d.ts.map +1 -1
  76. package/lib/typescript/src/components/mirror-area-chart/index.d.ts.map +1 -1
  77. package/lib/typescript/src/components/plot/index.d.ts.map +1 -1
  78. package/lib/typescript/src/components/pyramid-chart/index.d.ts.map +1 -1
  79. package/lib/typescript/src/components/questionnaire/index.d.ts.map +1 -1
  80. package/lib/typescript/src/components/radio-group/index.d.ts.map +1 -1
  81. package/lib/typescript/src/components/scatter-chart/index.d.ts.map +1 -1
  82. package/lib/typescript/src/components/scroll-blur/index.d.ts.map +1 -1
  83. package/lib/typescript/src/components/scroll-header/index.d.ts +4 -2
  84. package/lib/typescript/src/components/scroll-header/index.d.ts.map +1 -1
  85. package/lib/typescript/src/components/search-bar/index.d.ts +3 -0
  86. package/lib/typescript/src/components/search-bar/index.d.ts.map +1 -1
  87. package/lib/typescript/src/components/select/index.d.ts +2 -1
  88. package/lib/typescript/src/components/select/index.d.ts.map +1 -1
  89. package/lib/typescript/src/components/switch/index.d.ts +7 -0
  90. package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
  91. package/lib/typescript/src/components/table/index.d.ts.map +1 -1
  92. package/lib/typescript/src/components/toast/index.d.ts +7 -2
  93. package/lib/typescript/src/components/toast/index.d.ts.map +1 -1
  94. package/lib/typescript/src/components/waterfall-chart/index.d.ts.map +1 -1
  95. package/lib/typescript/src/components/week-hours-grid/index.d.ts +56 -0
  96. package/lib/typescript/src/components/week-hours-grid/index.d.ts.map +1 -0
  97. package/lib/typescript/src/components/week-strip/index.d.ts +173 -0
  98. package/lib/typescript/src/components/week-strip/index.d.ts.map +1 -0
  99. package/lib/typescript/src/index.d.ts +3 -1
  100. package/lib/typescript/src/index.d.ts.map +1 -1
  101. package/lib/typescript/src/primitives/scrim.d.ts +56 -2
  102. package/lib/typescript/src/primitives/scrim.d.ts.map +1 -1
  103. package/lib/typescript/src/theme/use-theme.d.ts +32 -1
  104. package/lib/typescript/src/theme/use-theme.d.ts.map +1 -1
  105. package/package.json +1 -1
  106. package/src/components/area-chart/index.tsx +3 -1
  107. package/src/components/bar-chart/index.tsx +3 -1
  108. package/src/components/bubble-chart/index.tsx +3 -1
  109. package/src/components/bump-chart/index.tsx +3 -1
  110. package/src/components/calendar/index.tsx +15 -3
  111. package/src/components/candlestick-chart/index.tsx +3 -1
  112. package/src/components/checkbox/index.tsx +1 -1
  113. package/src/components/combobox/index.tsx +27 -8
  114. package/src/components/heatmap-chart/index.tsx +3 -1
  115. package/src/components/line-chart/index.tsx +3 -1
  116. package/src/components/live-line-chart/index.tsx +3 -1
  117. package/src/components/mirror-area-chart/index.tsx +3 -1
  118. package/src/components/plot/index.tsx +3 -1
  119. package/src/components/pyramid-chart/index.tsx +3 -1
  120. package/src/components/questionnaire/index.tsx +1 -0
  121. package/src/components/radio-group/index.tsx +5 -1
  122. package/src/components/scatter-chart/index.tsx +3 -1
  123. package/src/components/scroll-blur/index.tsx +32 -4
  124. package/src/components/scroll-header/index.tsx +63 -25
  125. package/src/components/search-bar/index.tsx +1 -1
  126. package/src/components/section-progress/index.tsx +1 -1
  127. package/src/components/section-rail/index.tsx +1 -1
  128. package/src/components/select/index.tsx +27 -8
  129. package/src/components/switch/index.tsx +54 -5
  130. package/src/components/table/index.tsx +17 -3
  131. package/src/components/toast/index.tsx +24 -4
  132. package/src/components/waterfall-chart/index.tsx +3 -1
  133. package/src/components/week-hours-grid/index.tsx +238 -0
  134. package/src/components/week-strip/index.tsx +272 -0
  135. package/src/index.ts +16 -0
  136. package/src/primitives/scrim.tsx +56 -4
  137. package/src/theme/use-theme.ts +57 -4
  138. package/theme.css +5 -5
@@ -1,3 +1,4 @@
1
+ import { Appearance, Platform } from 'react-native';
1
2
  import { Uniwind, useUniwind } from 'uniwind';
2
3
 
3
4
  /** Themes shipped in `panelui-native/theme.css`. */
@@ -83,6 +84,58 @@ function findFamily(theme: string): PanelThemeFamily {
83
84
  );
84
85
  }
85
86
 
87
+ /**
88
+ * The light/dark side of a theme PanelUI knows, or `undefined` for one it does
89
+ * not. A theme registered by the app itself has no mode PanelUI can know, and
90
+ * guessing it from the name would pin the system to the wrong one.
91
+ */
92
+ function modeOf(theme: string): ThemeMode | undefined {
93
+ const family = PANEL_THEMES.find(
94
+ (candidate) => candidate.light === theme || candidate.dark === theme
95
+ );
96
+ if (!family) return undefined;
97
+ return family.dark === theme ? 'dark' : 'light';
98
+ }
99
+
100
+ /**
101
+ * Applies a theme, and tells the operating system which side of light and dark
102
+ * it is on.
103
+ *
104
+ * Uniwind keeps the system appearance in step only for `light` and `dark`.
105
+ * Every other name resets it to the device's own setting, so `grass-dark` on a
106
+ * phone set to Light leaves everything the system draws — the native tab bar,
107
+ * alerts, action sheets, the keyboard — in light. The correction runs in the
108
+ * same tick as the theme change, so no frame is drawn with the two disagreeing.
109
+ *
110
+ * `system` is left alone: pinning the appearance there would stop the app
111
+ * hearing about the device changing.
112
+ */
113
+ function applyTheme(name: ThemeName): void {
114
+ Uniwind.setTheme(name);
115
+ if (Platform.OS === 'web' || name === 'system' || name === 'light' || name === 'dark') {
116
+ return;
117
+ }
118
+ const mode = modeOf(name);
119
+ if (mode) Appearance.setColorScheme(mode);
120
+ }
121
+
122
+ /**
123
+ * Sets the theme from outside React — at module scope before the app mounts,
124
+ * from a deep link, or from a settings store.
125
+ *
126
+ * Use this rather than calling `Uniwind.setTheme` directly: it is the same
127
+ * change, plus the system appearance that a named theme needs to match.
128
+ * `useTheme` and `useThemeMode` go through it too.
129
+ *
130
+ * ```ts
131
+ * // app/_layout.tsx, before the root component
132
+ * PanelUITheme.setTheme('grass-dark');
133
+ * ```
134
+ */
135
+ export const PanelUITheme = {
136
+ setTheme: applyTheme,
137
+ } as const;
138
+
86
139
  /**
87
140
  * Reactive access to the current Uniwind theme plus a setter.
88
141
  * Theme changes are applied natively by Uniwind without re-rendering the tree.
@@ -94,7 +147,7 @@ export function useTheme() {
94
147
  /** The active theme name, e.g. `'dark'` or `'moon-dark'`. */
95
148
  theme: theme as PanelTheme,
96
149
  /** Switch theme by name, or `'system'` to follow the device. */
97
- setTheme: (name: ThemeName) => Uniwind.setTheme(name),
150
+ setTheme: applyTheme,
98
151
  };
99
152
  }
100
153
 
@@ -123,11 +176,11 @@ export function useThemeMode() {
123
176
  /** Switch brand, staying in the current light/dark mode. */
124
177
  setFamily: (id: string) => {
125
178
  const next = PANEL_THEMES.find((candidate) => candidate.id === id);
126
- if (next) Uniwind.setTheme(next[mode]);
179
+ if (next) applyTheme(next[mode]);
127
180
  },
128
181
  /** Set the mode, staying in the current family. */
129
- setMode: (next: ThemeMode) => Uniwind.setTheme(family[next]),
182
+ setMode: (next: ThemeMode) => applyTheme(family[next]),
130
183
  /** Flip light ↔ dark within the current family. */
131
- toggleMode: () => Uniwind.setTheme(mode === 'dark' ? family.light : family.dark),
184
+ toggleMode: () => applyTheme(mode === 'dark' ? family.light : family.dark),
132
185
  };
133
186
  }
package/theme.css CHANGED
@@ -453,8 +453,8 @@
453
453
  --color-muted: rgba(0, 0, 0, 0.05);
454
454
  --color-muted-foreground: #6b6f76;
455
455
 
456
- --color-accent: rgba(0, 0, 0, 0.06);
457
- --color-accent-foreground: #08090a;
456
+ --color-accent: rgba(94, 106, 210, 0.1);
457
+ --color-accent-foreground: #3d47a8;
458
458
 
459
459
  --color-destructive: #eb5757;
460
460
  --color-destructive-foreground: #c62b30;
@@ -536,14 +536,14 @@
536
536
  --color-primary: #5e6ad2;
537
537
  --color-primary-foreground: #ffffff;
538
538
 
539
- --color-secondary: rgba(255, 255, 255, 0.06);
539
+ --color-secondary: rgba(255, 255, 255, 0.08);
540
540
  --color-secondary-foreground: #f7f8f8;
541
541
 
542
542
  --color-muted: rgba(255, 255, 255, 0.06);
543
543
  --color-muted-foreground: #8a8f98;
544
544
 
545
- --color-accent: rgba(255, 255, 255, 0.08);
546
- --color-accent-foreground: #f7f8f8;
545
+ --color-accent: rgba(94, 106, 210, 0.18);
546
+ --color-accent-foreground: #b4baf5;
547
547
 
548
548
  --color-destructive: #eb5757;
549
549
  --color-destructive-foreground: #ff8a8a;