@cleanweb/oore 2.0.0-alpha.16 → 2.0.0-alpha.19

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 (99) hide show
  1. package/build/_cjs/base/index.d.ts +3 -0
  2. package/build/_cjs/base/index.js +19 -0
  3. package/build/_cjs/base/merged-state.d.ts +20 -0
  4. package/build/_cjs/base/merged-state.js +61 -0
  5. package/build/_cjs/base/methods.d.ts +58 -0
  6. package/build/_cjs/base/methods.js +95 -0
  7. package/build/_cjs/base/state/class-types.d.ts +20 -0
  8. package/build/_cjs/base/state/class-types.js +2 -0
  9. package/build/_cjs/base/state/class.d.ts +69 -0
  10. package/build/_cjs/base/state/class.js +129 -0
  11. package/build/_cjs/base/state/hook-types.d.ts +32 -0
  12. package/build/_cjs/base/state/hook-types.js +2 -0
  13. package/build/_cjs/base/state/hooks.d.ts +12 -0
  14. package/build/_cjs/base/state/hooks.js +41 -0
  15. package/build/_cjs/base/state/index.d.ts +8 -0
  16. package/build/_cjs/base/state/index.js +34 -0
  17. package/build/_cjs/classy/class/index.d.ts +128 -0
  18. package/build/_cjs/classy/class/index.js +174 -0
  19. package/build/_cjs/classy/class/types/extractor.d.ts +5 -0
  20. package/build/_cjs/classy/class/types/extractor.js +2 -0
  21. package/build/_cjs/classy/class/utils/function-name.d.ts +2 -0
  22. package/build/_cjs/classy/class/utils/function-name.js +17 -0
  23. package/build/_cjs/classy/index.d.ts +3 -0
  24. package/build/_cjs/classy/index.js +19 -0
  25. package/build/_cjs/classy/instance/index.d.ts +144 -0
  26. package/build/_cjs/classy/instance/index.js +177 -0
  27. package/build/_cjs/classy/instance/mount-callbacks.d.ts +5 -0
  28. package/build/_cjs/classy/instance/mount-callbacks.js +30 -0
  29. package/build/_cjs/classy/instance/types/hook.d.ts +13 -0
  30. package/build/_cjs/classy/instance/types/hook.js +2 -0
  31. package/build/_cjs/classy/logic/index.d.ts +116 -0
  32. package/build/_cjs/classy/logic/index.js +123 -0
  33. package/build/_cjs/classy/logic/types/hook.d.ts +16 -0
  34. package/build/_cjs/classy/logic/types/hook.js +2 -0
  35. package/build/_cjs/docs-src/api/base-classes.d.ts +3 -0
  36. package/build/_cjs/docs-src/api/base-classes.js +9 -0
  37. package/build/_cjs/docs-src/api/index.d.ts +13 -0
  38. package/build/_cjs/docs-src/api/index.js +44 -0
  39. package/build/_cjs/docs-src/api/references.d.ts +5 -0
  40. package/build/_cjs/docs-src/api/references.js +31 -0
  41. package/build/_cjs/helpers/errors.d.ts +10 -0
  42. package/build/_cjs/helpers/errors.js +21 -0
  43. package/build/_cjs/helpers/index.d.ts +13 -0
  44. package/build/_cjs/helpers/index.js +31 -0
  45. package/build/_cjs/helpers/mount-state.d.ts +5 -0
  46. package/build/_cjs/helpers/mount-state.js +25 -0
  47. package/build/_cjs/helpers/rerender.d.ts +24 -0
  48. package/build/_cjs/helpers/rerender.js +42 -0
  49. package/build/_cjs/helpers/type-guards.d.ts +1 -0
  50. package/build/_cjs/helpers/type-guards.js +8 -0
  51. package/build/_cjs/helpers/use-component/index.d.ts +6 -0
  52. package/build/_cjs/helpers/use-component/index.js +17 -0
  53. package/build/_cjs/helpers/use-component/types.d.ts +22 -0
  54. package/build/_cjs/helpers/use-component/types.js +2 -0
  55. package/build/_cjs/index.d.ts +3 -0
  56. package/build/_cjs/index.js +19 -0
  57. package/build/_cjs/slots/hook.d.ts +20 -0
  58. package/build/_cjs/slots/hook.js +143 -0
  59. package/build/_cjs/slots/index.d.ts +1 -0
  60. package/build/_cjs/slots/index.js +17 -0
  61. package/build/_cjs/slots/types.d.ts +131 -0
  62. package/build/_cjs/slots/types.js +2 -0
  63. package/build/base/index.js +19 -3
  64. package/build/base/merged-state.js +35 -54
  65. package/build/base/methods.js +23 -25
  66. package/build/base/state/class-types.js +2 -1
  67. package/build/base/state/class.js +49 -69
  68. package/build/base/state/hook-types.js +2 -1
  69. package/build/base/state/hooks.js +12 -12
  70. package/build/base/state/index.d.ts +0 -1
  71. package/build/base/state/index.js +31 -4
  72. package/build/classy/class/index.js +89 -109
  73. package/build/classy/class/types/extractor.js +2 -1
  74. package/build/classy/class/utils/function-name.js +5 -1
  75. package/build/classy/index.js +19 -3
  76. package/build/classy/instance/index.js +62 -84
  77. package/build/classy/instance/mount-callbacks.js +12 -8
  78. package/build/classy/instance/types/hook.js +2 -1
  79. package/build/classy/logic/index.js +27 -28
  80. package/build/classy/logic/types/hook.js +2 -1
  81. package/build/docs-src/api/base-classes.js +9 -3
  82. package/build/docs-src/api/index.js +39 -8
  83. package/build/docs-src/api/references.js +31 -5
  84. package/build/globals.d.ts +130 -83
  85. package/build/helpers/errors.js +5 -1
  86. package/build/helpers/index.js +23 -5
  87. package/build/helpers/mount-state.js +10 -6
  88. package/build/helpers/rerender.js +16 -12
  89. package/build/helpers/type-guards.js +6 -2
  90. package/build/helpers/use-component/index.js +9 -5
  91. package/build/helpers/use-component/types.js +2 -1
  92. package/build/index.d.ts +0 -1
  93. package/build/index.js +19 -3
  94. package/build/slots/hook.js +58 -36
  95. package/build/slots/index.js +17 -1
  96. package/build/slots/types.js +2 -1
  97. package/build/tsconfig.json +5 -6
  98. package/package.json +31 -12
  99. package/build/globals.js +0 -3
@@ -1,84 +1,131 @@
1
- declare const UniqueSecretSymbolKey: unique symbol;
2
- /** /testing: {
3
- const mySymbol = Symbol('asdfgh') as symbol;
4
-
5
- const tt = {
6
- // [mySymbol]: '' as never,
7
- // [UniqueSecretSymbolKey]: '',
8
- // '': '',
9
- }
10
-
11
- let TT: EmptyObject = {};
12
- TT = tt;
13
- }/**/
14
- declare global {
15
- type Optional<BaseType, AllowNull extends boolean = true> = (AllowNull extends true ? BaseType | undefined | null : BaseType | undefined);
16
- type Awaitable<Type> = Type | Promise<Type>;
17
- type Constructor<TInstance extends any = any, TParams extends any[] = never[]> = new (...args: TParams) => TInstance;
18
- /**
19
- * @example
20
- * ```js
21
- * const getNumber: AsyncFunction<number> = async () => {
22
- * return 5;
23
- * }
24
- * ```
25
- */
26
- type AsyncFunction<TReturnValue extends any = void, Params extends any[] = never[]> = (...params: Params) => Promise<TReturnValue>;
27
- /**
28
- * A function that takes no arguments and returns nothing.
29
- * Pass a type argument to set whether `async` and/or `sync` functions are allowed.
30
- */
31
- interface IVoidFunction<AsyncType extends 'async' | 'sync' | 'both' = 'both'> {
32
- (): AsyncType extends 'async' ? Promise<void> : AsyncType extends 'sync' ? void : void | Promise<void>;
33
- }
34
- type AnyFunction = (...args: any) => any;
35
- type FunctionType = AnyFunction;
36
- type TFunction = AnyFunction;
37
- /** @deprecated Use {@link NonNullish} */
38
- type NotNullish = {};
39
- type NonNullish = {};
40
- type NonPrimitive = object;
41
- /**
42
- * Describes an object that has no keys,
43
- * except for a secret unique symbol key,
44
- * whose value type is the union `never | undefuned`.
45
- *
46
- * Having a single key allows the object to throw type errors
47
- * of the form:
48
- * ```
49
- * Type `A` has no properties in common with `EmptyObject`.
50
- * ```
51
- * This may provide a slightly stricter type checking than simply
52
- * using the non-nullish (`{}`) or non-primitive (`object`)
53
- * built-in types.
54
- *
55
- * Note: `EmptyObject` is not assignable to `NeverObject`
56
- * because it has a key whose value type includes `undefined`,
57
- * but `NeverObject` keys can only have a type of `never`.
58
- */
59
- interface EmptyObject {
60
- [UniqueSecretSymbolKey]?: never;
61
- }
62
- /**
63
- * Describes an object that can have any key, but all keys have
64
- * a type of `never`. This effectively prevents any value
65
- * from ever being stored on the object. The object is therefore
66
- * guaranteed to always be empty.
67
- */
68
- interface NeverObject {
69
- [key: keyof any]: never;
70
- }
71
- type valueof<TObject> = TObject[keyof TObject];
72
- interface Window {
73
- }
74
- namespace JSX {
75
- interface IntrinsicElements {
76
- }
77
- }
78
- namespace NodeJS {
79
- interface ProcessEnv {
80
- NODE_ENV: 'development' | 'production' | 'test';
81
- }
82
- }
1
+ interface EmptyObject3 {
2
+ /**
3
+ * It appears keys of the base `symbol` type are excluded from
4
+ * excess property checks. This is likely a bug in TypeScript.
5
+ * Even the "has no properties in common" error disappears if the
6
+ * value being placed into a variable has a key typed as `symbol`.
7
+ * This only applies to the base `symbol` type. Specifc `'unique symbol'`
8
+ * types are unaffected.
9
+ *
10
+ * @example
11
+ * // Consider the following object:
12
+ * const myUniqueSymbol = Symbol('lkjhgfc');
13
+ * let myObj = { [myUniqueSymbol]?: 'a string value' };
14
+ *
15
+ * // We can attempt to reassign `myObj` with the expectation that TS will
16
+ * // warn if any key other than `myUniqueSymbol` is used in the new object.
17
+ * // But this breaks in one specific scenario.
18
+ *
19
+ * // No excess property check when this is used as a key.
20
+ * // Error "no properties in common" also suppressed when this is used as a key.
21
+ * const differentBasicSymbol = Symbol('qwertiop[') as symbol;
22
+ * myObj = { [differentBasicSymbol]: 5 };
23
+ *
24
+ * // Errors emitted as expected when this is used as a key.
25
+ * const differentUniqueSymbol = Symbol('zxcvbnm');
26
+ * myObj = { [differentUniqueSymbol]: 5 };
27
+ */
28
+ [key: symbol]: never;
29
+ }
30
+
31
+
32
+ /////////////
33
+ const UniqueSecretSymbolKey = Symbol('asdfghjkliuytrewqaxcvb,nb');
34
+
35
+ type TEmptyObject1 = { ''?: never };
36
+ type TEmptyObject2 = Record<keyof any, never>;
37
+
38
+ type Optional<
39
+ BaseType,
40
+ AllowNull extends boolean = true
41
+ > = (
42
+ AllowNull extends true
43
+ ? BaseType | undefined | null
44
+ : BaseType | undefined
45
+ )
46
+
47
+ type Awaitable<Type> = Type | Promise<Type>;
48
+
49
+ type Constructor<
50
+ TInstance extends any = any,
51
+ TParams extends any[] = never[]
52
+ > = new (...args: TParams) => TInstance;
53
+
54
+
55
+ /**
56
+ * @example
57
+ * ```js
58
+ * const getNumber: AsyncFunction<number> = async () => {
59
+ * return 5;
60
+ * }
61
+ * ```
62
+ */
63
+ type AsyncFunction<
64
+ TReturnValue extends any = void,
65
+ Params extends any[] = never[]
66
+ > = (...params: Params) => Promise<TReturnValue>
67
+
68
+ /**
69
+ * A function that takes no arguments and returns nothing.
70
+ * Pass a type argument to set whether `async` and/or `sync` functions are allowed.
71
+ */
72
+ interface IVoidFunction<AsyncType extends 'async' | 'sync' | 'both' = 'both'> {
73
+ (): AsyncType extends 'async' ? Promise<void>
74
+ : AsyncType extends 'sync' ? void
75
+ : void | Promise<void>
76
+ }
77
+
78
+ type AnyFunction = (...args: any) => any;
79
+ type FunctionType = AnyFunction;
80
+ type TFunction = AnyFunction;
81
+
82
+ /** @deprecated Use {@link NonNullish} */
83
+ type NotNullish = {};
84
+ type NonNullish = {};
85
+ type NonPrimitive = object;
86
+
87
+
88
+ /**
89
+ * Describes an object that has no keys,
90
+ * except for a secret unique symbol key,
91
+ * whose value type is the union `never | undefuned`.
92
+ *
93
+ * Having a single key allows the object to throw type errors
94
+ * of the form:
95
+ * ```
96
+ * Type `A` has no properties in common with `EmptyObject`.
97
+ * ```
98
+ * This may provide a slightly stricter type checking than simply
99
+ * using the non-nullish (`{}`) or non-primitive (`object`)
100
+ * built-in types.
101
+ *
102
+ * Note: `EmptyObject` is not assignable to `NeverObject`
103
+ * because it has a key whose value type includes `undefined`,
104
+ * but `NeverObject` keys can only have a type of `never`.
105
+ */
106
+ interface EmptyObject {
107
+ [UniqueSecretSymbolKey]?: never;
108
+ }
109
+
110
+ /**
111
+ * Describes an object that can have any key, but all keys have
112
+ * a type of `never`. This effectively prevents any value
113
+ * from ever being stored on the object. The object is therefore
114
+ * guaranteed to always be empty.
115
+ */
116
+ interface NeverObject {
117
+ [key: keyof any]: never;
118
+ }
119
+
120
+ type valueof<TObject> = TObject[keyof TObject];
121
+
122
+
123
+ //////////////////
124
+ interface Window {
125
+ }
126
+
127
+ namespace NodeJS {
128
+ interface ProcessEnv {
129
+ NODE_ENV: 'development' | 'production' | 'test',
130
+ }
83
131
  }
84
- export {};
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throwDevError = void 0;
1
4
  /**
2
5
  * Throw an error with the provided message
3
6
  * only when `NODE_ENV` is *not* 'production'.
@@ -7,7 +10,7 @@
7
10
  * Useful for enforcing certain conditions in development
8
11
  * while failing more gracefully in production.
9
12
  */
10
- export var throwDevError = function (message) {
13
+ const throwDevError = (message) => {
11
14
  if (process.env.NODE_ENV === 'production') {
12
15
  console.warn(message);
13
16
  }
@@ -15,3 +18,4 @@ export var throwDevError = function (message) {
15
18
  throw new Error(message);
16
19
  }
17
20
  };
21
+ exports.throwDevError = throwDevError;
@@ -1,13 +1,31 @@
1
+ "use strict";
1
2
  /**
2
3
  * <!-- @ mergeModuleWith API -->
3
4
  * @module Helpers
4
5
  */
5
- export * from './mount-state';
6
- export * from './rerender';
7
- export * from './use-component';
8
- export * from './type-guards';
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.noOp = void 0;
22
+ __exportStar(require("./mount-state"), exports);
23
+ __exportStar(require("./rerender"), exports);
24
+ __exportStar(require("./use-component"), exports);
25
+ __exportStar(require("./type-guards"), exports);
9
26
  /**
10
27
  * An empty function.
11
28
  * It returns (void) without performing any operations.
12
29
  */
13
- export var noOp = function () { };
30
+ const noOp = () => { };
31
+ exports.noOp = noOp;
@@ -1,21 +1,25 @@
1
- import { useEffect, useRef } from 'react';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMountState = void 0;
4
+ const react_1 = require("react");
2
5
  /**
3
6
  * Returns a value that is false before the component has been mounted,
4
7
  * then true during all subsequent rerenders.
5
8
  */
6
- export var useMountState = function () {
9
+ const useMountState = () => {
7
10
  /**
8
11
  * This must not be a state value. It should not be the cause of a rerender.
9
12
  * It merely provides information about the render count,
10
13
  * without influencing that count itself.
11
14
  * So `mounted` should never be created with `useState`.
12
15
  */
13
- var mounted = useRef(false);
14
- useEffect(function () {
16
+ const mounted = (0, react_1.useRef)(false);
17
+ (0, react_1.useEffect)(() => {
15
18
  mounted.current = true;
16
- return function () {
19
+ return () => {
17
20
  mounted.current = false;
18
21
  };
19
22
  }, []);
20
- return function () { return mounted.current; };
23
+ return () => mounted.current;
21
24
  };
25
+ exports.useMountState = useMountState;
@@ -1,19 +1,22 @@
1
- import { useCallback, useRef, useState } from 'react';
2
- import { useMountState } from '../helpers/mount-state';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useRerender = void 0;
4
+ const react_1 = require("react");
5
+ const mount_state_1 = require("../helpers/mount-state");
3
6
  ;
4
7
  /**
5
8
  * Returns a function that can be called to manually trigger
6
9
  * a rerender of your component.
7
10
  */
8
- export var useRerender = function () {
9
- var isMounted = useMountState();
10
- var renderCount = useRef(0);
11
- var _a = useState(renderCount.current), forceRerender = _a[1];
11
+ const useRerender = () => {
12
+ const isMounted = (0, mount_state_1.useMountState)();
13
+ const renderCount = (0, react_1.useRef)(0);
14
+ const [, forceRerender] = (0, react_1.useState)(renderCount.current);
12
15
  renderCount.current++;
13
- var rerender = useCallback(function () {
14
- var resolve;
15
- var promise = new Promise(function (_r) { return resolve = _r; });
16
- var execute = function () {
16
+ const rerender = (0, react_1.useCallback)(() => {
17
+ let resolve;
18
+ const promise = new Promise((_r) => resolve = _r);
19
+ const execute = () => {
17
20
  forceRerender(renderCount.current);
18
21
  resolve({
19
22
  previousCount: renderCount.current,
@@ -23,7 +26,7 @@ export var useRerender = function () {
23
26
  if (isMounted())
24
27
  execute();
25
28
  else {
26
- setTimeout(function () {
29
+ setTimeout(() => {
27
30
  if (isMounted())
28
31
  execute();
29
32
  else
@@ -32,7 +35,8 @@ export var useRerender = function () {
32
35
  }
33
36
  return promise;
34
37
  }, [forceRerender, renderCount]);
35
- var refresher = function () { return rerender(); };
38
+ const refresher = () => rerender();
36
39
  refresher.currentCount = renderCount.current;
37
40
  return refresher;
38
41
  };
42
+ exports.useRerender = useRerender;
@@ -1,4 +1,8 @@
1
- export var canIndex = function (key, targetObject) {
2
- var test = typeof key === 'number' ? "".concat(key) : key;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.canIndex = void 0;
4
+ const canIndex = (key, targetObject) => {
5
+ const test = typeof key === 'number' ? `${key}` : key;
3
6
  return Reflect.ownKeys(targetObject).includes(test);
4
7
  };
8
+ exports.canIndex = canIndex;
@@ -1,13 +1,17 @@
1
- import { useEffect } from 'react';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Use = void 0;
4
+ const react_1 = require("react");
2
5
  /**
3
6
  * A component you can use to consume React hooks
4
7
  * in a {@link Component | React.Component} class.
5
8
  */
6
- export var Use = function (params) {
7
- var useGenericHook = params.hook, argumentsList = params.argumentsList, onUpdate = params.onUpdate;
8
- var output = useGenericHook.apply(void 0, argumentsList);
9
- useEffect(function () {
9
+ const Use = (params) => {
10
+ const { hook: useGenericHook, argumentsList, onUpdate } = params;
11
+ const output = useGenericHook(...argumentsList);
12
+ (0, react_1.useEffect)(() => {
10
13
  onUpdate(output);
11
14
  }, [output]);
12
15
  return null;
13
16
  };
17
+ exports.Use = Use;
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/build/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './classy';
2
2
  export * from './base';
3
3
  export * from './helpers';
4
- export type { EmptyObject, NeverObject };
package/build/index.js CHANGED
@@ -1,3 +1,19 @@
1
- export * from './classy';
2
- export * from './base';
3
- export * from './helpers';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./classy"), exports);
18
+ __exportStar(require("./base"), exports);
19
+ __exportStar(require("./helpers"), exports);
@@ -1,24 +1,42 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
7
  }
8
- return to.concat(ar || Array.prototype.slice.call(from));
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
9
24
  };
10
- import { throwDevError } from '../helpers/errors';
11
- import React, { useMemo } from 'react';
12
- export var isElementChild = function (child) {
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.useSlots = exports.isPortalChild = exports.getComponentSlotName = exports.isElementChild = void 0;
27
+ const errors_1 = require("../helpers/errors");
28
+ const react_1 = __importStar(require("react"));
29
+ const isElementChild = (child) => {
13
30
  if (child && typeof child === 'object' && 'type' in child) {
14
31
  return true;
15
32
  }
16
33
  return false;
17
34
  };
18
- export var getComponentSlotName = function (TargetComponent, child) {
35
+ exports.isElementChild = isElementChild;
36
+ const getComponentSlotName = (TargetComponent, child) => {
19
37
  if (child) {
20
- var keyTypes = ['string', 'number', 'symbol'];
21
- var slotName = child.props['data-slot-name'];
38
+ const keyTypes = ['string', 'number', 'symbol'];
39
+ const slotName = child.props['data-slot-name'];
22
40
  if (keyTypes.includes(typeof slotName)) {
23
41
  return slotName;
24
42
  }
@@ -34,11 +52,13 @@ export var getComponentSlotName = function (TargetComponent, child) {
34
52
  }
35
53
  return undefined;
36
54
  };
37
- export var isPortalChild = function (child) {
55
+ exports.getComponentSlotName = getComponentSlotName;
56
+ const isPortalChild = (child) => {
38
57
  return (!!child
39
58
  && typeof child === 'object'
40
59
  && 'children' in child);
41
60
  };
61
+ exports.isPortalChild = isPortalChild;
42
62
  /**
43
63
  * Groups `children` prop into predefined slots.
44
64
  *
@@ -49,15 +69,14 @@ export var isPortalChild = function (child) {
49
69
  *
50
70
  * @see {@link SlotComponent} for more on how to use the returned slot nodes.
51
71
  */
52
- export var useSlots = function (children, Caller) {
53
- var slotsAliasLookup = useMemo(function () {
54
- var entries = Object.entries(Caller.Slots);
55
- var aliasLookup = {};
56
- entries.forEach(function (_a) {
57
- var alias = _a[0], RegisteredSlotComponent = _a[1];
58
- var slotName = getComponentSlotName(RegisteredSlotComponent);
72
+ const useSlots = (children, Caller) => {
73
+ const slotsAliasLookup = (0, react_1.useMemo)(() => {
74
+ const entries = Object.entries(Caller.Slots);
75
+ const aliasLookup = {};
76
+ entries.forEach(([alias, RegisteredSlotComponent]) => {
77
+ const slotName = (0, exports.getComponentSlotName)(RegisteredSlotComponent);
59
78
  if (!slotName) {
60
- throwDevError("A registered slot component did not have a slot name. All components registered as slots must either be a string tag-name or a React component with either \"slotName\" or \"displayName\". The affected component was: ".concat(RegisteredSlotComponent));
79
+ (0, errors_1.throwDevError)(`A registered slot component did not have a slot name. All components registered as slots must either be a string tag-name or a React component with either "slotName" or "displayName". The affected component was: ${RegisteredSlotComponent}`);
61
80
  return;
62
81
  }
63
82
  aliasLookup[slotName] = alias;
@@ -65,33 +84,35 @@ export var useSlots = function (children, Caller) {
65
84
  return aliasLookup;
66
85
  }, [Caller.Slots]);
67
86
  // @todo Expose original source order of `children` with respect to slot aliases.
68
- var result = useMemo(function () {
87
+ const result = (0, react_1.useMemo)(() => {
69
88
  var _a;
70
- var slotNodes = {};
71
- var unmatchedChildren = [];
72
- var invalidChildren = [];
73
- var requiredSlotAliases = __spreadArray([], ((_a = Caller.requiredSlotAliases) !== null && _a !== void 0 ? _a : []), true);
74
- React.Children.forEach(children, function (_child) {
89
+ const slotNodes = {};
90
+ const unmatchedChildren = [];
91
+ const invalidChildren = [];
92
+ const requiredSlotAliases = [
93
+ ...((_a = Caller.requiredSlotAliases) !== null && _a !== void 0 ? _a : [])
94
+ ];
95
+ react_1.default.Children.forEach(children, (_child) => {
75
96
  var _a;
76
- var child = _child;
97
+ const child = _child;
77
98
  if (!child) {
78
99
  invalidChildren.push(child);
79
100
  return;
80
101
  }
81
- if (!React.isValidElement(child)) {
82
- console.warn("Invalid node found in JSX children while parsing slots. Got: \"".concat(child, "\"."));
102
+ if (!react_1.default.isValidElement(child)) {
103
+ console.warn(`Invalid node found in JSX children while parsing slots. Got: "${child}".`);
83
104
  invalidChildren.push(child);
84
105
  return;
85
106
  }
86
107
  ;
87
108
  // @todo Check for fragment
88
- if (!isElementChild(child)) {
109
+ if (!(0, exports.isElementChild)(child)) {
89
110
  unmatchedChildren.push(child);
90
111
  return;
91
112
  }
92
- var slotAlias = (function () {
113
+ const slotAlias = (() => {
93
114
  var _a;
94
- var slotName = getComponentSlotName(child.type, child);
115
+ const slotName = (0, exports.getComponentSlotName)(child.type, child);
95
116
  return slotName ? (_a = slotsAliasLookup[slotName]) !== null && _a !== void 0 ? _a : null : null;
96
117
  })();
97
118
  if (slotAlias) {
@@ -110,12 +131,13 @@ export var useSlots = function (children, Caller) {
110
131
  else
111
132
  unmatchedChildren.push(child);
112
133
  });
113
- requiredSlotAliases.forEach(function (slotAlias) {
134
+ requiredSlotAliases.forEach((slotAlias) => {
114
135
  if (!slotNodes[slotAlias]) {
115
- throwDevError("Missing required slot \"".concat(String(slotAlias), "\"."));
136
+ (0, errors_1.throwDevError)(`Missing required slot "${String(slotAlias)}".`);
116
137
  }
117
138
  });
118
139
  return [slotNodes, unmatchedChildren, invalidChildren];
119
140
  }, [children]);
120
141
  return result;
121
142
  };
143
+ exports.useSlots = useSlots;
@@ -1 +1,17 @@
1
- export * from './hook';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./hook"), exports);
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });