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.
- package/lib/module/components/area-chart/index.js +4 -1
- package/lib/module/components/area-chart/index.js.map +1 -1
- package/lib/module/components/bar-chart/index.js +4 -1
- package/lib/module/components/bar-chart/index.js.map +1 -1
- package/lib/module/components/bubble-chart/index.js +4 -1
- package/lib/module/components/bubble-chart/index.js.map +1 -1
- package/lib/module/components/bump-chart/index.js +4 -1
- package/lib/module/components/bump-chart/index.js.map +1 -1
- package/lib/module/components/calendar/index.js +15 -2
- package/lib/module/components/calendar/index.js.map +1 -1
- package/lib/module/components/candlestick-chart/index.js +4 -1
- package/lib/module/components/candlestick-chart/index.js.map +1 -1
- package/lib/module/components/checkbox/index.js +2 -1
- package/lib/module/components/checkbox/index.js.map +1 -1
- package/lib/module/components/combobox/index.js +28 -7
- package/lib/module/components/combobox/index.js.map +1 -1
- package/lib/module/components/heatmap-chart/index.js +4 -1
- package/lib/module/components/heatmap-chart/index.js.map +1 -1
- package/lib/module/components/line-chart/index.js +4 -1
- package/lib/module/components/line-chart/index.js.map +1 -1
- package/lib/module/components/live-line-chart/index.js +4 -1
- package/lib/module/components/live-line-chart/index.js.map +1 -1
- package/lib/module/components/mirror-area-chart/index.js +4 -1
- package/lib/module/components/mirror-area-chart/index.js.map +1 -1
- package/lib/module/components/plot/index.js +4 -1
- package/lib/module/components/plot/index.js.map +1 -1
- package/lib/module/components/pyramid-chart/index.js +4 -1
- package/lib/module/components/pyramid-chart/index.js.map +1 -1
- package/lib/module/components/questionnaire/index.js +1 -0
- package/lib/module/components/questionnaire/index.js.map +1 -1
- package/lib/module/components/radio-group/index.js +2 -1
- package/lib/module/components/radio-group/index.js.map +1 -1
- package/lib/module/components/scatter-chart/index.js +4 -1
- package/lib/module/components/scatter-chart/index.js.map +1 -1
- package/lib/module/components/scroll-blur/index.js +25 -7
- package/lib/module/components/scroll-blur/index.js.map +1 -1
- package/lib/module/components/scroll-header/index.js +44 -24
- package/lib/module/components/scroll-header/index.js.map +1 -1
- package/lib/module/components/search-bar/index.js +2 -1
- package/lib/module/components/search-bar/index.js.map +1 -1
- package/lib/module/components/section-progress/index.js +1 -1
- package/lib/module/components/section-progress/index.js.map +1 -1
- package/lib/module/components/section-rail/index.js +1 -1
- package/lib/module/components/section-rail/index.js.map +1 -1
- package/lib/module/components/select/index.js +28 -7
- package/lib/module/components/select/index.js.map +1 -1
- package/lib/module/components/switch/index.js +51 -15
- package/lib/module/components/switch/index.js.map +1 -1
- package/lib/module/components/table/index.js +17 -3
- package/lib/module/components/table/index.js.map +1 -1
- package/lib/module/components/toast/index.js +13 -3
- package/lib/module/components/toast/index.js.map +1 -1
- package/lib/module/components/waterfall-chart/index.js +4 -1
- package/lib/module/components/waterfall-chart/index.js.map +1 -1
- package/lib/module/components/week-hours-grid/index.js +187 -0
- package/lib/module/components/week-hours-grid/index.js.map +1 -0
- package/lib/module/components/week-strip/index.js +232 -0
- package/lib/module/components/week-strip/index.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/primitives/scrim.js +50 -2
- package/lib/module/primitives/scrim.js.map +1 -1
- package/lib/module/theme/use-theme.js +55 -4
- package/lib/module/theme/use-theme.js.map +1 -1
- package/lib/typescript/src/components/area-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/bar-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/bubble-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/bump-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/calendar/index.d.ts.map +1 -1
- package/lib/typescript/src/components/candlestick-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/combobox/index.d.ts +2 -1
- package/lib/typescript/src/components/combobox/index.d.ts.map +1 -1
- package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/live-line-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/mirror-area-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/plot/index.d.ts.map +1 -1
- package/lib/typescript/src/components/pyramid-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/questionnaire/index.d.ts.map +1 -1
- package/lib/typescript/src/components/radio-group/index.d.ts.map +1 -1
- package/lib/typescript/src/components/scatter-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/scroll-blur/index.d.ts.map +1 -1
- package/lib/typescript/src/components/scroll-header/index.d.ts +4 -2
- package/lib/typescript/src/components/scroll-header/index.d.ts.map +1 -1
- package/lib/typescript/src/components/search-bar/index.d.ts +3 -0
- package/lib/typescript/src/components/search-bar/index.d.ts.map +1 -1
- package/lib/typescript/src/components/select/index.d.ts +2 -1
- package/lib/typescript/src/components/select/index.d.ts.map +1 -1
- package/lib/typescript/src/components/switch/index.d.ts +7 -0
- package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
- package/lib/typescript/src/components/table/index.d.ts.map +1 -1
- package/lib/typescript/src/components/toast/index.d.ts +7 -2
- package/lib/typescript/src/components/toast/index.d.ts.map +1 -1
- package/lib/typescript/src/components/waterfall-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/week-hours-grid/index.d.ts +56 -0
- package/lib/typescript/src/components/week-hours-grid/index.d.ts.map +1 -0
- package/lib/typescript/src/components/week-strip/index.d.ts +173 -0
- package/lib/typescript/src/components/week-strip/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/primitives/scrim.d.ts +56 -2
- package/lib/typescript/src/primitives/scrim.d.ts.map +1 -1
- package/lib/typescript/src/theme/use-theme.d.ts +32 -1
- package/lib/typescript/src/theme/use-theme.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/area-chart/index.tsx +3 -1
- package/src/components/bar-chart/index.tsx +3 -1
- package/src/components/bubble-chart/index.tsx +3 -1
- package/src/components/bump-chart/index.tsx +3 -1
- package/src/components/calendar/index.tsx +15 -3
- package/src/components/candlestick-chart/index.tsx +3 -1
- package/src/components/checkbox/index.tsx +1 -1
- package/src/components/combobox/index.tsx +27 -8
- package/src/components/heatmap-chart/index.tsx +3 -1
- package/src/components/line-chart/index.tsx +3 -1
- package/src/components/live-line-chart/index.tsx +3 -1
- package/src/components/mirror-area-chart/index.tsx +3 -1
- package/src/components/plot/index.tsx +3 -1
- package/src/components/pyramid-chart/index.tsx +3 -1
- package/src/components/questionnaire/index.tsx +1 -0
- package/src/components/radio-group/index.tsx +5 -1
- package/src/components/scatter-chart/index.tsx +3 -1
- package/src/components/scroll-blur/index.tsx +32 -4
- package/src/components/scroll-header/index.tsx +63 -25
- package/src/components/search-bar/index.tsx +1 -1
- package/src/components/section-progress/index.tsx +1 -1
- package/src/components/section-rail/index.tsx +1 -1
- package/src/components/select/index.tsx +27 -8
- package/src/components/switch/index.tsx +54 -5
- package/src/components/table/index.tsx +17 -3
- package/src/components/toast/index.tsx +24 -4
- package/src/components/waterfall-chart/index.tsx +3 -1
- package/src/components/week-hours-grid/index.tsx +238 -0
- package/src/components/week-strip/index.tsx +272 -0
- package/src/index.ts +16 -0
- package/src/primitives/scrim.tsx +56 -4
- package/src/theme/use-theme.ts +57 -4
- package/theme.css +5 -5
package/src/theme/use-theme.ts
CHANGED
|
@@ -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:
|
|
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)
|
|
179
|
+
if (next) applyTheme(next[mode]);
|
|
127
180
|
},
|
|
128
181
|
/** Set the mode, staying in the current family. */
|
|
129
|
-
setMode: (next: ThemeMode) =>
|
|
182
|
+
setMode: (next: ThemeMode) => applyTheme(family[next]),
|
|
130
183
|
/** Flip light ↔ dark within the current family. */
|
|
131
|
-
toggleMode: () =>
|
|
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(
|
|
457
|
-
--color-accent-foreground: #
|
|
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.
|
|
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(
|
|
546
|
-
--color-accent-foreground: #
|
|
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;
|