react-native-skelo 0.0.5 → 0.1.0-alpha.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 (55) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +77 -88
  3. package/lib/commonjs/animations/PulseAnimation.js +42 -17
  4. package/lib/commonjs/animations/PulseAnimation.js.map +1 -1
  5. package/lib/commonjs/animations/ShimmerAnimation.js +65 -54
  6. package/lib/commonjs/animations/ShimmerAnimation.js.map +1 -1
  7. package/lib/commonjs/components/Skeleton.js +8 -20
  8. package/lib/commonjs/components/Skeleton.js.map +1 -1
  9. package/lib/commonjs/index.js +0 -1
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/module/animations/PulseAnimation.js +43 -18
  12. package/lib/module/animations/PulseAnimation.js.map +1 -1
  13. package/lib/module/animations/ShimmerAnimation.js +66 -55
  14. package/lib/module/animations/ShimmerAnimation.js.map +1 -1
  15. package/lib/module/components/Skeleton.js +8 -20
  16. package/lib/module/components/Skeleton.js.map +1 -1
  17. package/lib/module/index.js +0 -4
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/typescript/animations/PulseAnimation.d.ts +44 -0
  20. package/lib/typescript/animations/PulseAnimation.d.ts.map +1 -1
  21. package/lib/typescript/animations/ShimmerAnimation.d.ts +44 -0
  22. package/lib/typescript/animations/ShimmerAnimation.d.ts.map +1 -1
  23. package/lib/typescript/components/Skeleton.d.ts +1 -1
  24. package/lib/typescript/components/Skeleton.d.ts.map +1 -1
  25. package/lib/typescript/index.d.ts +0 -1
  26. package/lib/typescript/index.d.ts.map +1 -1
  27. package/lib/typescript/types/skeleton.d.ts +0 -8
  28. package/lib/typescript/types/skeleton.d.ts.map +1 -1
  29. package/package.json +12 -23
  30. package/src/animations/PulseAnimation.tsx +89 -17
  31. package/src/animations/ShimmerAnimation.tsx +118 -39
  32. package/src/components/Skeleton.tsx +8 -22
  33. package/src/index.ts +0 -4
  34. package/src/types/skeleton.ts +0 -9
  35. package/lib/commonjs/core/deepRegistry.js +0 -18
  36. package/lib/commonjs/core/deepRegistry.js.map +0 -1
  37. package/lib/commonjs/core/parser/expandLists.js +0 -67
  38. package/lib/commonjs/core/parser/expandLists.js.map +0 -1
  39. package/lib/commonjs/deep.js +0 -18
  40. package/lib/commonjs/deep.js.map +0 -1
  41. package/lib/module/core/deepRegistry.js +0 -11
  42. package/lib/module/core/deepRegistry.js.map +0 -1
  43. package/lib/module/core/parser/expandLists.js +0 -61
  44. package/lib/module/core/parser/expandLists.js.map +0 -1
  45. package/lib/module/deep.js +0 -11
  46. package/lib/module/deep.js.map +0 -1
  47. package/lib/typescript/core/deepRegistry.d.ts +0 -7
  48. package/lib/typescript/core/deepRegistry.d.ts.map +0 -1
  49. package/lib/typescript/core/parser/expandLists.d.ts +0 -3
  50. package/lib/typescript/core/parser/expandLists.d.ts.map +0 -1
  51. package/lib/typescript/deep.d.ts +0 -2
  52. package/lib/typescript/deep.d.ts.map +0 -1
  53. package/src/core/deepRegistry.ts +0 -16
  54. package/src/core/parser/expandLists.tsx +0 -77
  55. package/src/deep.ts +0 -12
@@ -1,61 +0,0 @@
1
- import React, { isValidElement } from 'react';
2
- import { View } from 'react-native';
3
- import { getComponentName } from '../../utils/componentUtils';
4
-
5
- // List components whose rows come from `renderItem` (not JSX children).
6
- const LIST_TYPES = new Set(['FlatList', 'SectionList', 'VirtualizedList', 'FlashList']);
7
- const NOOP_SEPARATORS = {
8
- highlight: () => {},
9
- unhighlight: () => {},
10
- updateProps: () => {}
11
- };
12
-
13
- // Renders `count` sample rows from a list's `renderItem` so there's something
14
- // to skeletonize while the real data is still loading (the rows don't exist in
15
- // the tree yet). Rows that throw on placeholder data are skipped.
16
- function renderSampleRows(list, count) {
17
- const props = list.props || {};
18
- const data = Array.isArray(props.data) ? props.data : [];
19
- const sample = data.length > 0 ? data[0] : {};
20
- const rows = [];
21
- for (let i = 0; i < count; i++) {
22
- try {
23
- const row = props.renderItem?.({
24
- item: sample,
25
- index: i,
26
- section: {},
27
- separators: NOOP_SEPARATORS
28
- });
29
- if (row) {
30
- rows.push(/*#__PURE__*/React.createElement(React.Fragment, {
31
- key: i
32
- }, row));
33
- }
34
- } catch {
35
- // Row couldn't render with placeholder data — skip it.
36
- }
37
- }
38
- return /*#__PURE__*/React.createElement(View, {
39
- style: props.contentContainerStyle
40
- }, rows);
41
- }
42
-
43
- // Walks a child tree and replaces FlatList/SectionList with sample rows so a
44
- // plain `<Skeleton><FlatList/></Skeleton>` produces a skeleton while loading.
45
- export function expandListPlaceholders(children, count) {
46
- return React.Children.map(children, child => {
47
- if (! /*#__PURE__*/isValidElement(child)) {
48
- return child;
49
- }
50
- const name = getComponentName(child);
51
- const props = child.props || {};
52
- if (LIST_TYPES.has(name) && typeof props.renderItem === 'function') {
53
- return renderSampleRows(child, count);
54
- }
55
- if (props.children) {
56
- return /*#__PURE__*/React.cloneElement(child, undefined, expandListPlaceholders(props.children, count));
57
- }
58
- return child;
59
- });
60
- }
61
- //# sourceMappingURL=expandLists.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","isValidElement","View","getComponentName","LIST_TYPES","Set","NOOP_SEPARATORS","highlight","unhighlight","updateProps","renderSampleRows","list","count","props","data","Array","isArray","sample","length","rows","i","row","renderItem","item","index","section","separators","push","createElement","Fragment","key","style","contentContainerStyle","expandListPlaceholders","children","Children","map","child","name","has","cloneElement","undefined"],"sourceRoot":"../../../../src","sources":["core/parser/expandLists.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,cAAc,QAAQ,OAAO;AAE7C,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,gBAAgB,QAAQ,4BAA4B;;AAE7D;AACA,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAC,CAAC,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,CAAC,CAAC;AAEvF,MAAMC,eAAe,GAAG;EACtBC,SAAS,EAAEA,CAAA,KAAM,CAAC,CAAC;EACnBC,W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AAI,eAACpC,cAAc,CAACoC,KAAK,CAAC,EAAE;MAC1B,OAAOA,KAAK;IACd;IAEA,MAAMC,IAAI,GAAGnC,gBAAgB,CAACkC,KAAK,CAAC;IACpC,MAAMxB,KAAK,GAAIwB,KAAK,CAACxB,KAAK,IAAI,CAAC,CAA8B;IAE7D,IACET,UAAU,CAACmC,GAAG,CAACD,IAAI,CAAC,IACpB,OAAQzB,KAAK,CAA8BS,UAAU,KAAK,UAAU,EACpE;MACA,OAAOZ,gBAAgB,CAAC2B,KAAK,EAAEzB,KAAK,CAAC;IACvC;IAEA,IAAIC,KAAK,CAACqB,QAAQ,EAAE;MAClB,oBAAOlC,KAAK,CAACwC,YAAY,CAACH,KAAK,EAAEI,SAAS,EAAER,sBAAsB,CAACpB,KAAK,CAACqB,QAAQ,EAAEtB,KAAK,CAAC,CAAC;IAC5F;IAEA,OAAOyB,KAAK;EACd,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- // Opt-in deep mode. Import once in your app entry to enable `<Skeleton deep>`:
2
- //
3
- // import 'react-native-skelo/deep';
4
- //
5
- // This is the only module that pulls in react-reconciler, so apps that don't
6
- // use deep mode never bundle it. Requires `react-reconciler` to be installed.
7
- import { setDeepExpander } from './core/deepRegistry';
8
- import { expandToComponentNodes } from './core/parser/expandOffline';
9
- setDeepExpander(expandToComponentNodes);
10
- export const deepEnabled = true;
11
- //# sourceMappingURL=deep.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["setDeepExpander","expandToComponentNodes","deepEnabled"],"sourceRoot":"../../src","sources":["deep.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,qBAAqB;AACrD,SAASC,sBAAsB,QAAQ,6BAA6B;AAEpED,eAAe,CAACC,sBAAsB,CAAC;AAEvC,OAAO,MAAMC,WAAW,GAAG,IAAI","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- import type { ComponentNode } from '../types';
3
- type DeepExpander = (element: ReactElement) => ComponentNode[] | null;
4
- export declare function setDeepExpander(fn: DeepExpander): void;
5
- export declare function getDeepExpander(): DeepExpander | null;
6
- export {};
7
- //# sourceMappingURL=deepRegistry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deepRegistry.d.ts","sourceRoot":"","sources":["../../../src/core/deepRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C,KAAK,YAAY,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,aAAa,EAAE,GAAG,IAAI,CAAC;AAItE,wBAAgB,eAAe,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAEtD;AAED,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CAErD"}
@@ -1,3 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- export declare function expandListPlaceholders(children: ReactNode, count: number): ReactNode;
3
- //# sourceMappingURL=expandLists.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expandLists.d.ts","sourceRoot":"","sources":["../../../../src/core/parser/expandLists.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAqDrD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAsBpF"}
@@ -1,2 +0,0 @@
1
- export declare const deepEnabled = true;
2
- //# sourceMappingURL=deep.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deep.d.ts","sourceRoot":"","sources":["../../src/deep.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,WAAW,OAAO,CAAC"}
@@ -1,16 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- import type { ComponentNode } from '../types';
3
-
4
- // Deep expansion is opt-in so the core bundle never depends on react-reconciler.
5
- // `react-native-skelo/deep` registers the expander; Skeleton reads it here.
6
- type DeepExpander = (element: ReactElement) => ComponentNode[] | null;
7
-
8
- let expander: DeepExpander | null = null;
9
-
10
- export function setDeepExpander(fn: DeepExpander): void {
11
- expander = fn;
12
- }
13
-
14
- export function getDeepExpander(): DeepExpander | null {
15
- return expander;
16
- }
@@ -1,77 +0,0 @@
1
- import React, { isValidElement } from 'react';
2
- import type { ReactElement, ReactNode } from 'react';
3
- import { View } from 'react-native';
4
- import { getComponentName } from '../../utils/componentUtils';
5
-
6
- // List components whose rows come from `renderItem` (not JSX children).
7
- const LIST_TYPES = new Set(['FlatList', 'SectionList', 'VirtualizedList', 'FlashList']);
8
-
9
- const NOOP_SEPARATORS = {
10
- highlight: () => {},
11
- unhighlight: () => {},
12
- updateProps: () => {},
13
- };
14
-
15
- // Renders `count` sample rows from a list's `renderItem` so there's something
16
- // to skeletonize while the real data is still loading (the rows don't exist in
17
- // the tree yet). Rows that throw on placeholder data are skipped.
18
- function renderSampleRows(list: ReactElement, count: number): ReactNode {
19
- const props = (list.props || {}) as {
20
- renderItem?: (info: {
21
- item: unknown;
22
- index: number;
23
- section?: unknown;
24
- separators: typeof NOOP_SEPARATORS;
25
- }) => ReactNode;
26
- data?: unknown[];
27
- contentContainerStyle?: unknown;
28
- };
29
-
30
- const data = Array.isArray(props.data) ? props.data : [];
31
- const sample = data.length > 0 ? data[0] : {};
32
-
33
- const rows: ReactNode[] = [];
34
- for (let i = 0; i < count; i++) {
35
- try {
36
- const row = props.renderItem?.({
37
- item: sample,
38
- index: i,
39
- section: {},
40
- separators: NOOP_SEPARATORS,
41
- });
42
- if (row) {
43
- rows.push(<React.Fragment key={i}>{row}</React.Fragment>);
44
- }
45
- } catch {
46
- // Row couldn't render with placeholder data — skip it.
47
- }
48
- }
49
-
50
- return <View style={props.contentContainerStyle as never}>{rows}</View>;
51
- }
52
-
53
- // Walks a child tree and replaces FlatList/SectionList with sample rows so a
54
- // plain `<Skeleton><FlatList/></Skeleton>` produces a skeleton while loading.
55
- export function expandListPlaceholders(children: ReactNode, count: number): ReactNode {
56
- return React.Children.map(children, child => {
57
- if (!isValidElement(child)) {
58
- return child;
59
- }
60
-
61
- const name = getComponentName(child);
62
- const props = (child.props || {}) as { children?: ReactNode };
63
-
64
- if (
65
- LIST_TYPES.has(name) &&
66
- typeof (props as { renderItem?: unknown }).renderItem === 'function'
67
- ) {
68
- return renderSampleRows(child, count);
69
- }
70
-
71
- if (props.children) {
72
- return React.cloneElement(child, undefined, expandListPlaceholders(props.children, count));
73
- }
74
-
75
- return child;
76
- });
77
- }
package/src/deep.ts DELETED
@@ -1,12 +0,0 @@
1
- // Opt-in deep mode. Import once in your app entry to enable `<Skeleton deep>`:
2
- //
3
- // import 'react-native-skelo/deep';
4
- //
5
- // This is the only module that pulls in react-reconciler, so apps that don't
6
- // use deep mode never bundle it. Requires `react-reconciler` to be installed.
7
- import { setDeepExpander } from './core/deepRegistry';
8
- import { expandToComponentNodes } from './core/parser/expandOffline';
9
-
10
- setDeepExpander(expandToComponentNodes);
11
-
12
- export const deepEnabled = true;