@webority-technologies/mobile 0.0.14 → 0.0.20
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/commonjs/components/Accordion/Accordion.js +60 -19
- package/lib/commonjs/components/AppBar/AppBar.js +29 -20
- package/lib/commonjs/components/Avatar/Avatar.js +38 -8
- package/lib/commonjs/components/Badge/Badge.js +66 -4
- package/lib/commonjs/components/Banner/Banner.js +146 -66
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +37 -15
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +85 -50
- package/lib/commonjs/components/Button/Button.js +12 -5
- package/lib/commonjs/components/Card/Card.js +106 -16
- package/lib/commonjs/components/Carousel/Carousel.js +66 -12
- package/lib/commonjs/components/Checkbox/Checkbox.js +11 -7
- package/lib/commonjs/components/Chip/Chip.js +44 -12
- package/lib/commonjs/components/DatePicker/DatePicker.js +185 -76
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +133 -59
- package/lib/commonjs/components/Dialog/Dialog.js +16 -10
- package/lib/commonjs/components/Drawer/Drawer.js +13 -10
- package/lib/commonjs/components/FieldBase/FieldBase.js +306 -0
- package/lib/commonjs/components/FieldBase/index.js +32 -0
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +69 -44
- package/lib/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.js +8 -2
- package/lib/commonjs/components/FormField/FormField.js +3 -2
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +132 -44
- package/lib/commonjs/components/Input/Input.js +144 -181
- package/lib/commonjs/components/ListItem/ListItem.js +90 -11
- package/lib/commonjs/components/Modal/Modal.js +55 -27
- package/lib/commonjs/components/NumberInput/NumberInput.js +60 -106
- package/lib/commonjs/components/OTPInput/OTPInput.js +65 -58
- package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +185 -0
- package/lib/commonjs/components/{AppIcon → PickerTrigger}/index.js +4 -4
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +19 -11
- package/lib/commonjs/components/Radio/Radio.js +11 -6
- package/lib/commonjs/components/Rating/Rating.js +85 -19
- package/lib/commonjs/components/SearchBar/SearchBar.js +84 -107
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +22 -11
- package/lib/commonjs/components/Select/Select.js +62 -91
- package/lib/commonjs/components/Skeleton/Skeleton.js +131 -174
- package/lib/commonjs/components/Skeleton/SkeletonClock.js +117 -0
- package/lib/commonjs/components/Skeleton/SkeletonContent.js +164 -81
- package/lib/commonjs/components/Skeleton/SkeletonProvider.js +72 -10
- package/lib/commonjs/components/Skeleton/index.js +17 -16
- package/lib/commonjs/components/Slider/Slider.js +44 -25
- package/lib/commonjs/components/Stepper/Stepper.js +199 -29
- package/lib/commonjs/components/Swipeable/Swipeable.js +36 -19
- package/lib/commonjs/components/Switch/Switch.js +9 -2
- package/lib/commonjs/components/Tabs/Tabs.js +84 -21
- package/lib/commonjs/components/TimePicker/TimePicker.js +123 -45
- package/lib/commonjs/components/Toast/Toast.js +27 -16
- package/lib/commonjs/components/Tooltip/Tooltip.js +56 -32
- package/lib/commonjs/components/index.js +37 -37
- package/lib/commonjs/theme/tokens.js +55 -7
- package/lib/module/components/Accordion/Accordion.js +61 -20
- package/lib/module/components/AppBar/AppBar.js +29 -20
- package/lib/module/components/Avatar/Avatar.js +39 -9
- package/lib/module/components/Badge/Badge.js +67 -5
- package/lib/module/components/Banner/Banner.js +147 -67
- package/lib/module/components/BottomNavigation/BottomNavigation.js +37 -15
- package/lib/module/components/BottomSheet/BottomSheet.js +87 -52
- package/lib/module/components/Button/Button.js +12 -5
- package/lib/module/components/Card/Card.js +107 -17
- package/lib/module/components/Carousel/Carousel.js +67 -13
- package/lib/module/components/Checkbox/Checkbox.js +11 -7
- package/lib/module/components/Chip/Chip.js +45 -13
- package/lib/module/components/DatePicker/DatePicker.js +185 -76
- package/lib/module/components/DateRangePicker/DateRangePicker.js +134 -60
- package/lib/module/components/Dialog/Dialog.js +16 -10
- package/lib/module/components/Drawer/Drawer.js +13 -10
- package/lib/module/components/FieldBase/FieldBase.js +297 -0
- package/lib/module/components/FieldBase/index.js +4 -0
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +69 -44
- package/lib/module/components/ForceUpdateDialog/ForceUpdateDialog.js +8 -2
- package/lib/module/components/FormField/FormField.js +3 -2
- package/lib/module/components/ImageGallery/ImageGallery.js +128 -40
- package/lib/module/components/Input/Input.js +144 -179
- package/lib/module/components/ListItem/ListItem.js +91 -12
- package/lib/module/components/Modal/Modal.js +55 -27
- package/lib/module/components/NumberInput/NumberInput.js +60 -106
- package/lib/module/components/OTPInput/OTPInput.js +65 -58
- package/lib/module/components/PickerTrigger/PickerTrigger.js +181 -0
- package/lib/module/components/PickerTrigger/index.js +4 -0
- package/lib/module/components/ProgressBar/ProgressBar.js +19 -11
- package/lib/module/components/Radio/Radio.js +11 -6
- package/lib/module/components/Rating/Rating.js +86 -20
- package/lib/module/components/SearchBar/SearchBar.js +84 -107
- package/lib/module/components/SegmentedControl/SegmentedControl.js +22 -11
- package/lib/module/components/Select/Select.js +62 -91
- package/lib/module/components/Skeleton/Skeleton.js +135 -175
- package/lib/module/components/Skeleton/SkeletonClock.js +110 -0
- package/lib/module/components/Skeleton/SkeletonContent.js +167 -84
- package/lib/module/components/Skeleton/SkeletonProvider.js +71 -10
- package/lib/module/components/Skeleton/index.js +3 -2
- package/lib/module/components/Slider/Slider.js +44 -25
- package/lib/module/components/Stepper/Stepper.js +201 -31
- package/lib/module/components/Swipeable/Swipeable.js +36 -19
- package/lib/module/components/Switch/Switch.js +9 -2
- package/lib/module/components/Tabs/Tabs.js +84 -21
- package/lib/module/components/TimePicker/TimePicker.js +123 -45
- package/lib/module/components/Toast/Toast.js +27 -16
- package/lib/module/components/Tooltip/Tooltip.js +56 -32
- package/lib/module/components/index.js +2 -2
- package/lib/module/theme/tokens.js +55 -7
- package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +10 -5
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +8 -0
- package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +12 -6
- package/lib/typescript/commonjs/components/Badge/Badge.d.ts +7 -6
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +17 -6
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +7 -0
- package/lib/typescript/commonjs/components/Card/Card.d.ts +17 -6
- package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +7 -6
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +9 -1
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +13 -6
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +38 -3
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +36 -3
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +13 -1
- package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +141 -0
- package/lib/typescript/commonjs/components/FieldBase/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +8 -6
- package/lib/typescript/commonjs/components/FloatingActionButton/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +7 -0
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +7 -0
- package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +6 -4
- package/lib/typescript/commonjs/components/Input/Input.d.ts +6 -0
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +13 -6
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +3 -0
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +57 -0
- package/lib/typescript/commonjs/components/PickerTrigger/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +3 -0
- package/lib/typescript/commonjs/components/Rating/Rating.d.ts +9 -6
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +49 -20
- package/lib/typescript/commonjs/components/Skeleton/SkeletonClock.d.ts +60 -0
- package/lib/typescript/commonjs/components/Skeleton/SkeletonContent.d.ts +80 -19
- package/lib/typescript/commonjs/components/Skeleton/SkeletonProvider.d.ts +39 -5
- package/lib/typescript/commonjs/components/Skeleton/index.d.ts +6 -4
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +12 -1
- package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +18 -6
- package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +2 -0
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +1 -0
- package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +26 -2
- package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +36 -3
- package/lib/typescript/commonjs/components/Toast/Toast.d.ts +8 -0
- package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +7 -1
- package/lib/typescript/commonjs/components/index.d.ts +5 -5
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/types.d.ts +553 -11
- package/lib/typescript/module/components/Accordion/Accordion.d.ts +10 -5
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +8 -0
- package/lib/typescript/module/components/Avatar/Avatar.d.ts +12 -6
- package/lib/typescript/module/components/Badge/Badge.d.ts +7 -6
- package/lib/typescript/module/components/Banner/Banner.d.ts +17 -6
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +7 -0
- package/lib/typescript/module/components/Card/Card.d.ts +17 -6
- package/lib/typescript/module/components/Carousel/Carousel.d.ts +7 -6
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +9 -1
- package/lib/typescript/module/components/Chip/Chip.d.ts +13 -6
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +38 -3
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +36 -3
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +13 -1
- package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +141 -0
- package/lib/typescript/module/components/FieldBase/index.d.ts +3 -0
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +8 -6
- package/lib/typescript/module/components/FloatingActionButton/index.d.ts +1 -1
- package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +7 -0
- package/lib/typescript/module/components/FormField/FormField.d.ts +7 -0
- package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +6 -4
- package/lib/typescript/module/components/Input/Input.d.ts +6 -0
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +13 -6
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +3 -0
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +57 -0
- package/lib/typescript/module/components/PickerTrigger/index.d.ts +3 -0
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/lib/typescript/module/components/Radio/Radio.d.ts +3 -0
- package/lib/typescript/module/components/Rating/Rating.d.ts +9 -6
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +49 -20
- package/lib/typescript/module/components/Skeleton/SkeletonClock.d.ts +60 -0
- package/lib/typescript/module/components/Skeleton/SkeletonContent.d.ts +80 -19
- package/lib/typescript/module/components/Skeleton/SkeletonProvider.d.ts +39 -5
- package/lib/typescript/module/components/Skeleton/index.d.ts +6 -4
- package/lib/typescript/module/components/Slider/Slider.d.ts +12 -1
- package/lib/typescript/module/components/Stepper/Stepper.d.ts +18 -6
- package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +2 -0
- package/lib/typescript/module/components/Switch/Switch.d.ts +1 -0
- package/lib/typescript/module/components/Tabs/Tabs.d.ts +26 -2
- package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +36 -3
- package/lib/typescript/module/components/Toast/Toast.d.ts +8 -0
- package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +7 -1
- package/lib/typescript/module/components/index.d.ts +5 -5
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/theme/index.d.ts +1 -1
- package/lib/typescript/module/theme/types.d.ts +553 -11
- package/package.json +2 -6
- package/lib/commonjs/components/AppIcon/AppIcon.js +0 -120
- package/lib/commonjs/types/vector-icons.d.js +0 -2
- package/lib/module/components/AppIcon/AppIcon.js +0 -111
- package/lib/module/components/AppIcon/index.js +0 -4
- package/lib/module/types/vector-icons.d.js +0 -2
- package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +0 -20
- package/lib/typescript/commonjs/components/AppIcon/index.d.ts +0 -3
- package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +0 -20
- package/lib/typescript/module/components/AppIcon/index.d.ts +0 -3
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSkeletonClock = exports.SkeletonClockProvider = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _index = require("../../theme/index.js");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
/**
|
|
13
|
+
* SkeletonClock — single shared animation tick for every <Skeleton> on screen.
|
|
14
|
+
*
|
|
15
|
+
* Why this exists: previously every Skeleton primitive ran its own
|
|
16
|
+
* `Animated.loop` on its own `Animated.Value`. A list of 20 placeholders =
|
|
17
|
+
* 20 independent native-driver timers, each starting at a slightly different
|
|
18
|
+
* mount frame, so their shimmer bands drift out of phase within ~1s and the
|
|
19
|
+
* surface feels noisy. CSS-driven web skeleton libs (react-loading-skeleton,
|
|
20
|
+
* MUI) avoid this because the browser owns a single timeline. We emulate
|
|
21
|
+
* that on RN by hoisting the loop into context.
|
|
22
|
+
*
|
|
23
|
+
* The clock produces a value in `[0, 1)` that wraps every `duration` ms. Each
|
|
24
|
+
* Skeleton interpolates that value into its own translateX / opacity output.
|
|
25
|
+
* One native-driver loop, no drift, ~zero JS cost.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const SHIMMER_DURATION = {
|
|
29
|
+
slow: 1800,
|
|
30
|
+
normal: 1200,
|
|
31
|
+
fast: 800
|
|
32
|
+
};
|
|
33
|
+
const PULSE_DURATION = 1000;
|
|
34
|
+
const SkeletonClockContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
35
|
+
/**
|
|
36
|
+
* Owns the loops. Mount one of these inside `SkeletonProvider`; every
|
|
37
|
+
* `<Skeleton>` below it shares the same animated values.
|
|
38
|
+
*/
|
|
39
|
+
const SkeletonClockProvider = ({
|
|
40
|
+
speed,
|
|
41
|
+
enabled,
|
|
42
|
+
variant: _variant,
|
|
43
|
+
children
|
|
44
|
+
}) => {
|
|
45
|
+
const shimmer = (0, _react.useRef)((0, _index.createAnimatedValue)(0)).current;
|
|
46
|
+
const pulse = (0, _react.useRef)((0, _index.createAnimatedValue)(0)).current;
|
|
47
|
+
(0, _react.useEffect)(() => {
|
|
48
|
+
if (!enabled) {
|
|
49
|
+
// Park the values at a deterministic "off" state so any consumer that
|
|
50
|
+
// happens to be reading them still gets a visible (static) skeleton.
|
|
51
|
+
shimmer.setValue(0);
|
|
52
|
+
pulse.setValue(0.5);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Both loops use the native driver — the JS thread doesn't tick for
|
|
57
|
+
// either. Both run continuously; consumers read whichever they need.
|
|
58
|
+
// The negligible cost of running the *other* loop is worth keeping
|
|
59
|
+
// variant switching instant (no remount, no loop teardown).
|
|
60
|
+
const shimmerLoop = _reactNative.Animated.loop(_reactNative.Animated.timing(shimmer, {
|
|
61
|
+
toValue: 1,
|
|
62
|
+
duration: SHIMMER_DURATION[speed],
|
|
63
|
+
easing: _reactNative.Easing.linear,
|
|
64
|
+
useNativeDriver: true
|
|
65
|
+
}));
|
|
66
|
+
const pulseLoop = _reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(pulse, {
|
|
67
|
+
toValue: 1,
|
|
68
|
+
duration: PULSE_DURATION / 2,
|
|
69
|
+
easing: _reactNative.Easing.inOut(_reactNative.Easing.ease),
|
|
70
|
+
useNativeDriver: true
|
|
71
|
+
}), _reactNative.Animated.timing(pulse, {
|
|
72
|
+
toValue: 0,
|
|
73
|
+
duration: PULSE_DURATION / 2,
|
|
74
|
+
easing: _reactNative.Easing.inOut(_reactNative.Easing.ease),
|
|
75
|
+
useNativeDriver: true
|
|
76
|
+
})]));
|
|
77
|
+
shimmerLoop.start();
|
|
78
|
+
pulseLoop.start();
|
|
79
|
+
return () => {
|
|
80
|
+
shimmerLoop.stop();
|
|
81
|
+
pulseLoop.stop();
|
|
82
|
+
};
|
|
83
|
+
// `variant` is intentionally NOT a dependency — both loops always run
|
|
84
|
+
// so switching variants is a single render with no loop teardown.
|
|
85
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
86
|
+
}, [speed, enabled]);
|
|
87
|
+
const value = (0, _react.useMemo)(() => ({
|
|
88
|
+
shimmer,
|
|
89
|
+
pulse,
|
|
90
|
+
enabled
|
|
91
|
+
}), [shimmer, pulse, enabled]);
|
|
92
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(SkeletonClockContext.Provider, {
|
|
93
|
+
value: value,
|
|
94
|
+
children: children
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
exports.SkeletonClockProvider = SkeletonClockProvider;
|
|
98
|
+
SkeletonClockProvider.displayName = 'SkeletonClockProvider';
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Read the active clock. Returns a fallback "always-still" clock when no
|
|
102
|
+
* provider is mounted, so the primitives still render (statically) outside
|
|
103
|
+
* one — keeps demo/storybook usage friction-free.
|
|
104
|
+
*/
|
|
105
|
+
const useSkeletonClock = () => {
|
|
106
|
+
const ctx = (0, _react.useContext)(SkeletonClockContext);
|
|
107
|
+
if (ctx) return ctx;
|
|
108
|
+
// Fallback: a permanently-stopped clock. Created once at module scope.
|
|
109
|
+
return fallbackClock;
|
|
110
|
+
};
|
|
111
|
+
exports.useSkeletonClock = useSkeletonClock;
|
|
112
|
+
const fallbackClock = {
|
|
113
|
+
shimmer: (0, _index.createAnimatedValue)(0),
|
|
114
|
+
pulse: (0, _index.createAnimatedValue)(0.5),
|
|
115
|
+
enabled: false
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=SkeletonClock.js.map
|
|
@@ -6,10 +6,67 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.SkeletonContent = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
+
var _index = require("../../theme/index.js");
|
|
9
10
|
var _Skeleton = require("./Skeleton.js");
|
|
10
11
|
var _SkeletonSkip = require("./SkeletonSkip.js");
|
|
12
|
+
var _SkeletonProvider = require("./SkeletonProvider.js");
|
|
11
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
14
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
+
/**
|
|
16
|
+
* SkeletonContent — show placeholder shapes while data is loading, then
|
|
17
|
+
* cross-fade to the real children once it arrives.
|
|
18
|
+
*
|
|
19
|
+
* Three usage patterns, listed in order of preference:
|
|
20
|
+
*
|
|
21
|
+
* 1. **Explicit placeholder** (recommended):
|
|
22
|
+
*
|
|
23
|
+
* <SkeletonContent loading={isLoading} placeholder={<Card.Skeleton />}>
|
|
24
|
+
* <Card>{realChildren}</Card>
|
|
25
|
+
* </SkeletonContent>
|
|
26
|
+
*
|
|
27
|
+
* Renders `placeholder` verbatim while loading and `children` once loaded.
|
|
28
|
+
* Most precise and predictable — what you write is exactly what shimmers.
|
|
29
|
+
* Prefer this for any non-trivial layout.
|
|
30
|
+
*
|
|
31
|
+
* 2. **Self-describing components inside an auto-walked tree**:
|
|
32
|
+
*
|
|
33
|
+
* <SkeletonContent loading={isLoading}>
|
|
34
|
+
* <Stepper steps={steps} />
|
|
35
|
+
* <Card>...</Card>
|
|
36
|
+
* </SkeletonContent>
|
|
37
|
+
*
|
|
38
|
+
* With no `placeholder` prop, the walker substitutes each element. For
|
|
39
|
+
* library components, the walker checks for a `Component.Skeleton` static
|
|
40
|
+
* and replaces the element wholesale with it (the component author knows
|
|
41
|
+
* its shape best). For plain `<Text>`, `<Image>`, and sized `<View>`
|
|
42
|
+
* leaves the walker substitutes shape-matched `<Skeleton>` blocks based
|
|
43
|
+
* on the element's own style. Good for screen-level wrappers.
|
|
44
|
+
*
|
|
45
|
+
* 3. **Hand-authored primitive trees** (legacy / quick prototyping):
|
|
46
|
+
*
|
|
47
|
+
* <SkeletonContent loading={isLoading}>
|
|
48
|
+
* <View>
|
|
49
|
+
* <Text style={{ fontSize: 20 }}>Title</Text>
|
|
50
|
+
* <Text>Subtitle</Text>
|
|
51
|
+
* </View>
|
|
52
|
+
* </SkeletonContent>
|
|
53
|
+
*
|
|
54
|
+
* Same walker as (2) — the Text/Image/View introspection handles
|
|
55
|
+
* primitive trees that mirror the loaded layout.
|
|
56
|
+
*
|
|
57
|
+
* Cross-fade: when `loading` flips from true to false, real children fade in
|
|
58
|
+
* over `fadeDuration` ms. The first render is guarded — content that was
|
|
59
|
+
* never in a loading state does NOT fade on mount, only the actual
|
|
60
|
+
* loading→loaded transition does. Matches Chakra UI's `isLoaded` feel.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Components that ship their own placeholder shape declare this static. The
|
|
65
|
+
* walker looks for it before falling back to primitive introspection. The
|
|
66
|
+
* function receives the original component's props so consumer-customizable
|
|
67
|
+
* dimensions (size, count, etc.) carry through to the placeholder.
|
|
68
|
+
*/
|
|
69
|
+
|
|
13
70
|
const flattenStyle = style => {
|
|
14
71
|
if (!style) return {};
|
|
15
72
|
const flat = _reactNative.StyleSheet.flatten(style);
|
|
@@ -32,9 +89,9 @@ const skeletonizeNode = (node, variant, speed, colors, keyHint = 'r') => {
|
|
|
32
89
|
if (node == null || typeof node === 'boolean') return null;
|
|
33
90
|
if (typeof node === 'string' || typeof node === 'number') {
|
|
34
91
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.Skeleton, {
|
|
92
|
+
shape: "text",
|
|
35
93
|
width: "60%",
|
|
36
94
|
height: 14,
|
|
37
|
-
radius: "sm",
|
|
38
95
|
variant: variant,
|
|
39
96
|
speed: speed,
|
|
40
97
|
colors: colors
|
|
@@ -46,18 +103,35 @@ const skeletonizeNode = (node, variant, speed, colors, keyHint = 'r') => {
|
|
|
46
103
|
if (! /*#__PURE__*/(0, _react.isValidElement)(node)) return null;
|
|
47
104
|
const element = node;
|
|
48
105
|
const props = element.props ?? {};
|
|
49
|
-
const elementStyle = flattenStyle(props.style);
|
|
50
106
|
const elementType = element.type;
|
|
51
107
|
|
|
52
|
-
// <SkeletonSkip /> → opt-out marker; render its children unchanged
|
|
108
|
+
// <SkeletonSkip /> → opt-out marker; render its children unchanged.
|
|
53
109
|
if (elementType === _SkeletonSkip.SkeletonSkip) {
|
|
54
110
|
return /*#__PURE__*/(0, _react.cloneElement)(element, {
|
|
55
111
|
key: `${keyHint}-skip`
|
|
56
112
|
});
|
|
57
113
|
}
|
|
58
114
|
|
|
59
|
-
//
|
|
115
|
+
// Self-describing component path. If a custom component (Stepper, Card,
|
|
116
|
+
// Banner, etc.) ships a `Skeleton` static, prefer it over the primitive
|
|
117
|
+
// walker — the component author knows the shape better than we can guess.
|
|
118
|
+
// Forwards the original props so consumer-tunable params (size, count,
|
|
119
|
+
// tone) flow through. Crucially this short-circuits the walker BEFORE
|
|
120
|
+
// it tries to recurse into custom-component children, so we never end up
|
|
121
|
+
// rendering half-real / half-placeholder UI.
|
|
122
|
+
if (typeof elementType === 'function' || typeof elementType === 'object') {
|
|
123
|
+
const SkeletonStatic = elementType.Skeleton;
|
|
124
|
+
if (SkeletonStatic) {
|
|
125
|
+
const Sk = SkeletonStatic;
|
|
126
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Sk, {
|
|
127
|
+
...props
|
|
128
|
+
}, `${keyHint}-self`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// <Image /> → fixed-size skeleton block matching style.width/height/borderRadius.
|
|
60
133
|
if (elementType === _reactNative.Image) {
|
|
134
|
+
const elementStyle = flattenStyle(props.style);
|
|
61
135
|
const width = resolveWidth(elementStyle.width, '100%');
|
|
62
136
|
const height = typeof elementStyle.height === 'number' ? elementStyle.height : 120;
|
|
63
137
|
const radius = resolveRadius(elementStyle.borderRadius, 'sm');
|
|
@@ -74,14 +148,15 @@ const skeletonizeNode = (node, variant, speed, colors, keyHint = 'r') => {
|
|
|
74
148
|
}, `${keyHint}-img`);
|
|
75
149
|
}
|
|
76
150
|
|
|
77
|
-
// <Text /> → text-line skeleton matching font size
|
|
151
|
+
// <Text /> → text-line skeleton matching font size.
|
|
78
152
|
if (elementType === _reactNative.Text) {
|
|
153
|
+
const elementStyle = flattenStyle(props.style);
|
|
79
154
|
const fontSize = typeof elementStyle.fontSize === 'number' ? elementStyle.fontSize : 14;
|
|
80
155
|
const width = resolveWidth(elementStyle.width, '85%');
|
|
81
156
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.Skeleton, {
|
|
157
|
+
shape: "text",
|
|
82
158
|
width: width,
|
|
83
159
|
height: Math.round(fontSize * 1.15),
|
|
84
|
-
radius: "sm",
|
|
85
160
|
variant: variant,
|
|
86
161
|
speed: speed,
|
|
87
162
|
colors: colors,
|
|
@@ -91,30 +166,36 @@ const skeletonizeNode = (node, variant, speed, colors, keyHint = 'r') => {
|
|
|
91
166
|
}, `${keyHint}-txt`);
|
|
92
167
|
}
|
|
93
168
|
|
|
94
|
-
// Element with children → recurse, preserving the wrapper (View, Pressable,
|
|
169
|
+
// Element with children → recurse, preserving the wrapper (View, Pressable,
|
|
170
|
+
// custom layouts). Runs AFTER the self-describing check so any component
|
|
171
|
+
// with `.Skeleton` is replaced wholesale.
|
|
95
172
|
if (props.children != null) {
|
|
96
173
|
return /*#__PURE__*/(0, _react.cloneElement)(element, {
|
|
97
174
|
key: `${keyHint}-w`
|
|
98
175
|
}, skeletonizeNode(props.children, variant, speed, colors, `${keyHint}-c`));
|
|
99
176
|
}
|
|
100
177
|
|
|
101
|
-
// Leaf <View /> with explicit dimensions → skeleton block
|
|
102
|
-
if (elementType === _reactNative.View
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
178
|
+
// Leaf <View /> with explicit dimensions → skeleton block.
|
|
179
|
+
if (elementType === _reactNative.View) {
|
|
180
|
+
const elementStyle = flattenStyle(props.style);
|
|
181
|
+
if (elementStyle.width != null || elementStyle.height != null) {
|
|
182
|
+
const width = resolveWidth(elementStyle.width, '100%');
|
|
183
|
+
const height = typeof elementStyle.height === 'number' ? elementStyle.height : 20;
|
|
184
|
+
const radius = resolveRadius(elementStyle.borderRadius, 'sm');
|
|
185
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.Skeleton, {
|
|
186
|
+
width: width,
|
|
187
|
+
height: height,
|
|
188
|
+
radius: radius,
|
|
189
|
+
variant: variant,
|
|
190
|
+
speed: speed,
|
|
191
|
+
colors: colors
|
|
192
|
+
}, `${keyHint}-vw`);
|
|
193
|
+
}
|
|
114
194
|
}
|
|
115
195
|
|
|
116
|
-
// Opaque leaf (custom component without inspectable children
|
|
117
|
-
//
|
|
196
|
+
// Opaque leaf (custom component without inspectable children and without a
|
|
197
|
+
// `.Skeleton` static) → leave as-is. Consumers should provide an explicit
|
|
198
|
+
// `placeholder` or author a `.Skeleton` static to handle these.
|
|
118
199
|
return /*#__PURE__*/(0, _react.cloneElement)(element, {
|
|
119
200
|
key: `${keyHint}-leaf`
|
|
120
201
|
});
|
|
@@ -122,92 +203,94 @@ const skeletonizeNode = (node, variant, speed, colors, keyHint = 'r') => {
|
|
|
122
203
|
const SkeletonContent = ({
|
|
123
204
|
loading,
|
|
124
205
|
children,
|
|
206
|
+
placeholder,
|
|
125
207
|
variant,
|
|
126
208
|
speed,
|
|
127
|
-
mode = 'auto',
|
|
128
209
|
count = 1,
|
|
129
210
|
colors,
|
|
211
|
+
fadeDuration,
|
|
130
212
|
style,
|
|
131
213
|
testID
|
|
132
214
|
}) => {
|
|
215
|
+
const defaults = (0, _SkeletonProvider.useSkeletonDefaults)();
|
|
216
|
+
const resolvedFadeDuration = fadeDuration ?? defaults.fadeDuration ?? 300;
|
|
217
|
+
|
|
218
|
+
// Cross-fade: opacity goes 0 → 1 when loading just flipped off. First
|
|
219
|
+
// render is guarded with `wasLoadingRef` so already-loaded content
|
|
220
|
+
// doesn't fade in on mount.
|
|
221
|
+
const wasLoadingRef = (0, _react.useRef)(loading);
|
|
222
|
+
const fadeAnim = (0, _react.useRef)((0, _index.createAnimatedValue)(loading ? 0 : 1)).current;
|
|
223
|
+
(0, _react.useEffect)(() => {
|
|
224
|
+
if (wasLoadingRef.current && !loading) {
|
|
225
|
+
fadeAnim.setValue(0);
|
|
226
|
+
_reactNative.Animated.timing(fadeAnim, {
|
|
227
|
+
toValue: 1,
|
|
228
|
+
duration: resolvedFadeDuration,
|
|
229
|
+
useNativeDriver: true
|
|
230
|
+
}).start();
|
|
231
|
+
} else if (!wasLoadingRef.current && loading) {
|
|
232
|
+
// Going back into loading from loaded — snap opacity so the
|
|
233
|
+
// placeholder appears instantly when data invalidates.
|
|
234
|
+
fadeAnim.setValue(1);
|
|
235
|
+
}
|
|
236
|
+
wasLoadingRef.current = loading;
|
|
237
|
+
}, [loading, fadeAnim, resolvedFadeDuration]);
|
|
133
238
|
if (!loading) {
|
|
134
|
-
|
|
239
|
+
if (resolvedFadeDuration <= 0) {
|
|
240
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
241
|
+
children: children
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
|
|
245
|
+
style: [style, {
|
|
246
|
+
opacity: fadeAnim
|
|
247
|
+
}],
|
|
248
|
+
testID: testID,
|
|
135
249
|
children: children
|
|
136
250
|
});
|
|
137
251
|
}
|
|
252
|
+
|
|
253
|
+
// Explicit placeholder path — no walker, no introspection.
|
|
254
|
+
if (placeholder !== undefined) {
|
|
255
|
+
const slots = count > 1 ? Array.from({
|
|
256
|
+
length: count
|
|
257
|
+
}, (_, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
|
|
258
|
+
children: placeholder
|
|
259
|
+
}, `sk-ph-${i}`)) : placeholder;
|
|
260
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
261
|
+
style: style,
|
|
262
|
+
testID: testID,
|
|
263
|
+
accessible: true,
|
|
264
|
+
accessibilityLabel: "Loading",
|
|
265
|
+
accessibilityRole: "progressbar",
|
|
266
|
+
accessibilityState: {
|
|
267
|
+
busy: true
|
|
268
|
+
},
|
|
269
|
+
accessibilityLiveRegion: "polite",
|
|
270
|
+
children: slots
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Walker path — auto-substitute primitives and self-describing components.
|
|
138
275
|
const repeated = count > 1 ? Array.from({
|
|
139
276
|
length: count
|
|
140
277
|
}, (_, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
|
|
141
278
|
children: children
|
|
142
279
|
}, `sk-rep-${i}`)) : children;
|
|
143
|
-
if (mode === 'block') {
|
|
144
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockSkeleton, {
|
|
145
|
-
style: style,
|
|
146
|
-
testID: testID,
|
|
147
|
-
variant: variant,
|
|
148
|
-
speed: speed,
|
|
149
|
-
colors: colors,
|
|
150
|
-
children: repeated
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
280
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
154
281
|
style: style,
|
|
155
282
|
testID: testID,
|
|
156
283
|
accessible: true,
|
|
157
284
|
accessibilityLabel: "Loading",
|
|
158
285
|
accessibilityRole: "progressbar",
|
|
286
|
+
accessibilityState: {
|
|
287
|
+
busy: true
|
|
288
|
+
},
|
|
159
289
|
accessibilityLiveRegion: "polite",
|
|
160
290
|
children: skeletonizeNode(repeated, variant, speed, colors)
|
|
161
291
|
});
|
|
162
292
|
};
|
|
163
293
|
exports.SkeletonContent = SkeletonContent;
|
|
164
294
|
SkeletonContent.displayName = 'SkeletonContent';
|
|
165
|
-
const BlockSkeleton = ({
|
|
166
|
-
children,
|
|
167
|
-
variant,
|
|
168
|
-
speed,
|
|
169
|
-
colors,
|
|
170
|
-
style,
|
|
171
|
-
testID
|
|
172
|
-
}) => {
|
|
173
|
-
const [size, setSize] = (0, _react.useState)(null);
|
|
174
|
-
const onLayout = event => {
|
|
175
|
-
const {
|
|
176
|
-
width,
|
|
177
|
-
height
|
|
178
|
-
} = event.nativeEvent.layout;
|
|
179
|
-
if (!size || size.width !== width || size.height !== height) {
|
|
180
|
-
setSize({
|
|
181
|
-
width,
|
|
182
|
-
height
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
187
|
-
style: style,
|
|
188
|
-
testID: testID,
|
|
189
|
-
onLayout: onLayout,
|
|
190
|
-
accessible: true,
|
|
191
|
-
accessibilityLabel: "Loading",
|
|
192
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
193
|
-
style: {
|
|
194
|
-
opacity: 0
|
|
195
|
-
},
|
|
196
|
-
pointerEvents: "none",
|
|
197
|
-
children: children
|
|
198
|
-
}), size != null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
199
|
-
style: _reactNative.StyleSheet.absoluteFill,
|
|
200
|
-
pointerEvents: "none",
|
|
201
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.Skeleton, {
|
|
202
|
-
width: size.width,
|
|
203
|
-
height: size.height,
|
|
204
|
-
radius: "md",
|
|
205
|
-
variant: variant,
|
|
206
|
-
speed: speed,
|
|
207
|
-
colors: colors
|
|
208
|
-
})
|
|
209
|
-
}) : null]
|
|
210
|
-
});
|
|
211
|
-
};
|
|
212
295
|
var _default = exports.default = SkeletonContent;
|
|
213
296
|
//# sourceMappingURL=SkeletonContent.js.map
|
|
@@ -3,14 +3,32 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useSkeletonDefaults = exports.SkeletonProvider = void 0;
|
|
6
|
+
exports.useSkeletonDefaults = exports.useReduceMotion = exports.SkeletonProvider = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _SkeletonClock = require("./SkeletonClock.js");
|
|
8
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
11
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
13
|
+
* SkeletonProvider — app-level defaults for every <Skeleton> below it.
|
|
14
|
+
*
|
|
15
|
+
* Two responsibilities:
|
|
16
|
+
* 1. Broadcasts the default variant / speed / colors / radius /
|
|
17
|
+
* placeholderCount so consumers don't repeat them per call site.
|
|
18
|
+
* 2. Mounts the shared `SkeletonClockProvider` (see SkeletonClock.tsx) so
|
|
19
|
+
* every primitive shares a single Animated.Value — synchronized shimmer
|
|
20
|
+
* across the whole subtree, one native-driver loop per provider.
|
|
21
|
+
*
|
|
22
|
+
* Also honors the OS "Reduce Motion" preference: when enabled, the clock is
|
|
23
|
+
* paused and skeletons render as static dim blocks. The detection is live —
|
|
24
|
+
* if the user toggles the setting while the app is open the skeletons stop
|
|
25
|
+
* shimmering immediately.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Per-instance color override for a skeleton. `background` is the resting
|
|
30
|
+
* tone of the placeholder; `highlight` is the moving shimmer band (or pulse
|
|
31
|
+
* fade). Either can be omitted — missing keys fall back to the active theme.
|
|
14
32
|
*/
|
|
15
33
|
|
|
16
34
|
const SkeletonDefaultsContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
@@ -20,29 +38,73 @@ const SkeletonProvider = ({
|
|
|
20
38
|
speed,
|
|
21
39
|
placeholderCount,
|
|
22
40
|
radius,
|
|
23
|
-
colors
|
|
41
|
+
colors,
|
|
42
|
+
fadeDuration,
|
|
43
|
+
animation = 'auto'
|
|
24
44
|
}) => {
|
|
45
|
+
const reduceMotion = useReduceMotion();
|
|
46
|
+
// Resolve whether the clock should actually tick. `'never'` forces off,
|
|
47
|
+
// `'always'` forces on, `'auto'` follows the OS preference.
|
|
48
|
+
const animationsEnabled = animation === 'always' ? true : animation === 'never' ? false : !reduceMotion;
|
|
49
|
+
const resolvedSpeed = speed ?? 'normal';
|
|
50
|
+
const resolvedVariant = variant ?? 'shimmer';
|
|
25
51
|
const value = (0, _react.useMemo)(() => ({
|
|
26
52
|
variant,
|
|
27
53
|
speed,
|
|
28
54
|
placeholderCount,
|
|
29
55
|
radius,
|
|
30
|
-
colors
|
|
31
|
-
|
|
56
|
+
colors,
|
|
57
|
+
fadeDuration,
|
|
58
|
+
animation
|
|
59
|
+
}), [variant, speed, placeholderCount, radius, colors, fadeDuration, animation]);
|
|
32
60
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(SkeletonDefaultsContext.Provider, {
|
|
33
61
|
value: value,
|
|
34
|
-
children:
|
|
62
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SkeletonClock.SkeletonClockProvider, {
|
|
63
|
+
speed: resolvedSpeed,
|
|
64
|
+
variant: resolvedVariant,
|
|
65
|
+
enabled: animationsEnabled,
|
|
66
|
+
children: children
|
|
67
|
+
})
|
|
35
68
|
});
|
|
36
69
|
};
|
|
37
70
|
exports.SkeletonProvider = SkeletonProvider;
|
|
38
71
|
SkeletonProvider.displayName = 'SkeletonProvider';
|
|
39
72
|
|
|
40
73
|
/**
|
|
41
|
-
* Read the current SkeletonProvider defaults. Returns an empty object when
|
|
42
|
-
* provider is mounted, so the skeleton primitives still work outside of
|
|
74
|
+
* Read the current SkeletonProvider defaults. Returns an empty object when
|
|
75
|
+
* no provider is mounted, so the skeleton primitives still work outside of
|
|
76
|
+
* one — but without a shared clock or theme-coordinated colors.
|
|
43
77
|
*/
|
|
44
78
|
const useSkeletonDefaults = () => {
|
|
45
79
|
return (0, _react.useContext)(SkeletonDefaultsContext);
|
|
46
80
|
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Subscribes to the OS "Reduce Motion" preference. Live — updates when the
|
|
84
|
+
* user toggles the setting while the app is open. Used internally by
|
|
85
|
+
* `SkeletonProvider`; exposed so consumer screens can branch on it too.
|
|
86
|
+
*/
|
|
47
87
|
exports.useSkeletonDefaults = useSkeletonDefaults;
|
|
88
|
+
const useReduceMotion = () => {
|
|
89
|
+
const [reduce, setReduce] = (0, _react.useState)(false);
|
|
90
|
+
(0, _react.useEffect)(() => {
|
|
91
|
+
let mounted = true;
|
|
92
|
+
_reactNative.AccessibilityInfo.isReduceMotionEnabled().then(value => {
|
|
93
|
+
if (mounted) setReduce(value);
|
|
94
|
+
}).catch(() => {
|
|
95
|
+
// Some platforms / older RN versions throw if the native module is
|
|
96
|
+
// missing. Treat as "motion allowed" — degrade quietly to shimmer.
|
|
97
|
+
if (mounted) setReduce(false);
|
|
98
|
+
});
|
|
99
|
+
const sub = _reactNative.AccessibilityInfo.addEventListener('reduceMotionChanged', value => {
|
|
100
|
+
setReduce(value);
|
|
101
|
+
});
|
|
102
|
+
return () => {
|
|
103
|
+
mounted = false;
|
|
104
|
+
sub.remove();
|
|
105
|
+
};
|
|
106
|
+
}, []);
|
|
107
|
+
return reduce;
|
|
108
|
+
};
|
|
109
|
+
exports.useReduceMotion = useReduceMotion;
|
|
48
110
|
//# sourceMappingURL=SkeletonProvider.js.map
|
|
@@ -9,22 +9,16 @@ Object.defineProperty(exports, "Skeleton", {
|
|
|
9
9
|
return _Skeleton.Skeleton;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _Skeleton.SkeletonAvatar;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "SkeletonCard", {
|
|
12
|
+
Object.defineProperty(exports, "SkeletonCircle", {
|
|
19
13
|
enumerable: true,
|
|
20
14
|
get: function () {
|
|
21
|
-
return _Skeleton.
|
|
15
|
+
return _Skeleton.SkeletonCircle;
|
|
22
16
|
}
|
|
23
17
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "SkeletonClockProvider", {
|
|
25
19
|
enumerable: true,
|
|
26
20
|
get: function () {
|
|
27
|
-
return
|
|
21
|
+
return _SkeletonClock.SkeletonClockProvider;
|
|
28
22
|
}
|
|
29
23
|
});
|
|
30
24
|
Object.defineProperty(exports, "SkeletonContent", {
|
|
@@ -39,12 +33,6 @@ Object.defineProperty(exports, "SkeletonList", {
|
|
|
39
33
|
return _SkeletonList.SkeletonList;
|
|
40
34
|
}
|
|
41
35
|
});
|
|
42
|
-
Object.defineProperty(exports, "SkeletonListItem", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _Skeleton.SkeletonListItem;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
36
|
Object.defineProperty(exports, "SkeletonProvider", {
|
|
49
37
|
enumerable: true,
|
|
50
38
|
get: function () {
|
|
@@ -69,6 +57,18 @@ Object.defineProperty(exports, "default", {
|
|
|
69
57
|
return _Skeleton.default;
|
|
70
58
|
}
|
|
71
59
|
});
|
|
60
|
+
Object.defineProperty(exports, "useReduceMotion", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _SkeletonProvider.useReduceMotion;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "useSkeletonClock", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _SkeletonClock.useSkeletonClock;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
72
|
Object.defineProperty(exports, "useSkeletonDefaults", {
|
|
73
73
|
enumerable: true,
|
|
74
74
|
get: function () {
|
|
@@ -79,6 +79,7 @@ var _Skeleton = _interopRequireWildcard(require("./Skeleton.js"));
|
|
|
79
79
|
var _SkeletonContent = require("./SkeletonContent.js");
|
|
80
80
|
var _SkeletonList = require("./SkeletonList.js");
|
|
81
81
|
var _SkeletonProvider = require("./SkeletonProvider.js");
|
|
82
|
+
var _SkeletonClock = require("./SkeletonClock.js");
|
|
82
83
|
var _SkeletonSkip = require("./SkeletonSkip.js");
|
|
83
84
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
84
85
|
//# sourceMappingURL=index.js.map
|