@startlibs/core 1.0.7 → 1.2.0-rc.1

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 (173) hide show
  1. package/lib/SlotFill.mjs +232 -0
  2. package/lib/SlotFill.mjs.map +1 -0
  3. package/lib/StartlibsProvider.mjs +62 -0
  4. package/lib/StartlibsProvider.mjs.map +1 -0
  5. package/lib/hocs/WithLazyResource.mjs +74 -0
  6. package/lib/hocs/WithLazyResource.mjs.map +1 -0
  7. package/lib/hocs/WithRef.mjs +20 -0
  8. package/lib/hocs/WithRef.mjs.map +1 -0
  9. package/lib/hocs/consumes.mjs +22 -0
  10. package/lib/hocs/consumes.mjs.map +1 -0
  11. package/lib/hocs/withDialogError.mjs +22 -0
  12. package/lib/hocs/withDialogError.mjs.map +1 -0
  13. package/lib/hocs/withGroupEvent.mjs +45 -0
  14. package/lib/hocs/withGroupEvent.mjs.map +1 -0
  15. package/lib/hooks/WithConstant.mjs +13 -0
  16. package/lib/hooks/WithConstant.mjs.map +1 -0
  17. package/lib/hooks/WithEffect.mjs +12 -0
  18. package/lib/hooks/WithEffect.mjs.map +1 -0
  19. package/lib/hooks/useAsyncEffect.mjs +14 -0
  20. package/lib/hooks/useAsyncEffect.mjs.map +1 -0
  21. package/lib/hooks/useCallState.mjs +21 -0
  22. package/lib/hooks/useCallState.mjs.map +1 -0
  23. package/lib/hooks/useCallbackStable.mjs +17 -0
  24. package/lib/hooks/useCallbackStable.mjs.map +1 -0
  25. package/lib/hooks/useConstant.mjs +21 -0
  26. package/lib/hooks/useConstant.mjs.map +1 -0
  27. package/lib/hooks/useConsumerCatalog.mjs +25 -0
  28. package/lib/hooks/useConsumerCatalog.mjs.map +1 -0
  29. package/lib/hooks/useEnsureRef.mjs +9 -0
  30. package/lib/hooks/useEnsureRef.mjs.map +1 -0
  31. package/lib/hooks/useForceUpdate.mjs +28 -0
  32. package/lib/hooks/useForceUpdate.mjs.map +1 -0
  33. package/lib/hooks/useIsUnmounted.mjs +15 -0
  34. package/lib/hooks/useIsUnmounted.mjs.map +1 -0
  35. package/lib/hooks/usePopupToggle.mjs +33 -0
  36. package/lib/hooks/usePopupToggle.mjs.map +1 -0
  37. package/lib/hooks/usePrevious.mjs +28 -0
  38. package/lib/hooks/usePrevious.mjs.map +1 -0
  39. package/lib/hooks/useRecycleFocus.mjs +36 -0
  40. package/lib/hooks/useRecycleFocus.mjs.map +1 -0
  41. package/lib/hooks/useRefMemo.mjs +13 -0
  42. package/lib/hooks/useRefMemo.mjs.map +1 -0
  43. package/lib/hooks/useRefState.mjs +29 -0
  44. package/lib/hooks/useRefState.mjs.map +1 -0
  45. package/lib/hooks/useSignal.mjs +271 -0
  46. package/lib/hooks/useSignal.mjs.map +1 -0
  47. package/lib/hooks/useTitle.mjs +17 -0
  48. package/lib/hooks/useTitle.mjs.map +1 -0
  49. package/lib/hooks/useToggle.mjs +152 -0
  50. package/lib/hooks/useToggle.mjs.map +1 -0
  51. package/lib/hooks/useUpdateEffect.mjs +15 -0
  52. package/lib/hooks/useUpdateEffect.mjs.map +1 -0
  53. package/lib/hooks/useUpdateOnResize.mjs +18 -0
  54. package/lib/hooks/useUpdateOnResize.mjs.map +1 -0
  55. package/lib/hooks/useWithTransition.mjs +18 -0
  56. package/lib/hooks/useWithTransition.mjs.map +1 -0
  57. package/lib/hooks/willUseLayers.mjs +55 -0
  58. package/lib/hooks/willUseLayers.mjs.map +1 -0
  59. package/lib/hooks/willUseSharedCallback.mjs +70 -0
  60. package/lib/hooks/willUseSharedCallback.mjs.map +1 -0
  61. package/lib/hooks/willUseSharedState.mjs +41 -0
  62. package/lib/hooks/willUseSharedState.mjs.map +1 -0
  63. package/lib/hooks/willUseSpreadState.mjs +119 -0
  64. package/lib/hooks/willUseSpreadState.mjs.map +1 -0
  65. package/lib/index.cjs +1474 -0
  66. package/lib/index.cjs.map +1 -0
  67. package/lib/index.mjs +33 -0
  68. package/lib/index.mjs.map +1 -0
  69. package/lib-yak/SlotFill.mjs +230 -0
  70. package/lib-yak/SlotFill.mjs.map +1 -0
  71. package/lib-yak/StartlibsProvider.mjs +62 -0
  72. package/lib-yak/StartlibsProvider.mjs.map +1 -0
  73. package/lib-yak/hocs/WithLazyResource.mjs +74 -0
  74. package/lib-yak/hocs/WithLazyResource.mjs.map +1 -0
  75. package/lib-yak/hocs/WithRef.mjs +20 -0
  76. package/lib-yak/hocs/WithRef.mjs.map +1 -0
  77. package/lib-yak/hocs/consumes.mjs +22 -0
  78. package/lib-yak/hocs/consumes.mjs.map +1 -0
  79. package/lib-yak/hocs/withDialogError.mjs +22 -0
  80. package/lib-yak/hocs/withDialogError.mjs.map +1 -0
  81. package/lib-yak/hocs/withGroupEvent.mjs +45 -0
  82. package/lib-yak/hocs/withGroupEvent.mjs.map +1 -0
  83. package/lib-yak/hooks/WithConstant.mjs +13 -0
  84. package/lib-yak/hooks/WithConstant.mjs.map +1 -0
  85. package/lib-yak/hooks/WithEffect.mjs +12 -0
  86. package/lib-yak/hooks/WithEffect.mjs.map +1 -0
  87. package/lib-yak/hooks/useAsyncEffect.mjs +14 -0
  88. package/lib-yak/hooks/useAsyncEffect.mjs.map +1 -0
  89. package/lib-yak/hooks/useCallState.mjs +21 -0
  90. package/lib-yak/hooks/useCallState.mjs.map +1 -0
  91. package/lib-yak/hooks/useCallbackStable.mjs +17 -0
  92. package/lib-yak/hooks/useCallbackStable.mjs.map +1 -0
  93. package/lib-yak/hooks/useConstant.mjs +21 -0
  94. package/lib-yak/hooks/useConstant.mjs.map +1 -0
  95. package/lib-yak/hooks/useConsumerCatalog.mjs +25 -0
  96. package/lib-yak/hooks/useConsumerCatalog.mjs.map +1 -0
  97. package/lib-yak/hooks/useEnsureRef.mjs +9 -0
  98. package/lib-yak/hooks/useEnsureRef.mjs.map +1 -0
  99. package/lib-yak/hooks/useForceUpdate.mjs +28 -0
  100. package/lib-yak/hooks/useForceUpdate.mjs.map +1 -0
  101. package/lib-yak/hooks/useIsUnmounted.mjs +15 -0
  102. package/lib-yak/hooks/useIsUnmounted.mjs.map +1 -0
  103. package/lib-yak/hooks/usePopupToggle.mjs +33 -0
  104. package/lib-yak/hooks/usePopupToggle.mjs.map +1 -0
  105. package/lib-yak/hooks/usePrevious.mjs +28 -0
  106. package/lib-yak/hooks/usePrevious.mjs.map +1 -0
  107. package/lib-yak/hooks/useRecycleFocus.mjs +34 -0
  108. package/lib-yak/hooks/useRecycleFocus.mjs.map +1 -0
  109. package/lib-yak/hooks/useRefMemo.mjs +13 -0
  110. package/lib-yak/hooks/useRefMemo.mjs.map +1 -0
  111. package/lib-yak/hooks/useRefState.mjs +29 -0
  112. package/lib-yak/hooks/useRefState.mjs.map +1 -0
  113. package/lib-yak/hooks/useSignal.mjs +271 -0
  114. package/lib-yak/hooks/useSignal.mjs.map +1 -0
  115. package/lib-yak/hooks/useTitle.mjs +17 -0
  116. package/lib-yak/hooks/useTitle.mjs.map +1 -0
  117. package/lib-yak/hooks/useToggle.mjs +152 -0
  118. package/lib-yak/hooks/useToggle.mjs.map +1 -0
  119. package/lib-yak/hooks/useUpdateEffect.mjs +15 -0
  120. package/lib-yak/hooks/useUpdateEffect.mjs.map +1 -0
  121. package/lib-yak/hooks/useUpdateOnResize.mjs +18 -0
  122. package/lib-yak/hooks/useUpdateOnResize.mjs.map +1 -0
  123. package/lib-yak/hooks/useWithTransition.mjs +18 -0
  124. package/lib-yak/hooks/useWithTransition.mjs.map +1 -0
  125. package/lib-yak/hooks/willUseLayers.mjs +55 -0
  126. package/lib-yak/hooks/willUseLayers.mjs.map +1 -0
  127. package/lib-yak/hooks/willUseSharedCallback.mjs +70 -0
  128. package/lib-yak/hooks/willUseSharedCallback.mjs.map +1 -0
  129. package/lib-yak/hooks/willUseSharedState.mjs +41 -0
  130. package/lib-yak/hooks/willUseSharedState.mjs.map +1 -0
  131. package/lib-yak/hooks/willUseSpreadState.mjs +119 -0
  132. package/lib-yak/hooks/willUseSpreadState.mjs.map +1 -0
  133. package/lib-yak/index.mjs +33 -0
  134. package/lib-yak/index.mjs.map +1 -0
  135. package/package.json +53 -30
  136. package/src/SlotFill.jsx +166 -0
  137. package/src/StartlibsProvider.jsx +62 -0
  138. package/src/hocs/WithLazyResource.jsx +32 -0
  139. package/src/hocs/WithRef.js +20 -0
  140. package/src/hocs/Wrapper.jsx +40 -0
  141. package/src/hocs/consumes.jsx +16 -0
  142. package/src/hocs/withDialogError.jsx +16 -0
  143. package/src/hocs/withGroupEvent.jsx +43 -0
  144. package/src/hooks/WithConstant.jsx +7 -0
  145. package/src/hooks/WithEffect.jsx +6 -0
  146. package/src/hooks/useAsyncEffect.jsx +11 -0
  147. package/src/hooks/useCallState.js +15 -0
  148. package/src/hooks/useCallbackStable.jsx +12 -0
  149. package/src/hooks/useConstant.js +20 -0
  150. package/src/hooks/useConsumerCatalog.jsx +21 -0
  151. package/src/hooks/useEnsureRef.js +6 -0
  152. package/src/hooks/useForceUpdate.jsx +16 -0
  153. package/src/hooks/useIsUnmounted.jsx +12 -0
  154. package/src/hooks/usePopupToggle.js +30 -0
  155. package/src/hooks/usePrevious.jsx +27 -0
  156. package/src/hooks/useRecycleFocus.jsx +26 -0
  157. package/src/hooks/useRefMemo.jsx +10 -0
  158. package/src/hooks/useRefState.js +26 -0
  159. package/src/hooks/useSignal.jsx +193 -0
  160. package/src/hooks/useTitle.jsx +12 -0
  161. package/src/hooks/useToggle.js +126 -0
  162. package/src/hooks/useUpdateEffect.js +14 -0
  163. package/src/hooks/useUpdateOnResize.jsx +14 -0
  164. package/src/hooks/useWithTransition.jsx +14 -0
  165. package/src/hooks/willUseLayers.jsx +42 -0
  166. package/src/hooks/willUseSharedCallback.jsx +60 -0
  167. package/src/hooks/willUseSharedState.jsx +34 -0
  168. package/src/hooks/willUseSpreadState.jsx +103 -0
  169. package/src/index.js +32 -0
  170. package/.babelrc +0 -27
  171. package/lib/index.js +0 -1921
  172. package/rollup.config.js +0 -53
  173. package/yarn-error.log +0 -3374
@@ -0,0 +1,74 @@
1
+ import React, { useReducer } from 'react';
2
+ import { ifUndefined } from '@startlibs/utils';
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
6
+ import _isArray from 'lodash/fp/isArray';
7
+
8
+ const _excluded = ["value", "fallback", "children", "forwardProps"],
9
+ _excluded2 = ["value", "wrap", "fallback", "children", "forwardProps"];
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ const addExtraProp = function (element, extra) {
13
+ let override = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
14
+ return /*#__PURE__*/React.cloneElement(element, override ? _objectSpread(_objectSpread({}, element.props), extra) : _objectSpread(_objectSpread({}, extra), element.props), element.props.children);
15
+ };
16
+ const WithLazyPlaceholder = _ref => {
17
+ let value = _ref.value,
18
+ fallback = _ref.fallback,
19
+ children = _ref.children,
20
+ _ref$forwardProps = _ref.forwardProps,
21
+ forwardProps = _ref$forwardProps === void 0 ? false : _ref$forwardProps,
22
+ props = _objectWithoutProperties(_ref, _excluded);
23
+ return /*#__PURE__*/React.createElement(React.Suspense, {
24
+ fallback: React.Children.map(children(fallback, {
25
+ isLoading: true
26
+ }), child => /*#__PURE__*/React.isValidElement(child) ? addExtraProp(child, {
27
+ isLoading: true
28
+ }, false) : child)
29
+ }, /*#__PURE__*/React.createElement(Load, {
30
+ value: value,
31
+ children: children,
32
+ forwardProps: forwardProps && props
33
+ }));
34
+ };
35
+ const WithLazyResource = _ref2 => {
36
+ let value = _ref2.value,
37
+ wrap = _ref2.wrap,
38
+ fallback = _ref2.fallback,
39
+ children = _ref2.children,
40
+ _ref2$forwardProps = _ref2.forwardProps,
41
+ forwardProps = _ref2$forwardProps === void 0 ? false : _ref2$forwardProps,
42
+ props = _objectWithoutProperties(_ref2, _excluded2);
43
+ return wrap || fallback !== undefined ? /*#__PURE__*/React.createElement(React.Suspense, {
44
+ fallback: ifUndefined(fallback, null)
45
+ }, /*#__PURE__*/React.createElement(Load, {
46
+ value: value,
47
+ forwardProps: forwardProps && props,
48
+ children: children
49
+ })) : /*#__PURE__*/React.createElement(Load, {
50
+ value: value,
51
+ children: children,
52
+ forwardProps: forwardProps && props
53
+ });
54
+ };
55
+ const Load = _ref3 => {
56
+ let value = _ref3.value,
57
+ children = _ref3.children,
58
+ forwardProps = _ref3.forwardProps;
59
+ const loaded = _isArray(value) ? value.forEach(v => v.promise()) || value.map(v => v.read()) : value.read();
60
+ const _useReducer = useReducer(s => s + 1, 0),
61
+ _useReducer2 = _slicedToArray(_useReducer, 2),
62
+ update = _useReducer2[1];
63
+ const refresh = () => Promise.all(_isArray(value) ? value.map(v => v.refresh().promise()) : [value.refresh().promise()]).then(update);
64
+ return forwardProps ? addExtraProp(children(loaded, {
65
+ refresh,
66
+ update
67
+ }), forwardProps) : children(loaded, {
68
+ refresh,
69
+ update
70
+ });
71
+ };
72
+
73
+ export { WithLazyPlaceholder, WithLazyResource };
74
+ //# sourceMappingURL=WithLazyResource.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithLazyResource.mjs","sources":["../../src/hocs/WithLazyResource.jsx"],"sourcesContent":["import React, {useReducer} from 'react'\nimport _ from 'lodash/fp'\nimport {ifUndefined} from '@startlibs/utils'\n\nconst addExtraProp = (element, extra, override = true) => React.cloneElement(\n element,\n override ? {...element.props,...extra} : {...extra,...element.props},\n element.props.children\n)\n\nexport const WithLazyPlaceholder = ({value, fallback, children, forwardProps = false,...props}) => {\n return <React.Suspense\n fallback={React.Children.map(children(fallback,{isLoading:true}), (child) => React.isValidElement(child) ? addExtraProp(child, {isLoading: true}, false) : child)}\n >\n <Load value={value} children={children} forwardProps={forwardProps && props}/>\n </React.Suspense>\n}\n\n\nexport const WithLazyResource = ({value, wrap,fallback,children,forwardProps = false,...props}) => {\n\n return (wrap || fallback !== undefined)\n ? <React.Suspense fallback={ifUndefined(fallback,null)}><Load value={value} forwardProps={forwardProps && props} children={children}/></React.Suspense>\n : <Load value={value} children={children} forwardProps={forwardProps && props}/>\n}\n\nconst Load = ({value,children,forwardProps}) => {\n const loaded = _.isArray(value) ? (value.forEach(v => v.promise()) || value.map(v => v.read())) : value.read()\n const [,update] = useReducer((s) => s+1, 0)\n const refresh = () => Promise.all(_.isArray(value) ? value.map(v => v.refresh().promise()) : [value.refresh().promise()]).then(update)\n return forwardProps ? addExtraProp(children(loaded,{refresh,update}),forwardProps) : children(loaded, {refresh,update})\n}"],"names":["addExtraProp","element","extra","override","arguments","length","undefined","React","cloneElement","_objectSpread","props","children","WithLazyPlaceholder","_ref","value","fallback","_ref$forwardProps","forwardProps","_objectWithoutProperties","_excluded","createElement","Suspense","Children","map","isLoading","child","isValidElement","Load","WithLazyResource","_ref2","wrap","_ref2$forwardProps","_excluded2","ifUndefined","_ref3","loaded","_isArray","forEach","v","promise","read","_useReducer","useReducer","s","_useReducer2","_slicedToArray","update","refresh","Promise","all","then"],"mappings":"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"}
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+
3
+ class WithRef extends React.Component {
4
+ constructor(props) {
5
+ super(props);
6
+ const total = props.length || props.children.length;
7
+ const refs = new Array(total);
8
+ for (var i = 0; i < total; i++) {
9
+ refs[i] = /*#__PURE__*/React.createRef();
10
+ }
11
+ this.createdRefs = refs;
12
+ }
13
+ render() {
14
+ const children = this.props.children;
15
+ return children(...this.createdRefs);
16
+ }
17
+ }
18
+
19
+ export { WithRef };
20
+ //# sourceMappingURL=WithRef.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithRef.mjs","sources":["../../src/hocs/WithRef.js"],"sourcesContent":["// @flow\nimport React from 'react'\n\nexport class WithRef extends React.Component {\n\n constructor(props) {\n super(props)\n const total = props.length || props.children.length\n const refs = new Array(total)\n for (var i = 0; i < total; i++) {\n refs[i] = React.createRef()\n }\n this.createdRefs = refs\n }\n\n render() {\n const {children} = this.props\n return children(...this.createdRefs)\n }\n}"],"names":["WithRef","React","Component","constructor","props","total","length","children","refs","Array","i","createRef","createdRefs","render"],"mappings":";;AAGO,MAAMA,OAAO,SAASC,KAAK,CAACC,SAAS,CAAC;EAE3CC,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,KAAK,CAAC;IACZ,MAAMC,KAAK,GAAGD,KAAK,CAACE,MAAM,IAAIF,KAAK,CAACG,QAAQ,CAACD,MAAM;IACnD,MAAME,IAAI,GAAG,IAAIC,KAAK,CAACJ,KAAK,CAAC;IAC7B,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,KAAK,EAAEK,CAAC,EAAE,EAAE;MAC9BF,IAAI,CAACE,CAAC,CAAC,gBAAGT,KAAK,CAACU,SAAS,EAAE;;IAE7B,IAAI,CAACC,WAAW,GAAGJ,IAAI;;EAGzBK,MAAMA,GAAG;IACP,MAAON,QAAQ,GAAI,IAAI,CAACH,KAAK,CAAtBG,QAAQ;IACf,OAAOA,QAAQ,CAAC,GAAG,IAAI,CAACK,WAAW,CAAC;;AAExC;;;;"}
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ const propsOrConsume = (prop, Consumer, childrenAsFunction) => prop ? childrenAsFunction(prop) : /*#__PURE__*/React.createElement(Consumer, null, childrenAsFunction);
8
+ const addConsumers = (Component, obj) => Object.entries(obj).reduce((acc, _ref) => {
9
+ let _ref2 = _slicedToArray(_ref, 2),
10
+ propKey = _ref2[0],
11
+ Consumer = _ref2[1];
12
+ return props => propsOrConsume(props[propKey], Consumer, v => acc(_objectSpread({
13
+ [propKey]: v
14
+ }, props)));
15
+ }, props => /*#__PURE__*/React.createElement(Component, props));
16
+ const consumes = obj => Component => {
17
+ const withConsumers = addConsumers(Component, obj);
18
+ return props => withConsumers(props);
19
+ };
20
+
21
+ export { consumes };
22
+ //# sourceMappingURL=consumes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumes.mjs","sources":["../../src/hocs/consumes.jsx"],"sourcesContent":["import React from 'react'\n\nconst propsOrConsume = (prop, Consumer,childrenAsFunction) => prop ? childrenAsFunction(prop) : <Consumer>{childrenAsFunction}</Consumer>\n\nconst addConsumers = (Component,obj) =>\n Object.entries(obj)\n .reduce(\n (acc, [propKey, Consumer]) => (props) =>\n propsOrConsume(props[propKey],Consumer,v => acc({[propKey]: v, ...props})),\n (props) => <Component {...props} />\n )\n\nexport const consumes = (obj) => (Component) => {\n const withConsumers = addConsumers(Component,obj)\n return (props) => withConsumers(props)\n}\n"],"names":["propsOrConsume","prop","Consumer","childrenAsFunction","React","createElement","addConsumers","Component","obj","Object","entries","reduce","acc","_ref","_ref2","_slicedToArray","propKey","props","v","_objectSpread","consumes","withConsumers"],"mappings":";;;;;;AAEA,MAAMA,cAAc,GAAGA,CAACC,IAAI,EAAEC,QAAQ,EAACC,kBAAkB,KAAKF,IAAI,GAAGE,kBAAkB,CAACF,IAAI,CAAC,gBAAGG,KAAA,CAAAC,aAAA,CAACH,QAAQ,QAAEC,kBAA6B,CAAC;AAEzI,MAAMG,YAAY,GAAGA,CAACC,SAAS,EAACC,GAAG,KACjCC,MAAM,CAACC,OAAO,CAACF,GAAG,CAAC,CAChBG,MAAM,CACL,CAACC,GAAG,EAAAC,IAAA;EAAA,IAAAC,KAAA,GAAAC,cAAA,CAAAF,IAAA;IAAGG,OAAO,GAAAF,KAAA;IAAEZ,QAAQ,GAAAY,KAAA;EAAA,OAAOG,KAAK,IAClCjB,cAAc,CAACiB,KAAK,CAACD,OAAO,CAAC,EAACd,QAAQ,EAACgB,CAAC,IAAIN,GAAG,CAAAO,aAAA;IAAE,CAACH,OAAO,GAAGE;KAAMD,KAAK,CAAC,CAAC,CAAC;AAAA,GAC3EA,KAAK,iBAAKb,KAAA,CAAAC,aAAA,CAACE,SAAS,EAAKU,KAAQ,CACpC,CAAC;MAEQG,QAAQ,GAAIZ,GAAG,IAAMD,SAAS,IAAK;EAC9C,MAAMc,aAAa,GAAGf,YAAY,CAACC,SAAS,EAACC,GAAG,CAAC;EACjD,OAAQS,KAAK,IAAKI,aAAa,CAACJ,KAAK,CAAC;AACxC;;;;"}
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import _extends from '@babel/runtime/helpers/extends';
3
+
4
+ const withDialogError = Dialog => {
5
+ const ErrorBoundedComponent = /*#__PURE__*/React.forwardRef((props, ref) => {
6
+ return /*#__PURE__*/React.createElement(Dialog, _extends({
7
+ ref: ref
8
+ }, props));
9
+
10
+ // const ErrorBoundary = __internals('ErrorBoundary')
11
+ /*return (
12
+ <ErrorBoundary Error={props.Error || __internals('DialogError')} closeDialog={props.closeDialog}>
13
+ <Dialog {...props}/>
14
+ </ErrorBoundary>
15
+ )*/
16
+ });
17
+ // ErrorBoundedComponent.contextTypes = {startlibs:()=>null}
18
+ return ErrorBoundedComponent;
19
+ };
20
+
21
+ export { withDialogError };
22
+ //# sourceMappingURL=withDialogError.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withDialogError.mjs","sources":["../../src/hocs/withDialogError.jsx"],"sourcesContent":["import React from 'react'\n\nexport const withDialogError = (Dialog) => {\n const ErrorBoundedComponent = React.forwardRef((props,ref) => {\n return <Dialog ref={ref} {...props}/>\n\n // const ErrorBoundary = __internals('ErrorBoundary')\n /*return (\n <ErrorBoundary Error={props.Error || __internals('DialogError')} closeDialog={props.closeDialog}>\n <Dialog {...props}/>\n </ErrorBoundary>\n )*/\n })\n // ErrorBoundedComponent.contextTypes = {startlibs:()=>null}\n return ErrorBoundedComponent\n}"],"names":["withDialogError","Dialog","ErrorBoundedComponent","React","forwardRef","props","ref","createElement","_extends"],"mappings":";;;MAEaA,eAAe,GAAIC,MAAM,IAAK;EACzC,MAAMC,qBAAqB,gBAAGC,KAAK,CAACC,UAAU,CAAC,CAACC,KAAK,EAACC,GAAG,KAAK;IAC5D,oBAAOH,KAAA,CAAAI,aAAA,CAACN,MAAM,EAAAO,QAAA;MAACF,GAAG,EAAEA;OAASD,KAAK,CAAE,CAAC;;;;AAIzC;AACA;AACA;AACA;GACG,CAAC;;EAEF,OAAOH,qBAAqB;AAC9B;;;;"}
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import _extends from '@babel/runtime/helpers/extends';
3
+ import mitt from 'mitt';
4
+
5
+ const GroupEventFactory = () => {
6
+ let emitter = mitt();
7
+ class WithGroupEvent extends React.Component {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.events = {};
11
+ this.processEvent = (type, event) => {
12
+ (this.events[type] || []).forEach(c => c(event));
13
+ };
14
+ this.groupEventProps = {
15
+ on: (type, callback) => {
16
+ this.events[type] = (this.events[type] || []).concat(callback);
17
+ },
18
+ off: (type, callback) => {
19
+ this.events[type] = (this.events[type] || []).filter(e => e !== callback);
20
+ },
21
+ emit: emitter.emit
22
+ };
23
+ }
24
+ componentDidMount() {
25
+ emitter.on('*', this.processEvent);
26
+ }
27
+ componentWillUnmount() {
28
+ emitter.off('*', this.processEvent);
29
+ }
30
+ render() {
31
+ return this.props.children(this.groupEventProps);
32
+ }
33
+ }
34
+ return WithGroupEvent;
35
+ };
36
+ const withGroupEvent = Component => {
37
+ const WithGroupEvent = GroupEventFactory();
38
+ return /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(WithGroupEvent, null, groupEvent => /*#__PURE__*/React.createElement(Component, _extends({}, props, {
39
+ ref: ref,
40
+ groupEvent: groupEvent
41
+ }))));
42
+ };
43
+
44
+ export { GroupEventFactory, withGroupEvent };
45
+ //# sourceMappingURL=withGroupEvent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withGroupEvent.mjs","sources":["../../src/hocs/withGroupEvent.jsx"],"sourcesContent":["import React from 'react'\nimport mitt from 'mitt'\n\nexport const GroupEventFactory = () => {\n let emitter = mitt()\n\n class WithGroupEvent extends React.Component {\n componentDidMount() {\n emitter.on('*', this.processEvent)\n }\n\n componentWillUnmount() {\n emitter.off('*',this.processEvent)\n }\n\n events = {}\n\n processEvent = (type, event) => {\n (this.events[type] || []).forEach(c => c(event))\n }\n\n groupEventProps = {\n on: (type,callback) => {\n this.events[type] = (this.events[type] || []).concat(callback)\n },\n off: (type,callback) => {\n this.events[type] = (this.events[type] || []).filter(e=>e!==callback)\n },\n emit: emitter.emit\n }\n\n render() {\n return this.props.children(this.groupEventProps)\n }\n }\n return WithGroupEvent\n}\n\nexport const withGroupEvent = (Component) => {\n const WithGroupEvent = GroupEventFactory()\n return React.forwardRef((props,ref) => <WithGroupEvent>{(groupEvent) => <Component {...props} ref={ref} groupEvent={groupEvent}/>}</WithGroupEvent>)\n}\n\n"],"names":["GroupEventFactory","emitter","mitt","WithGroupEvent","React","Component","constructor","arguments","events","processEvent","type","event","forEach","c","groupEventProps","on","callback","concat","off","filter","e","emit","componentDidMount","componentWillUnmount","render","props","children","withGroupEvent","forwardRef","ref","createElement","groupEvent","_extends"],"mappings":";;;;MAGaA,iBAAiB,GAAGA,MAAM;EACrC,IAAIC,OAAO,GAAGC,IAAI,EAAE;EAEpB,MAAMC,cAAc,SAASC,KAAK,CAACC,SAAS,CAAC;IAAAC;MAAA,SAAAC,SAAA;MAAA,KAS3CC,MAAM,GAAG,EAAE;MAAA,KAEXC,YAAY,GAAG,CAACC,IAAI,EAAEC,KAAK,KAAK;QAC9B,CAAC,IAAI,CAACH,MAAM,CAACE,IAAI,CAAC,IAAI,EAAE,EAAEE,OAAO,CAACC,CAAC,IAAIA,CAAC,CAACF,KAAK,CAAC,CAAC;OACjD;MAAA,KAEDG,eAAe,GAAG;QAChBC,EAAE,EAAEA,CAACL,IAAI,EAACM,QAAQ,KAAK;UACrB,IAAI,CAACR,MAAM,CAACE,IAAI,CAAC,GAAG,CAAC,IAAI,CAACF,MAAM,CAACE,IAAI,CAAC,IAAI,EAAE,EAAEO,MAAM,CAACD,QAAQ,CAAC;SAC/D;QACDE,GAAG,EAAEA,CAACR,IAAI,EAACM,QAAQ,KAAK;UACtB,IAAI,CAACR,MAAM,CAACE,IAAI,CAAC,GAAG,CAAC,IAAI,CAACF,MAAM,CAACE,IAAI,CAAC,IAAI,EAAE,EAAES,MAAM,CAACC,CAAC,IAAEA,CAAC,KAAGJ,QAAQ,CAAC;SACtE;QACDK,IAAI,EAAEpB,OAAO,CAACoB;OACf;;IAtBDC,iBAAiBA,GAAG;MAClBrB,OAAO,CAACc,EAAE,CAAC,GAAG,EAAE,IAAI,CAACN,YAAY,CAAC;;IAGpCc,oBAAoBA,GAAG;MACrBtB,OAAO,CAACiB,GAAG,CAAC,GAAG,EAAC,IAAI,CAACT,YAAY,CAAC;;IAmBpCe,MAAMA,GAAG;MACP,OAAO,IAAI,CAACC,KAAK,CAACC,QAAQ,CAAC,IAAI,CAACZ,eAAe,CAAC;;;EAGpD,OAAOX,cAAc;AACvB;MAEawB,cAAc,GAAItB,SAAS,IAAK;EAC3C,MAAMF,cAAc,GAAGH,iBAAiB,EAAE;EAC1C,oBAAOI,KAAK,CAACwB,UAAU,CAAC,CAACH,KAAK,EAACI,GAAG,kBAAKzB,KAAA,CAAA0B,aAAA,CAAC3B,cAAc,QAAG4B,UAAU,iBAAK3B,KAAA,CAAA0B,aAAA,CAACzB,SAAS,EAAA2B,QAAA,KAAKP,KAAK;IAAEI,GAAG,EAAEA,GAAI;IAACE,UAAU,EAAEA;IAAY,CAAkB,CAAC,CAAC;AACtJ;;;;"}
@@ -0,0 +1,13 @@
1
+ import 'react';
2
+ import { useLazyConstant } from './useConstant.mjs';
3
+
4
+ const WithConstant = _ref => {
5
+ let _ref$inputs = _ref.inputs,
6
+ value = _ref.value,
7
+ children = _ref.children;
8
+ const constant = useLazyConstant(value);
9
+ return children(constant);
10
+ };
11
+
12
+ export { WithConstant };
13
+ //# sourceMappingURL=WithConstant.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithConstant.mjs","sources":["../../src/hooks/WithConstant.jsx"],"sourcesContent":["import React from 'react'\nimport {useLazyConstant} from './useConstant'\n\nexport const WithConstant = ({inputs=[],value,children}) => {\n const constant = useLazyConstant(value,inputs)\n return children(constant)\n}"],"names":["WithConstant","_ref","_ref$inputs","inputs","value","children","constant","useLazyConstant"],"mappings":";;;MAGaA,YAAY,GAAGC,IAAA,IAAgC;MAAAC,WAAA,GAAAD,IAAA,CAA9BE,MAAM;IAAIC,KAAK,GAAAH,IAAA,CAALG,KAAK;IAACC,QAAQ,GAAAJ,IAAA,CAARI;EAC5C,MAAMC,QAAQ,GAAGC,eAAe,CAACH,KAAY,CAAC;EAC9C,OAAOC,QAAQ,CAACC,QAAQ,CAAC;AAC3B;;;;"}
@@ -0,0 +1,12 @@
1
+ import { useEffect } from 'react';
2
+
3
+ const WithEffect = _ref => {
4
+ let _ref$inputs = _ref.inputs,
5
+ inputs = _ref$inputs === void 0 ? [] : _ref$inputs,
6
+ children = _ref.children;
7
+ useEffect(children, inputs);
8
+ return null;
9
+ };
10
+
11
+ export { WithEffect };
12
+ //# sourceMappingURL=WithEffect.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithEffect.mjs","sources":["../../src/hooks/WithEffect.jsx"],"sourcesContent":["import React, {useEffect} from 'react'\n\nexport const WithEffect = ({inputs=[],children}) => {\n useEffect(children,inputs)\n return null\n}"],"names":["WithEffect","_ref","_ref$inputs","inputs","children","useEffect"],"mappings":";;MAEaA,UAAU,GAAGC,IAAA,IAA0B;EAAA,IAAAC,WAAA,GAAAD,IAAA,CAAxBE,MAAM;IAANA,MAAM,GAAAD,WAAA,cAAC,EAAE,GAAAA,WAAA;IAACE,QAAQ,GAAAH,IAAA,CAARG,QAAQ;EAC5CC,SAAS,CAACD,QAAQ,EAACD,MAAM,CAAC;EAC1B,OAAO,IAAI;AACb;;;;"}
@@ -0,0 +1,14 @@
1
+ import { useEffect } from 'react';
2
+ import { callIfFunction } from '@startlibs/utils';
3
+
4
+ const useAsyncEffect = (fn, args) => {
5
+ useEffect(() => {
6
+ const result = fn();
7
+ return () => {
8
+ result.then(end => callIfFunction(end));
9
+ };
10
+ }, args);
11
+ };
12
+
13
+ export { useAsyncEffect };
14
+ //# sourceMappingURL=useAsyncEffect.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAsyncEffect.mjs","sources":["../../src/hooks/useAsyncEffect.jsx"],"sourcesContent":["import React, {useEffect} from 'react'\nimport {callIfFunction} from '@startlibs/utils'\n\nexport const useAsyncEffect = (fn,args) => {\n useEffect(() => {\n const result = fn()\n return () => {\n result.then(end => callIfFunction(end))\n }\n },args)\n}"],"names":["useAsyncEffect","fn","args","useEffect","result","then","end","callIfFunction"],"mappings":";;;MAGaA,cAAc,GAAGA,CAACC,EAAE,EAACC,IAAI,KAAK;EACzCC,SAAS,CAAC,MAAM;IACd,MAAMC,MAAM,GAAGH,EAAE,EAAE;IACnB,OAAO,MAAM;MACXG,MAAM,CAACC,IAAI,CAACC,GAAG,IAAIC,cAAc,CAACD,GAAG,CAAC,CAAC;KACxC;GACF,EAACJ,IAAI,CAAC;AACT;;;;"}
@@ -0,0 +1,21 @@
1
+ import { useState, useMemo } from 'react';
2
+ import '@startlibs/utils';
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+
5
+ const useCallState = (defaultValue, setCallback) => {
6
+ const _useState = useState(defaultValue),
7
+ _useState2 = _slicedToArray(_useState, 2),
8
+ val = _useState2[0],
9
+ setValue = _useState2[1];
10
+ return useMemo(() => {
11
+ const get = () => val;
12
+ return {
13
+ get,
14
+ val,
15
+ set: setValue
16
+ };
17
+ }, [val]);
18
+ };
19
+
20
+ export { useCallState };
21
+ //# sourceMappingURL=useCallState.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCallState.mjs","sources":["../../src/hooks/useCallState.js"],"sourcesContent":["import React, {useMemo, useState} from 'react'\nimport {_s} from '@startlibs/utils'\n\nconst isPath = (path) => typeof path === 'string' || typeof path === 'number' || Array.isArray(path)\n\nconst getter = (value) => path => isPath(path) ? _s.get(path, value) : value\n\nexport const useCallState = (defaultValue, setCallback) => {\n const [val, setValue] = useState(defaultValue)\n\n return useMemo(() => {\n const get = () => val\n return {get, val, set: setValue}\n }, [val])\n}\n"],"names":["useCallState","defaultValue","setCallback","_useState","useState","_useState2","_slicedToArray","val","setValue","useMemo","get","set"],"mappings":";;;;MAOaA,YAAY,GAAGA,CAACC,YAAY,EAAEC,WAAW,KAAK;EACzD,MAAAC,SAAA,GAAwBC,QAAQ,CAACH,YAAY,CAAC;IAAAI,UAAA,GAAAC,cAAA,CAAAH,SAAA;IAAvCI,GAAG,GAAAF,UAAA;IAAEG,QAAQ,GAAAH,UAAA;EAEpB,OAAOI,OAAO,CAAC,MAAM;IACnB,MAAMC,GAAG,GAAGA,MAAMH,GAAG;IACrB,OAAO;MAACG,GAAG;MAAEH,GAAG;MAAEI,GAAG,EAAEH;KAAS;GACjC,EAAE,CAACD,GAAG,CAAC,CAAC;AACX;;;;"}
@@ -0,0 +1,17 @@
1
+ import React, { useInsertionEffect } from 'react';
2
+
3
+ const useCallbackStable = fn => {
4
+ const ref = React.useRef([fn, function () {
5
+ return ref[0](...arguments);
6
+ }]).current;
7
+ // Per Dan Abramov: useInsertionEffect executes marginally closer to the
8
+ // correct timing for ref synchronization than useLayoutEffect on React 18.
9
+ // See: https://github.com/facebook/react/pull/25881#issuecomment-1356244360
10
+ useInsertionEffect(() => {
11
+ ref[0] = fn;
12
+ });
13
+ return ref[1];
14
+ };
15
+
16
+ export { useCallbackStable };
17
+ //# sourceMappingURL=useCallbackStable.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCallbackStable.mjs","sources":["../../src/hooks/useCallbackStable.jsx"],"sourcesContent":["import React, {useInsertionEffect} from 'react'\n\nexport const useCallbackStable = (fn) => {\n const ref = React.useRef([fn, (...args) => ref[0](...args)]).current;\n // Per Dan Abramov: useInsertionEffect executes marginally closer to the\n // correct timing for ref synchronization than useLayoutEffect on React 18.\n // See: https://github.com/facebook/react/pull/25881#issuecomment-1356244360\n useInsertionEffect(() => {\n ref[0] = fn;\n });\n return ref[1];\n}"],"names":["useCallbackStable","fn","ref","React","useRef","arguments","current","useInsertionEffect"],"mappings":";;MAEaA,iBAAiB,GAAIC,EAAE,IAAK;EACvC,MAAMC,GAAG,GAAGC,KAAK,CAACC,MAAM,CAAC,CAACH,EAAE,EAAE;IAAA,OAAaC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAAG,SAAO,CAAC;IAAC,CAAC,CAACC,OAAO;;;;EAIpEC,kBAAkB,CAAC,MAAM;IACvBL,GAAG,CAAC,CAAC,CAAC,GAAGD,EAAE;GACZ,CAAC;EACF,OAAOC,GAAG,CAAC,CAAC,CAAC;AACf;;;;"}
@@ -0,0 +1,21 @@
1
+ import { useRef } from 'react';
2
+ import { callIfFunction } from '@startlibs/utils';
3
+
4
+ const not_defined = {};
5
+ const useConstant = value => {
6
+ const ref = useRef(not_defined);
7
+ if (ref.current === not_defined) {
8
+ ref.current = value;
9
+ }
10
+ return ref.current;
11
+ };
12
+ const useLazyConstant = value => {
13
+ const ref = useRef(not_defined);
14
+ if (ref.current === not_defined) {
15
+ ref.current = callIfFunction(value);
16
+ }
17
+ return ref.current;
18
+ };
19
+
20
+ export { useConstant, useLazyConstant };
21
+ //# sourceMappingURL=useConstant.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConstant.mjs","sources":["../../src/hooks/useConstant.js"],"sourcesContent":["import React, {useRef} from 'react'\nimport {callIfFunction} from '@startlibs/utils'\n\nconst not_defined = {}\n\nexport const useConstant = (value) => {\n const ref = useRef(not_defined)\n if (ref.current === not_defined) {\n ref.current = value\n }\n return ref.current\n}\n\nexport const useLazyConstant= (value) => {\n const ref = useRef(not_defined)\n if (ref.current === not_defined) {\n ref.current = callIfFunction(value)\n }\n return ref.current\n}\n"],"names":["not_defined","useConstant","value","ref","useRef","current","useLazyConstant","callIfFunction"],"mappings":";;;AAGA,MAAMA,WAAW,GAAG,EAAE;MAETC,WAAW,GAAIC,KAAK,IAAK;EACpC,MAAMC,GAAG,GAAGC,MAAM,CAACJ,WAAW,CAAC;EAC/B,IAAIG,GAAG,CAACE,OAAO,KAAKL,WAAW,EAAE;IAC/BG,GAAG,CAACE,OAAO,GAAGH,KAAK;;EAErB,OAAOC,GAAG,CAACE,OAAO;AACpB;MAEaC,eAAe,GAAGJ,KAAK,IAAK;EACvC,MAAMC,GAAG,GAAGC,MAAM,CAACJ,WAAW,CAAC;EAC/B,IAAIG,GAAG,CAACE,OAAO,KAAKL,WAAW,EAAE;IAC/BG,GAAG,CAACE,OAAO,GAAGE,cAAc,CAACL,KAAK,CAAC;;EAErC,OAAOC,GAAG,CAACE,OAAO;AACpB;;;;"}
@@ -0,0 +1,25 @@
1
+ import { useMemo, useEffect } from 'react';
2
+ import { callMany } from '@startlibs/utils';
3
+ import { useRefState } from './useRefState.mjs';
4
+
5
+ const useConsumerCatalog = (mountCallback, unmountCallback) => {
6
+ const elements = useRefState([]);
7
+ const register = callMany(element => elements.set(elements => elements.concat([element])), mountCallback);
8
+ const unregister = callMany(element => elements.set(elements => elements.filter(_ => _ !== element)), unmountCallback);
9
+ const manager = useMemo(() => ({
10
+ register,
11
+ unregister
12
+ }), []);
13
+ return [elements.get, manager];
14
+ };
15
+ const useCatalogManager = (_ref, ref) => {
16
+ let register = _ref.register,
17
+ unregister = _ref.unregister;
18
+ useEffect(() => {
19
+ register(ref);
20
+ return () => unregister(ref);
21
+ }, [ref]);
22
+ };
23
+
24
+ export { useCatalogManager, useConsumerCatalog };
25
+ //# sourceMappingURL=useConsumerCatalog.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConsumerCatalog.mjs","sources":["../../src/hooks/useConsumerCatalog.jsx"],"sourcesContent":["import React, {useEffect, useMemo} from 'react'\nimport {callMany} from '@startlibs/utils'\nimport {useRefState} from './useRefState'\n\nexport const useConsumerCatalog = (mountCallback,unmountCallback) => {\n const elements = useRefState([])\n\n const register = callMany((element) => elements.set((elements) => elements.concat([element])), mountCallback)\n const unregister = callMany((element) => elements.set((elements) => elements.filter(_ => _ !== element)), unmountCallback)\n\n const manager = useMemo(()=> ({register,unregister}), [])\n\n return [elements.get,manager]\n}\n\nexport const useCatalogManager = ({register,unregister},ref) => {\n useEffect(() => {\n register(ref)\n return () => unregister(ref)\n },[ref])\n}"],"names":["useConsumerCatalog","mountCallback","unmountCallback","elements","useRefState","register","callMany","element","set","concat","unregister","filter","_","manager","useMemo","get","useCatalogManager","_ref","ref","useEffect"],"mappings":";;;;MAIaA,kBAAkB,GAAGA,CAACC,aAAa,EAACC,eAAe,KAAK;EACnE,MAAMC,QAAQ,GAAGC,WAAW,CAAC,EAAE,CAAC;EAEhC,MAAMC,QAAQ,GAAGC,QAAQ,CAAEC,OAAO,IAAKJ,QAAQ,CAACK,GAAG,CAAEL,QAAQ,IAAKA,QAAQ,CAACM,MAAM,CAAC,CAACF,OAAO,CAAC,CAAC,CAAC,EAAEN,aAAa,CAAC;EAC7G,MAAMS,UAAU,GAAGJ,QAAQ,CAAEC,OAAO,IAAMJ,QAAQ,CAACK,GAAG,CAAEL,QAAQ,IAAKA,QAAQ,CAACQ,MAAM,CAACC,CAAC,IAAIA,CAAC,KAAKL,OAAO,CAAC,CAAC,EAAEL,eAAe,CAAC;EAE3H,MAAMW,OAAO,GAAGC,OAAO,CAAC,OAAM;IAACT,QAAQ;IAACK;GAAW,CAAC,EAAE,EAAE,CAAC;EAEzD,OAAO,CAACP,QAAQ,CAACY,GAAG,EAACF,OAAO,CAAC;AAC/B;MAEaG,iBAAiB,GAAGA,CAAAC,IAAA,EAAuBC,GAAG,KAAK;EAAA,IAA7Bb,QAAQ,GAAAY,IAAA,CAARZ,QAAQ;IAACK,UAAU,GAAAO,IAAA,CAAVP,UAAU;EACpDS,SAAS,CAAC,MAAM;IACdd,QAAQ,CAACa,GAAG,CAAC;IACb,OAAO,MAAMR,UAAU,CAACQ,GAAG,CAAC;GAC7B,EAAC,CAACA,GAAG,CAAC,CAAC;AACV;;;;"}
@@ -0,0 +1,9 @@
1
+ import { useRef } from 'react';
2
+
3
+ const useEnsureRef = forwardedRef => {
4
+ const ref = useRef();
5
+ return forwardedRef || ref;
6
+ };
7
+
8
+ export { useEnsureRef };
9
+ //# sourceMappingURL=useEnsureRef.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEnsureRef.mjs","sources":["../../src/hooks/useEnsureRef.js"],"sourcesContent":["import React, {useRef} from 'react'\n\nexport const useEnsureRef = (forwardedRef) => {\n const ref = useRef()\n return forwardedRef || ref\n}\n"],"names":["useEnsureRef","forwardedRef","ref","useRef"],"mappings":";;MAEaA,YAAY,GAAIC,YAAY,IAAK;EAC5C,MAAMC,GAAG,GAAGC,MAAM,EAAE;EACpB,OAAOF,YAAY,IAAIC,GAAG;AAC5B;;;;"}
@@ -0,0 +1,28 @@
1
+ import { useState } from 'react';
2
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
+ import { willUseSharedState } from './willUseSharedState.mjs';
4
+
5
+ const useForceUpdate = () => {
6
+ const _useState = useState(0),
7
+ _useState2 = _slicedToArray(_useState, 2),
8
+ value = _useState2[0],
9
+ setValue = _useState2[1]; // integer state
10
+ return () => setValue(value => value + 1); // update the state to force render
11
+ };
12
+ const willUseForceUpdate = () => {
13
+ const _willUseSharedState = willUseSharedState(),
14
+ _willUseSharedState2 = _slicedToArray(_willUseSharedState, 3),
15
+ useValue = _willUseSharedState2[0],
16
+ set = _willUseSharedState2[2];
17
+ const useForceUpdate = () => {
18
+ const _useValue = useValue(0),
19
+ _useValue2 = _slicedToArray(_useValue, 2),
20
+ v = _useValue2[0],
21
+ setV = _useValue2[1];
22
+ return () => setV(value => value + 1);
23
+ };
24
+ return [useForceUpdate, () => set(value => value + 1)];
25
+ };
26
+
27
+ export { useForceUpdate, willUseForceUpdate };
28
+ //# sourceMappingURL=useForceUpdate.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useForceUpdate.mjs","sources":["../../src/hooks/useForceUpdate.jsx"],"sourcesContent":["import {useState} from 'react'\nimport {willUseSharedState} from './willUseSharedState'\n\nexport const useForceUpdate = () => {\n const [value, setValue] = useState(0); // integer state\n return () => setValue(value => value + 1); // update the state to force render\n}\n\nexport const willUseForceUpdate = () => {\n const [useValue,,set] = willUseSharedState()\n const useForceUpdate = () => {\n const [v,setV] = useValue(0)\n return () => setV(value => value + 1)\n }\n return [useForceUpdate,() => set(value => value + 1)]\n}"],"names":["useForceUpdate","_useState","useState","_useState2","_slicedToArray","value","setValue","willUseForceUpdate","_willUseSharedState","willUseSharedState","_willUseSharedState2","useValue","set","_useValue","_useValue2","v","setV"],"mappings":";;;;MAGaA,cAAc,GAAGA,MAAM;EAClC,MAAAC,SAAA,GAA0BC,QAAQ,CAAC,CAAC,CAAC;IAAAC,UAAA,GAAAC,cAAA,CAAAH,SAAA;IAA9BI,KAAK,GAAAF,UAAA;IAAEG,QAAQ,GAAAH,UAAA,IAAgB;EACtC,OAAO,MAAMG,QAAQ,CAACD,KAAK,IAAIA,KAAK,GAAG,CAAC,CAAC,CAAC;AAC5C;MAEaE,kBAAkB,GAAGA,MAAM;EACtC,MAAAC,mBAAA,GAAwBC,kBAAkB,EAAE;IAAAC,oBAAA,GAAAN,cAAA,CAAAI,mBAAA;IAArCG,QAAQ,GAAAD,oBAAA;IAAEE,GAAG,GAAAF,oBAAA;EACpB,MAAMV,cAAc,GAAGA,MAAM;IAC3B,MAAAa,SAAA,GAAiBF,QAAQ,CAAC,CAAC,CAAC;MAAAG,UAAA,GAAAV,cAAA,CAAAS,SAAA;MAArBE,CAAC,GAAAD,UAAA;MAACE,IAAI,GAAAF,UAAA;IACb,OAAO,MAAME,IAAI,CAACX,KAAK,IAAIA,KAAK,GAAG,CAAC,CAAC;GACtC;EACD,OAAO,CAACL,cAAc,EAAC,MAAMY,GAAG,CAACP,KAAK,IAAIA,KAAK,GAAG,CAAC,CAAC,CAAC;AACvD;;;;"}
@@ -0,0 +1,15 @@
1
+ import { useRef, useEffect } from 'react';
2
+
3
+ const useIsUnmounted = () => {
4
+ const unmounted = useRef(false);
5
+ useEffect(() => {
6
+ unmounted.current = false;
7
+ return () => {
8
+ unmounted.current = true;
9
+ };
10
+ }, []);
11
+ return () => unmounted.current;
12
+ };
13
+
14
+ export { useIsUnmounted };
15
+ //# sourceMappingURL=useIsUnmounted.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsUnmounted.mjs","sources":["../../src/hooks/useIsUnmounted.jsx"],"sourcesContent":["import {useEffect, useRef} from 'react'\n\nexport const useIsUnmounted = () => {\n const unmounted = useRef(false)\n\n useEffect(() => {\n unmounted.current = false\n return () => { unmounted.current = true }\n }, [])\n\n return () => unmounted.current\n}"],"names":["useIsUnmounted","unmounted","useRef","useEffect","current"],"mappings":";;MAEaA,cAAc,GAAGA,MAAM;EAClC,MAAMC,SAAS,GAAGC,MAAM,CAAC,KAAK,CAAC;EAE/BC,SAAS,CAAC,MAAM;IACdF,SAAS,CAACG,OAAO,GAAG,KAAK;IACzB,OAAO,MAAM;MAAEH,SAAS,CAACG,OAAO,GAAG,IAAI;KAAE;GAC1C,EAAE,EAAE,CAAC;EAEN,OAAO,MAAMH,SAAS,CAACG,OAAO;AAChC;;;;"}
@@ -0,0 +1,33 @@
1
+ import 'react';
2
+ import { callIfFunction } from '@startlibs/utils';
3
+ import { useToggle } from './useToggle.mjs';
4
+
5
+ let prevOpenToggleClose = () => {};
6
+ let sameTick = false;
7
+ const clearPopups = () => {
8
+ if (!sameTick) {
9
+ prevOpenToggleClose();
10
+ prevOpenToggleClose = () => {};
11
+ }
12
+ };
13
+ const usePopupToggle = (startWith, callback) => {
14
+ const toggle = useToggle(startWith, (v, prev) => {
15
+ const result = callIfFunction(callback, v, prev);
16
+ if (result === false) {
17
+ return false;
18
+ }
19
+ if (v !== false && prevOpenToggleClose !== toggle.close) {
20
+ prevOpenToggleClose();
21
+ prevOpenToggleClose = toggle.close;
22
+ sameTick = true;
23
+ window.setTimeout(() => sameTick = false, 1);
24
+ }
25
+ if (v === false) {
26
+ prevOpenToggleClose = () => {};
27
+ }
28
+ });
29
+ return toggle;
30
+ };
31
+
32
+ export { clearPopups, usePopupToggle };
33
+ //# sourceMappingURL=usePopupToggle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePopupToggle.mjs","sources":["../../src/hooks/usePopupToggle.js"],"sourcesContent":["import React from 'react'\nimport {useToggle} from './useToggle'\nimport {callIfFunction} from '@startlibs/utils'\n\nlet prevOpenToggleClose = () => {}\nlet sameTick = false\n\nexport const clearPopups = () => {\n if (!sameTick) {\n prevOpenToggleClose()\n prevOpenToggleClose = () => {}\n }\n}\n\nexport const usePopupToggle = (startWith,callback) => {\n const toggle = useToggle(startWith,(v,prev) => {\n const result = callIfFunction(callback,v,prev)\n if (result === false) { return false}\n if (v !== false && prevOpenToggleClose !== toggle.close) {\n prevOpenToggleClose()\n prevOpenToggleClose = toggle.close\n sameTick = true\n window.setTimeout(()=>sameTick = false, 1)\n }\n if (v === false) {\n prevOpenToggleClose = () => {}\n }\n })\n return toggle\n}"],"names":["prevOpenToggleClose","sameTick","clearPopups","usePopupToggle","startWith","callback","toggle","useToggle","v","prev","result","callIfFunction","close","window","setTimeout"],"mappings":";;;;AAIA,IAAIA,mBAAmB,GAAGA,MAAM,EAAE;AAClC,IAAIC,QAAQ,GAAG,KAAK;MAEPC,WAAW,GAAGA,MAAM;EAC/B,IAAI,CAACD,QAAQ,EAAE;IACbD,mBAAmB,EAAE;IACrBA,mBAAmB,GAAGA,MAAM,EAAE;;AAElC;MAEaG,cAAc,GAAGA,CAACC,SAAS,EAACC,QAAQ,KAAK;EACpD,MAAMC,MAAM,GAAGC,SAAS,CAACH,SAAS,EAAC,CAACI,CAAC,EAACC,IAAI,KAAK;IAC7C,MAAMC,MAAM,GAAGC,cAAc,CAACN,QAAQ,EAACG,CAAC,EAACC,IAAI,CAAC;IAC9C,IAAIC,MAAM,KAAK,KAAK,EAAE;MAAE,OAAO,KAAK;;IACpC,IAAIF,CAAC,KAAK,KAAK,IAAIR,mBAAmB,KAAKM,MAAM,CAACM,KAAK,EAAE;MACvDZ,mBAAmB,EAAE;MACrBA,mBAAmB,GAAGM,MAAM,CAACM,KAAK;MAClCX,QAAQ,GAAG,IAAI;MACfY,MAAM,CAACC,UAAU,CAAC,MAAIb,QAAQ,GAAG,KAAK,EAAE,CAAC,CAAC;;IAE5C,IAAIO,CAAC,KAAK,KAAK,EAAE;MACfR,mBAAmB,GAAGA,MAAM,EAAE;;GAEjC,CAAC;EACF,OAAOM,MAAM;AACf;;;;"}
@@ -0,0 +1,28 @@
1
+ import { useRef, useEffect } from 'react';
2
+
3
+ function usePrevious(value, initialValue) {
4
+ const ref = useRef(initialValue);
5
+ useEffect(() => {
6
+ ref.current = value;
7
+ });
8
+ return ref.current;
9
+ }
10
+ function usePreviousUnique(value, initialValue) {
11
+ const ref = useRef(initialValue);
12
+ useEffect(() => {
13
+ if (value !== ref.current) {
14
+ ref.current = value;
15
+ }
16
+ });
17
+ return ref.current;
18
+ }
19
+ function usePreviousForEffect(value, initialValue) {
20
+ const ref = useRef(initialValue);
21
+ useEffect(() => () => {
22
+ ref.current = value;
23
+ }, [value]);
24
+ return ref.current;
25
+ }
26
+
27
+ export { usePrevious, usePreviousForEffect, usePreviousUnique };
28
+ //# sourceMappingURL=usePrevious.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrevious.mjs","sources":["../../src/hooks/usePrevious.jsx"],"sourcesContent":["import {useEffect, useRef} from 'react'\n\nexport function usePrevious(value,initialValue) {\n const ref = useRef(initialValue);\n useEffect(() => {\n ref.current = value;\n });\n return ref.current;\n}\n\nexport function usePreviousUnique(value,initialValue) {\n const ref = useRef(initialValue);\n useEffect(() => {\n if (value !== ref.current) {\n ref.current = value;\n }\n });\n return ref.current;\n}\n\nexport function usePreviousForEffect(value,initialValue) {\n const ref = useRef(initialValue);\n useEffect(() => () => {\n ref.current = value;\n },[value]);\n return ref.current;\n}"],"names":["usePrevious","value","initialValue","ref","useRef","useEffect","current","usePreviousUnique","usePreviousForEffect"],"mappings":";;AAEO,SAASA,WAAWA,CAACC,KAAK,EAACC,YAAY,EAAE;EAC9C,MAAMC,GAAG,GAAGC,MAAM,CAACF,YAAY,CAAC;EAChCG,SAAS,CAAC,MAAM;IACdF,GAAG,CAACG,OAAO,GAAGL,KAAK;GACpB,CAAC;EACF,OAAOE,GAAG,CAACG,OAAO;AACpB;AAEO,SAASC,iBAAiBA,CAACN,KAAK,EAACC,YAAY,EAAE;EACpD,MAAMC,GAAG,GAAGC,MAAM,CAACF,YAAY,CAAC;EAChCG,SAAS,CAAC,MAAM;IACd,IAAIJ,KAAK,KAAKE,GAAG,CAACG,OAAO,EAAE;MACzBH,GAAG,CAACG,OAAO,GAAGL,KAAK;;GAEtB,CAAC;EACF,OAAOE,GAAG,CAACG,OAAO;AACpB;AAEO,SAASE,oBAAoBA,CAACP,KAAK,EAACC,YAAY,EAAE;EACvD,MAAMC,GAAG,GAAGC,MAAM,CAACF,YAAY,CAAC;EAChCG,SAAS,CAAC,MAAM,MAAM;IACpBF,GAAG,CAACG,OAAO,GAAGL,KAAK;GACpB,EAAC,CAACA,KAAK,CAAC,CAAC;EACV,OAAOE,GAAG,CAACG,OAAO;AACpB;;;;"}
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { yakDomTag } from '@startlibs/utils/yakDomTag';
3
+ import { styled } from '@yak/react';
4
+
5
+ const TabFocus = styled(yakDomTag("div"))`width:0;height:0;position:absolute;`;
6
+ const useRecycleFocus = function (ref) {
7
+ let enabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
8
+ let lastIndex = arguments.length > 2 ? arguments[2] : undefined;
9
+ const recycle = i => e => {
10
+ if (!enabled || !ref.current) {
11
+ return;
12
+ }
13
+ const nextTab = ref.current.querySelectorAll('[tabindex]');
14
+ if (nextTab) {
15
+ if (i < 0) {
16
+ console.log(nextTab[1]);
17
+ nextTab[1].focus();
18
+ } else {
19
+ console.log(nextTab[nextTab.length - 2]);
20
+ nextTab[nextTab.length - 2].focus();
21
+ }
22
+ }
23
+ };
24
+ return [/*#__PURE__*/React.createElement(TabFocus, {
25
+ tabIndex: 1,
26
+ onFocus: recycle(0)
27
+ }), /*#__PURE__*/React.createElement(TabFocus, {
28
+ tabIndex: lastIndex || 1,
29
+ onFocus: recycle(-1)
30
+ })];
31
+ };
32
+
33
+ export { useRecycleFocus };
34
+ //# sourceMappingURL=useRecycleFocus.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRecycleFocus.mjs","sources":["../../src/hooks/useRecycleFocus.jsx"],"sourcesContent":["import React from 'react'\nimport styled from 'styled-components'\n\nstyled\n\nconst TabFocus = styled.div`width:0;height:0;position:absolute;`\nexport const useRecycleFocus = (ref, enabled = true,lastIndex) => {\n\n const recycle = i => (e) => {\n if (!enabled || !ref.current) {\n return\n }\n const nextTab = ref.current.querySelectorAll('[tabindex]')\n if (nextTab) {\n if (i<0) {\n console.log(nextTab[1])\n nextTab[1].focus()\n } else {\n console.log(nextTab[nextTab.length - 2])\n nextTab[nextTab.length - 2].focus()\n }\n }\n }\n\n return [<TabFocus tabIndex={1} onFocus={recycle(0)}></TabFocus>,<TabFocus tabIndex={lastIndex || 1} onFocus={recycle(-1)}></TabFocus>]\n}"],"names":["TabFocus","styled","yakDomTag","useRecycleFocus","ref","enabled","arguments","length","undefined","lastIndex","recycle","i","e","current","nextTab","querySelectorAll","console","log","focus","React","createElement","tabIndex","onFocus"],"mappings":";;;;AAKA,MAAMA,QAAQ,GAAGC,MAAA,CAAAC,SAAA,6CAA+C;MACnDC,eAAe,GAAG,UAACC,GAAG,EAA+B;EAAA,IAA7BC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAAA,IAACG,SAAS,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAE3D,MAAME,OAAO,GAAGC,CAAC,IAAKC,CAAC,IAAK;IAC1B,IAAI,CAACP,OAAO,IAAI,CAACD,GAAG,CAACS,OAAO,EAAE;MAC5B;;IAEF,MAAMC,OAAO,GAAGV,GAAG,CAACS,OAAO,CAACE,gBAAgB,CAAC,YAAY,CAAC;IAC1D,IAAID,OAAO,EAAE;MACX,IAAIH,CAAC,GAAC,CAAC,EAAE;QACPK,OAAO,CAACC,GAAG,CAACH,OAAO,CAAC,CAAC,CAAC,CAAC;QACvBA,OAAO,CAAC,CAAC,CAAC,CAACI,KAAK,EAAE;OACnB,MAAM;QACLF,OAAO,CAACC,GAAG,CAACH,OAAO,CAACA,OAAO,CAACP,MAAM,GAAG,CAAC,CAAC,CAAC;QACxCO,OAAO,CAACA,OAAO,CAACP,MAAM,GAAG,CAAC,CAAC,CAACW,KAAK,EAAE;;;GAGxC;EAED,OAAO,cAACC,KAAA,CAAAC,aAAA,CAACpB,QAAQ;IAACqB,QAAQ,EAAE,CAAE;IAACC,OAAO,EAAEZ,OAAO,CAAC,CAAC;GAAa,CAAC,eAACS,KAAA,CAAAC,aAAA,CAACpB,QAAQ;IAACqB,QAAQ,EAAEZ,SAAS,IAAI,CAAE;IAACa,OAAO,EAAEZ,OAAO,CAAC,CAAC,CAAC;GAAa,CAAC,CAAC;AACxI;;;;"}
@@ -0,0 +1,13 @@
1
+ import { useRef } from 'react';
2
+ import { callIfFunction } from '@startlibs/utils';
3
+
4
+ const useRefMemo = value => {
5
+ const ref = useRef(value);
6
+ if (ref.current !== value) {
7
+ ref.current = callIfFunction(value);
8
+ }
9
+ return ref;
10
+ };
11
+
12
+ export { useRefMemo };
13
+ //# sourceMappingURL=useRefMemo.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRefMemo.mjs","sources":["../../src/hooks/useRefMemo.jsx"],"sourcesContent":["import React, {useRef} from 'react'\nimport {callIfFunction} from '@startlibs/utils'\n\nexport const useRefMemo = (value) => {\n const ref = useRef(value)\n if (ref.current !== value) {\n ref.current = callIfFunction(value)\n }\n return ref\n}"],"names":["useRefMemo","value","ref","useRef","current","callIfFunction"],"mappings":";;;MAGaA,UAAU,GAAIC,KAAK,IAAK;EACnC,MAAMC,GAAG,GAAGC,MAAM,CAACF,KAAK,CAAC;EACzB,IAAIC,GAAG,CAACE,OAAO,KAAKH,KAAK,EAAE;IACzBC,GAAG,CAACE,OAAO,GAAGC,cAAc,CAACJ,KAAK,CAAC;;EAErC,OAAOC,GAAG;AACZ;;;;"}