@startlibs/core 1.1.0 → 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.
- package/lib/SlotFill.mjs +4 -4
- package/lib/SlotFill.mjs.map +1 -1
- package/lib/StartlibsProvider.mjs.map +1 -1
- package/lib/hocs/WithLazyResource.mjs +4 -4
- package/lib/hocs/WithLazyResource.mjs.map +1 -1
- package/lib/hocs/WithRef.mjs.map +1 -1
- package/lib/hocs/consumes.mjs +1 -1
- package/lib/hocs/consumes.mjs.map +1 -1
- package/lib/hocs/withDialogError.mjs +1 -1
- package/lib/hocs/withDialogError.mjs.map +1 -1
- package/lib/hocs/withGroupEvent.mjs +1 -1
- package/lib/hocs/withGroupEvent.mjs.map +1 -1
- package/lib/hooks/WithConstant.mjs +2 -2
- package/lib/hooks/WithConstant.mjs.map +1 -1
- package/lib/hooks/WithEffect.mjs.map +1 -1
- package/lib/hooks/useAsyncEffect.mjs.map +1 -1
- package/lib/hooks/useCallState.mjs +1 -1
- package/lib/hooks/useCallState.mjs.map +1 -1
- package/lib/hooks/useCallbackStable.mjs.map +1 -1
- package/lib/hooks/useConstant.mjs.map +1 -1
- package/lib/hooks/useConsumerCatalog.mjs.map +1 -1
- package/lib/hooks/useEnsureRef.mjs.map +1 -1
- package/lib/hooks/useForceUpdate.mjs +7 -7
- package/lib/hooks/useForceUpdate.mjs.map +1 -1
- package/lib/hooks/useIsUnmounted.mjs.map +1 -1
- package/lib/hooks/usePopupToggle.mjs +1 -1
- package/lib/hooks/usePopupToggle.mjs.map +1 -1
- package/lib/hooks/usePrevious.mjs.map +1 -1
- package/lib/hooks/useRecycleFocus.mjs.map +1 -1
- package/lib/hooks/useRefMemo.mjs.map +1 -1
- package/lib/hooks/useRefState.mjs +1 -1
- package/lib/hooks/useRefState.mjs.map +1 -1
- package/lib/hooks/useSignal.mjs +15 -15
- package/lib/hooks/useSignal.mjs.map +1 -1
- package/lib/hooks/useTitle.mjs +2 -2
- package/lib/hooks/useTitle.mjs.map +1 -1
- package/lib/hooks/useToggle.mjs +1 -1
- package/lib/hooks/useToggle.mjs.map +1 -1
- package/lib/hooks/useUpdateEffect.mjs.map +1 -1
- package/lib/hooks/useUpdateOnResize.mjs.map +1 -1
- package/lib/hooks/useWithTransition.mjs +1 -1
- package/lib/hooks/useWithTransition.mjs.map +1 -1
- package/lib/hooks/willUseLayers.mjs +2 -2
- package/lib/hooks/willUseLayers.mjs.map +1 -1
- package/lib/hooks/willUseSharedCallback.mjs.map +1 -1
- package/lib/hooks/willUseSharedState.mjs +3 -3
- package/lib/hooks/willUseSharedState.mjs.map +1 -1
- package/lib/hooks/willUseSpreadState.mjs +4 -4
- package/lib/hooks/willUseSpreadState.mjs.map +1 -1
- package/lib/index.cjs +164 -164
- package/lib/index.cjs.map +1 -1
- package/lib/index.mjs +10 -10
- package/lib-yak/SlotFill.mjs +230 -0
- package/lib-yak/SlotFill.mjs.map +1 -0
- package/lib-yak/StartlibsProvider.mjs +62 -0
- package/lib-yak/StartlibsProvider.mjs.map +1 -0
- package/lib-yak/hocs/WithLazyResource.mjs +74 -0
- package/lib-yak/hocs/WithLazyResource.mjs.map +1 -0
- package/lib-yak/hocs/WithRef.mjs +20 -0
- package/lib-yak/hocs/WithRef.mjs.map +1 -0
- package/lib-yak/hocs/consumes.mjs +22 -0
- package/lib-yak/hocs/consumes.mjs.map +1 -0
- package/lib-yak/hocs/withDialogError.mjs +22 -0
- package/lib-yak/hocs/withDialogError.mjs.map +1 -0
- package/lib-yak/hocs/withGroupEvent.mjs +45 -0
- package/lib-yak/hocs/withGroupEvent.mjs.map +1 -0
- package/lib-yak/hooks/WithConstant.mjs +13 -0
- package/lib-yak/hooks/WithConstant.mjs.map +1 -0
- package/lib-yak/hooks/WithEffect.mjs +12 -0
- package/lib-yak/hooks/WithEffect.mjs.map +1 -0
- package/lib-yak/hooks/useAsyncEffect.mjs +14 -0
- package/lib-yak/hooks/useAsyncEffect.mjs.map +1 -0
- package/lib-yak/hooks/useCallState.mjs +21 -0
- package/lib-yak/hooks/useCallState.mjs.map +1 -0
- package/lib-yak/hooks/useCallbackStable.mjs +17 -0
- package/lib-yak/hooks/useCallbackStable.mjs.map +1 -0
- package/lib-yak/hooks/useConstant.mjs +21 -0
- package/lib-yak/hooks/useConstant.mjs.map +1 -0
- package/lib-yak/hooks/useConsumerCatalog.mjs +25 -0
- package/lib-yak/hooks/useConsumerCatalog.mjs.map +1 -0
- package/lib-yak/hooks/useEnsureRef.mjs +9 -0
- package/lib-yak/hooks/useEnsureRef.mjs.map +1 -0
- package/lib-yak/hooks/useForceUpdate.mjs +28 -0
- package/lib-yak/hooks/useForceUpdate.mjs.map +1 -0
- package/lib-yak/hooks/useIsUnmounted.mjs +15 -0
- package/lib-yak/hooks/useIsUnmounted.mjs.map +1 -0
- package/lib-yak/hooks/usePopupToggle.mjs +33 -0
- package/lib-yak/hooks/usePopupToggle.mjs.map +1 -0
- package/lib-yak/hooks/usePrevious.mjs +28 -0
- package/lib-yak/hooks/usePrevious.mjs.map +1 -0
- package/lib-yak/hooks/useRecycleFocus.mjs +34 -0
- package/lib-yak/hooks/useRecycleFocus.mjs.map +1 -0
- package/lib-yak/hooks/useRefMemo.mjs +13 -0
- package/lib-yak/hooks/useRefMemo.mjs.map +1 -0
- package/lib-yak/hooks/useRefState.mjs +29 -0
- package/lib-yak/hooks/useRefState.mjs.map +1 -0
- package/lib-yak/hooks/useSignal.mjs +271 -0
- package/lib-yak/hooks/useSignal.mjs.map +1 -0
- package/lib-yak/hooks/useTitle.mjs +17 -0
- package/lib-yak/hooks/useTitle.mjs.map +1 -0
- package/lib-yak/hooks/useToggle.mjs +152 -0
- package/lib-yak/hooks/useToggle.mjs.map +1 -0
- package/lib-yak/hooks/useUpdateEffect.mjs +15 -0
- package/lib-yak/hooks/useUpdateEffect.mjs.map +1 -0
- package/lib-yak/hooks/useUpdateOnResize.mjs +18 -0
- package/lib-yak/hooks/useUpdateOnResize.mjs.map +1 -0
- package/lib-yak/hooks/useWithTransition.mjs +18 -0
- package/lib-yak/hooks/useWithTransition.mjs.map +1 -0
- package/lib-yak/hooks/willUseLayers.mjs +55 -0
- package/lib-yak/hooks/willUseLayers.mjs.map +1 -0
- package/lib-yak/hooks/willUseSharedCallback.mjs +70 -0
- package/lib-yak/hooks/willUseSharedCallback.mjs.map +1 -0
- package/lib-yak/hooks/willUseSharedState.mjs +41 -0
- package/lib-yak/hooks/willUseSharedState.mjs.map +1 -0
- package/lib-yak/hooks/willUseSpreadState.mjs +119 -0
- package/lib-yak/hooks/willUseSpreadState.mjs.map +1 -0
- package/lib-yak/index.mjs +33 -0
- package/lib-yak/index.mjs.map +1 -0
- package/package.json +11 -2
package/lib/SlotFill.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React, { useRef, useContext, useLayoutEffect, useMemo, useEffect } from 'react';
|
|
2
|
+
import { callIfFunction, _s } from '@startlibs/utils';
|
|
1
3
|
import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
|
|
2
4
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
5
|
import _extends from '@babel/runtime/helpers/extends';
|
|
@@ -15,10 +17,8 @@ import _without from 'lodash/fp/without';
|
|
|
15
17
|
import _union from 'lodash/fp/union';
|
|
16
18
|
import _update from 'lodash/fp/update';
|
|
17
19
|
import _flow from 'lodash/fp/flow';
|
|
18
|
-
import React, { useRef, useContext, useLayoutEffect, useMemo, useEffect } from 'react';
|
|
19
20
|
import ReactDOM from 'react-dom';
|
|
20
21
|
import styled from 'styled-components';
|
|
21
|
-
import { callIfFunction, _s } from '@startlibs/utils';
|
|
22
22
|
import { useConstant } from './hooks/useConstant.mjs';
|
|
23
23
|
import { willUseSharedState } from './hooks/willUseSharedState.mjs';
|
|
24
24
|
|
|
@@ -86,8 +86,8 @@ const Invisible = /*#__PURE__*/styled.div.withConfig({
|
|
|
86
86
|
})(["display:none"]);
|
|
87
87
|
const FillBeforeFlip = _ref3 => {
|
|
88
88
|
let name = _ref3.name,
|
|
89
|
-
children = _ref3.children
|
|
90
|
-
_ref3.slot;
|
|
89
|
+
children = _ref3.children,
|
|
90
|
+
slot = _ref3.slot;
|
|
91
91
|
const slots = useContext(SlotContext);
|
|
92
92
|
const ref = useRef();
|
|
93
93
|
useLayoutEffect(() => {
|
package/lib/SlotFill.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlotFill.mjs","sources":["../src/SlotFill.jsx"],"sourcesContent":["import React, {useContext, useEffect, useLayoutEffect, useMemo, useRef} from 'react'\nimport ReactDOM from 'react-dom'\nimport styled from 'styled-components'\nimport _ from 'lodash/fp'\nimport {_s, callIfFunction} from '@startlibs/utils'\nimport {useConstant} from './hooks/useConstant'\nimport {willUseSharedState} from './hooks/willUseSharedState'\n\nexport const SlotContext = React.createContext(new Map())\nconst [useFillHookState, useFillHookStateRef] = willUseSharedState()\nconst [useHiddenFillHookState, useHiddenFillHookStateRef] = willUseSharedState()\n\nconst DEFAULT_CONTEXT = new Map()\n\nexport const SlotProvider = ({children}) => {\n\n return <SlotContext.Provider value={DEFAULT_CONTEXT}>\n {children}\n <React.Suspense fallback={null}><FillHooks/></React.Suspense>\n <HiddenFillHooks/>\n </SlotContext.Provider>\n}\n\nexport const Slot = ({name,children,...rest}) => {\n\n const ref = useRef()\n const slotInfo = useConstant({ref})\n\n const slots = useContext(SlotContext)\n\n useLayoutEffect(() => {\n const previous = slots.get(name)\n const updates = previous?.updates || []\n if (previous?.children) {\n // reparent\n }\n slots.set(name,_.flow(\n _.update('infos',_.union([slotInfo]))\n )(previous))\n updates.forEach(v => v({}))\n return () => {\n const previous = slots.get(name)\n previous.infos = _.without([slotInfo],previous.infos)\n if (!previous.infos?.length && !previous.updates?.length) {\n slots.delete(name)\n }\n }\n }, [name])\n\n return children\n ? <>\n <div data-id={name} {...rest} ref={ref}/>\n {React.Children.map(children,c => React.cloneElement(c,{...c.props,name,stack:Number.MIN_SAFE_INTEGER}))}\n </>\n : <div data-id={name} {...rest} ref={ref}/>\n\n}\n\nconst Invisible = styled.div`display:none`\n\nconst FillBeforeFlip = ({name, children, slot}) => {\n const slots = useContext(SlotContext)\n const ref = useRef()\n useLayoutEffect(() => {\n const infos = slots.get(name)?.infos || []\n const mounted = _.flatMap(({ref}) => ref?.current,infos)\n const clones = []\n const getClone = () => {\n const cloned = ref.current.cloneNode(true)\n cloned.className = 'JS-fill-flip'\n clones.push(cloned)\n return cloned\n }\n mounted.map(_ => _.appendChild(getClone()))\n return () => {\n clones.forEach(el => el.remove())\n }\n },[])\n return <Invisible ref={ref}>{children}</Invisible>\n}\n\nconst useFillState = (name,stack) => {\n const forceUpdate = React.useState(false)[1];\n const slots = useContext(SlotContext)\n const renderSlot = slots.get(name)\n const maxStack = _.max(renderSlot?.stacks)\n const onStack = !_.isFinite(maxStack) || maxStack === stack\n useLayoutEffect(() => {\n\n const slot = slots.get(name)\n const updatedSlot = _.flow(\n _.update('updates',_.union([forceUpdate])),\n _.update('stacks',_.union([stack])),\n )(slot)\n slots.set(name, updatedSlot)\n updatedSlot.updates.forEach(v => v({}))\n return () => {\n const previous = slots.get(name)\n const index = previous.updates.indexOf(forceUpdate)\n const next = _.flow(\n _.update('updates',_s.removeAt(index)),\n _.update('stacks',_s.removeAt(index))\n )(previous)\n slots.set(name,next)\n next.updates.forEach(v => v({}))\n }\n },[])\n\n return [renderSlot,onStack]\n}\n\n\nexport const Fill = ({name, children, stack = 0, mountBeforeFlip}) => {\n const [slot,onStack] = useFillState(name,stack)\n if (slot?.infos && onStack) {\n return slot?.infos.map((info) => info.ref?.current && ReactDOM.createPortal(callIfFunction(children,info),info.ref.current))\n } else if (mountBeforeFlip) {\n return <FillBeforeFlip name={name} slot={slot}>{children}</FillBeforeFlip>\n } else {\n return null\n }\n}\n\n\nconst FillHooks = ({}) => {\n const [hooked] = useFillHookState({})\n return Object.entries(hooked)\n .map(([name, childs]) => childs.map(({children}, i) => <Fill key={name + i} name={name}>{children}</Fill>))\n}\n\nlet uid = 0\nexport const useFill = (name, children, inputs) => {\n const [, set] = useFillHookStateRef()\n const key = useRef(uid++)\n useLayoutEffect(() => {\n if (children) {\n set(_.update([name], (list = []) => {\n const index = _.findIndex(['key',key.current],list)\n const value = {children,key:key.current}\n if (index >= 0 ) {\n return _.set([index],value,list)\n } else {\n return list.concat(value)\n }\n } ))\n } else {\n set(_.update([name], _.differenceBy('key',_, [{children,key:key.current}])))\n }\n }, inputs || children)\n\n useLayoutEffect(() =>\n () => set(_.update([name], _.differenceBy('key',_, [{key:key.current}])))\n ,[])\n}\n\nconst HiddenFillHooks = ({}) => {\n const [hookedChildren] = useHiddenFillHookState({})\n return <div>{Object.values(hookedChildren)}</div>\n}\n\nexport const useHiddenFill = (children, inputs) => {\n const [, set] = useHiddenFillHookStateRef()\n const [uid] = useMemo(()=>_.uniqueId(\"\"),[])\n set(_.set([uid], children ? React.cloneElement(children,{key:uid}) : null))\n useEffect(()=> () => set(_.unset([uid])),[])\n}\n"],"names":["SlotContext","React","createContext","Map","_willUseSharedState","willUseSharedState","_willUseSharedState2","_slicedToArray","useFillHookState","useFillHookStateRef","_willUseSharedState3","_willUseSharedState4","useHiddenFillHookState","useHiddenFillHookStateRef","DEFAULT_CONTEXT","SlotProvider","_ref","children","createElement","Provider","value","Suspense","fallback","FillHooks","HiddenFillHooks","Slot","_ref2","name","rest","_objectWithoutProperties","_excluded","ref","useRef","slotInfo","useConstant","slots","useContext","useLayoutEffect","previous","get","updates","set","_flow","_update","_union","forEach","v","_previous$infos","_previous$updates","infos","_without","length","delete","Fragment","_extends","Children","map","c","cloneElement","_objectSpread","props","stack","Number","MIN_SAFE_INTEGER","Invisible","styled","div","withConfig","displayName","componentId","FillBeforeFlip","_ref3","slot","_slots$get","mounted","_flatMap","_ref4","current","clones","getClone","cloned","cloneNode","className","push","_","appendChild","el","remove","useFillState","forceUpdate","useState","renderSlot","maxStack","_max","stacks","onStack","_isFinite","updatedSlot","index","indexOf","next","_s","removeAt","Fill","_ref5","_ref5$stack","mountBeforeFlip","_useFillState","_useFillState2","info","_info$ref","ReactDOM","createPortal","callIfFunction","_ref6","_objectDestructuringEmpty","_useFillHookState","_useFillHookState2","hooked","Object","entries","_ref7","_ref8","childs","_ref9","i","key","uid","useFill","inputs","_useFillHookStateRef","_useFillHookStateRef2","list","arguments","undefined","_findIndex","_set","concat","_differenceBy","placeholder","_ref0","_useHiddenFillHookSta","_useHiddenFillHookSta2","hookedChildren","values","useHiddenFill","_useHiddenFillHookSta3","_useHiddenFillHookSta4","_useMemo","useMemo","_uniqueId","_useMemo2","useEffect","_unset"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAMA,WAAW,gBAAGC,KAAK,CAACC,aAAa,CAAC,IAAIC,GAAG,EAAE,EAAC;AACzD,MAAAC,mBAAA,GAAgDC,kBAAkB,EAAE;EAAAC,oBAAA,GAAAC,cAAA,CAAAH,mBAAA,EAAA,CAAA,CAAA;AAA7DI,EAAAA,gBAAgB,GAAAF,oBAAA,CAAA,CAAA,CAAA;AAAEG,EAAAA,mBAAmB,GAAAH,oBAAA,CAAA,CAAA,CAAA,CAAA;AAC5C,MAAAI,oBAAA,GAA4DL,kBAAkB,EAAE;EAAAM,oBAAA,GAAAJ,cAAA,CAAAG,oBAAA,EAAA,CAAA,CAAA;AAAzEE,EAAAA,sBAAsB,GAAAD,oBAAA,CAAA,CAAA,CAAA;AAAEE,EAAAA,yBAAyB,GAAAF,oBAAA,CAAA,CAAA,CAAA,CAAA;AAExD,MAAMG,eAAe,GAAG,IAAIX,GAAG,EAAE,CAAA;AAEpBY,MAAAA,YAAY,GAAGC,IAAA,IAAgB;AAAA,EAAA,IAAdC,QAAQ,GAAAD,IAAA,CAARC,QAAQ,CAAA;AAEpC,EAAA,oBAAOhB,KAAA,CAAAiB,aAAA,CAAClB,WAAW,CAACmB,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEN,eAAAA;GACjC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,CAAC,EAAE9G,QAAQ,gBAAGhB,KAAK,CAACyD,YAAY,CAACzC,QAAQ,EAAC;AAAC6G,IAAAA,GAAG,EAACC,GAAAA;AAAG,GAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;AAC3EyB,EAAAA,SAAS,CAAC,MAAK,MAAM/G,GAAG,CAACgH,MAAA,CAAQ,CAAC1B,GAAG,CAAC,CAAC,CAAC,EAAC,EAAE,CAAC,CAAA;AAC9C;;;;"}
|
|
1
|
+
{"version":3,"file":"SlotFill.mjs","sources":["../src/SlotFill.jsx"],"sourcesContent":["import React, {useContext, useEffect, useLayoutEffect, useMemo, useRef} from 'react'\nimport ReactDOM from 'react-dom'\nimport styled from 'styled-components'\nimport _ from 'lodash/fp'\nimport {_s, callIfFunction} from '@startlibs/utils'\nimport {useConstant} from './hooks/useConstant'\nimport {willUseSharedState} from './hooks/willUseSharedState'\n\nexport const SlotContext = React.createContext(new Map())\nconst [useFillHookState, useFillHookStateRef] = willUseSharedState()\nconst [useHiddenFillHookState, useHiddenFillHookStateRef] = willUseSharedState()\n\nconst DEFAULT_CONTEXT = new Map()\n\nexport const SlotProvider = ({children}) => {\n\n return <SlotContext.Provider value={DEFAULT_CONTEXT}>\n {children}\n <React.Suspense fallback={null}><FillHooks/></React.Suspense>\n <HiddenFillHooks/>\n </SlotContext.Provider>\n}\n\nexport const Slot = ({name,children,...rest}) => {\n\n const ref = useRef()\n const slotInfo = useConstant({ref})\n\n const slots = useContext(SlotContext)\n\n useLayoutEffect(() => {\n const previous = slots.get(name)\n const updates = previous?.updates || []\n if (previous?.children) {\n // reparent\n }\n slots.set(name,_.flow(\n _.update('infos',_.union([slotInfo]))\n )(previous))\n updates.forEach(v => v({}))\n return () => {\n const previous = slots.get(name)\n previous.infos = _.without([slotInfo],previous.infos)\n if (!previous.infos?.length && !previous.updates?.length) {\n slots.delete(name)\n }\n }\n }, [name])\n\n return children\n ? <>\n <div data-id={name} {...rest} ref={ref}/>\n {React.Children.map(children,c => React.cloneElement(c,{...c.props,name,stack:Number.MIN_SAFE_INTEGER}))}\n </>\n : <div data-id={name} {...rest} ref={ref}/>\n\n}\n\nconst Invisible = styled.div`display:none`\n\nconst FillBeforeFlip = ({name, children, slot}) => {\n const slots = useContext(SlotContext)\n const ref = useRef()\n useLayoutEffect(() => {\n const infos = slots.get(name)?.infos || []\n const mounted = _.flatMap(({ref}) => ref?.current,infos)\n const clones = []\n const getClone = () => {\n const cloned = ref.current.cloneNode(true)\n cloned.className = 'JS-fill-flip'\n clones.push(cloned)\n return cloned\n }\n mounted.map(_ => _.appendChild(getClone()))\n return () => {\n clones.forEach(el => el.remove())\n }\n },[])\n return <Invisible ref={ref}>{children}</Invisible>\n}\n\nconst useFillState = (name,stack) => {\n const forceUpdate = React.useState(false)[1];\n const slots = useContext(SlotContext)\n const renderSlot = slots.get(name)\n const maxStack = _.max(renderSlot?.stacks)\n const onStack = !_.isFinite(maxStack) || maxStack === stack\n useLayoutEffect(() => {\n\n const slot = slots.get(name)\n const updatedSlot = _.flow(\n _.update('updates',_.union([forceUpdate])),\n _.update('stacks',_.union([stack])),\n )(slot)\n slots.set(name, updatedSlot)\n updatedSlot.updates.forEach(v => v({}))\n return () => {\n const previous = slots.get(name)\n const index = previous.updates.indexOf(forceUpdate)\n const next = _.flow(\n _.update('updates',_s.removeAt(index)),\n _.update('stacks',_s.removeAt(index))\n )(previous)\n slots.set(name,next)\n next.updates.forEach(v => v({}))\n }\n },[])\n\n return [renderSlot,onStack]\n}\n\n\nexport const Fill = ({name, children, stack = 0, mountBeforeFlip}) => {\n const [slot,onStack] = useFillState(name,stack)\n if (slot?.infos && onStack) {\n return slot?.infos.map((info) => info.ref?.current && ReactDOM.createPortal(callIfFunction(children,info),info.ref.current))\n } else if (mountBeforeFlip) {\n return <FillBeforeFlip name={name} slot={slot}>{children}</FillBeforeFlip>\n } else {\n return null\n }\n}\n\n\nconst FillHooks = ({}) => {\n const [hooked] = useFillHookState({})\n return Object.entries(hooked)\n .map(([name, childs]) => childs.map(({children}, i) => <Fill key={name + i} name={name}>{children}</Fill>))\n}\n\nlet uid = 0\nexport const useFill = (name, children, inputs) => {\n const [, set] = useFillHookStateRef()\n const key = useRef(uid++)\n useLayoutEffect(() => {\n if (children) {\n set(_.update([name], (list = []) => {\n const index = _.findIndex(['key',key.current],list)\n const value = {children,key:key.current}\n if (index >= 0 ) {\n return _.set([index],value,list)\n } else {\n return list.concat(value)\n }\n } ))\n } else {\n set(_.update([name], _.differenceBy('key',_, [{children,key:key.current}])))\n }\n }, inputs || children)\n\n useLayoutEffect(() =>\n () => set(_.update([name], _.differenceBy('key',_, [{key:key.current}])))\n ,[])\n}\n\nconst HiddenFillHooks = ({}) => {\n const [hookedChildren] = useHiddenFillHookState({})\n return <div>{Object.values(hookedChildren)}</div>\n}\n\nexport const useHiddenFill = (children, inputs) => {\n const [, set] = useHiddenFillHookStateRef()\n const [uid] = useMemo(()=>_.uniqueId(\"\"),[])\n set(_.set([uid], children ? React.cloneElement(children,{key:uid}) : null))\n useEffect(()=> () => set(_.unset([uid])),[])\n}\n"],"names":["SlotContext","React","createContext","Map","_willUseSharedState","willUseSharedState","_willUseSharedState2","_slicedToArray","useFillHookState","useFillHookStateRef","_willUseSharedState3","_willUseSharedState4","useHiddenFillHookState","useHiddenFillHookStateRef","DEFAULT_CONTEXT","SlotProvider","_ref","children","createElement","Provider","value","Suspense","fallback","FillHooks","HiddenFillHooks","Slot","_ref2","name","rest","_objectWithoutProperties","_excluded","ref","useRef","slotInfo","useConstant","slots","useContext","useLayoutEffect","previous","get","updates","set","_flow","_update","_union","forEach","v","_previous$infos","_previous$updates","infos","_without","length","delete","Fragment","_extends","Children","map","c","cloneElement","_objectSpread","props","stack","Number","MIN_SAFE_INTEGER","Invisible","styled","div","withConfig","displayName","componentId","FillBeforeFlip","_ref3","slot","_slots$get","mounted","_flatMap","_ref4","current","clones","getClone","cloned","cloneNode","className","push","_","appendChild","el","remove","useFillState","forceUpdate","useState","renderSlot","maxStack","_max","stacks","onStack","_isFinite","updatedSlot","index","indexOf","next","_s","removeAt","Fill","_ref5","_ref5$stack","mountBeforeFlip","_useFillState","_useFillState2","info","_info$ref","ReactDOM","createPortal","callIfFunction","_ref6","_objectDestructuringEmpty","_useFillHookState","_useFillHookState2","hooked","Object","entries","_ref7","_ref8","childs","_ref9","i","key","uid","useFill","inputs","_useFillHookStateRef","_useFillHookStateRef2","list","arguments","undefined","_findIndex","_set","concat","_differenceBy","placeholder","_ref0","_useHiddenFillHookSta","_useHiddenFillHookSta2","hookedChildren","values","useHiddenFill","_useHiddenFillHookSta3","_useHiddenFillHookSta4","_useMemo","useMemo","_uniqueId","_useMemo2","useEffect","_unset"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;MAQaA,WAAW,gBAAGC,KAAK,CAACC,aAAa,CAAC,IAAIC,GAAG,EAAE;AACxD,MAAAC,mBAAA,GAAgDC,kBAAkB,EAAE;EAAAC,oBAAA,GAAAC,cAAA,CAAAH,mBAAA;EAA7DI,gBAAgB,GAAAF,oBAAA;EAAEG,mBAAmB,GAAAH,oBAAA;AAC5C,MAAAI,oBAAA,GAA4DL,kBAAkB,EAAE;EAAAM,oBAAA,GAAAJ,cAAA,CAAAG,oBAAA;EAAzEE,sBAAsB,GAAAD,oBAAA;EAAEE,yBAAyB,GAAAF,oBAAA;AAExD,MAAMG,eAAe,GAAG,IAAIX,GAAG,EAAE;MAEpBY,YAAY,GAAGC,IAAA,IAAgB;EAAA,IAAdC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EAEpC,oBAAOhB,KAAA,CAAAiB,aAAA,CAAClB,WAAW,CAACmB,QAAQ;IAACC,KAAK,EAAEN;KACjCG,QAAQ,eACThB,KAAA,CAAAiB,aAAA,CAACjB,KAAK,CAACoB,QAAQ;IAACC,QAAQ,EAAE;kBAAMrB,KAAA,CAAAiB,aAAA,CAACK,SAAS,MAAC,CAAiB,CAAC,eAC7DtB,KAAA,CAAAiB,aAAA,CAACM,eAAe,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AAC,CAAC,CAAC,EAAC,EAAE,CAAC;AAC9C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartlibsProvider.mjs","sources":["../src/StartlibsProvider.jsx"],"sourcesContent":["import React from 'react'\nimport _ from 'lodash/fp'\nimport {fixMediaQuery,callIfFunction} from '@startlibs/utils'\nimport {SlotProvider} from './SlotFill'\nimport {clearPopups} from './hooks/usePopupToggle'\n\nexport const StartlibsContext = React.createContext({})\nexport const PopupContext = React.createContext({})\nexport const StartlibsMetacontext = React.createContext(()=>{})\n\nexport const StartlibsConsumer = StartlibsContext.Consumer\n\nconst wrappeStyle = {height: '100%'}\n\n\nexport class StartlibsProvider extends React.Component {\n\n componentDidMount() {\n fixMediaQuery()\n const addVHFix = () => {\n let vh = window.innerHeight * 0.01;\n document.documentElement?.style?.setProperty('--vh', `${vh}px`);\n }\n window.addEventListener('resize', _.debounce(200, addVHFix))\n addVHFix()\n }\n\n openToggles = new Map()\n\n popupToggleRender = ({isOpen,close},ref) => {\n if (isOpen && !this.openToggles.has(ref)) {\n this.closePopup()\n this.openToggles.set(ref,close)\n }\n }\n closePopup = () => {\n clearPopups()\n }\n\n startlibsMeta = new Map()\n\n getMeta = (key,initValue) => {\n const exists = this.startlibsMeta.get(key)\n if (exists) return exists\n this.startlibsMeta.set(key,callIfFunction(initValue))\n return initValue\n }\n\n render() {\n return <StartlibsContext.Provider value={this.props.value}>\n <StartlibsMetacontext.Provider value={this.getMeta}>\n <PopupContext.Provider value={this.popupToggleRender}>\n <div style={wrappeStyle} onClick={this.closePopup}>\n <SlotProvider>\n {this.props.children}\n </SlotProvider>\n </div>\n </PopupContext.Provider>\n </StartlibsMetacontext.Provider>\n </StartlibsContext.Provider>\n }\n}\n"],"names":["StartlibsContext","React","createContext","PopupContext","StartlibsMetacontext","StartlibsConsumer","Consumer","wrappeStyle","height","StartlibsProvider","Component","constructor","arguments","openToggles","Map","popupToggleRender","_ref","ref","isOpen","close","has","closePopup","set","clearPopups","startlibsMeta","getMeta","key","initValue","exists","get","callIfFunction","componentDidMount","fixMediaQuery","addVHFix","_document$documentEle","vh","window","innerHeight","document","documentElement","style","setProperty","concat","addEventListener","_debounce","render","createElement","Provider","value","props","onClick","SlotProvider","children"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"StartlibsProvider.mjs","sources":["../src/StartlibsProvider.jsx"],"sourcesContent":["import React from 'react'\nimport _ from 'lodash/fp'\nimport {fixMediaQuery,callIfFunction} from '@startlibs/utils'\nimport {SlotProvider} from './SlotFill'\nimport {clearPopups} from './hooks/usePopupToggle'\n\nexport const StartlibsContext = React.createContext({})\nexport const PopupContext = React.createContext({})\nexport const StartlibsMetacontext = React.createContext(()=>{})\n\nexport const StartlibsConsumer = StartlibsContext.Consumer\n\nconst wrappeStyle = {height: '100%'}\n\n\nexport class StartlibsProvider extends React.Component {\n\n componentDidMount() {\n fixMediaQuery()\n const addVHFix = () => {\n let vh = window.innerHeight * 0.01;\n document.documentElement?.style?.setProperty('--vh', `${vh}px`);\n }\n window.addEventListener('resize', _.debounce(200, addVHFix))\n addVHFix()\n }\n\n openToggles = new Map()\n\n popupToggleRender = ({isOpen,close},ref) => {\n if (isOpen && !this.openToggles.has(ref)) {\n this.closePopup()\n this.openToggles.set(ref,close)\n }\n }\n closePopup = () => {\n clearPopups()\n }\n\n startlibsMeta = new Map()\n\n getMeta = (key,initValue) => {\n const exists = this.startlibsMeta.get(key)\n if (exists) return exists\n this.startlibsMeta.set(key,callIfFunction(initValue))\n return initValue\n }\n\n render() {\n return <StartlibsContext.Provider value={this.props.value}>\n <StartlibsMetacontext.Provider value={this.getMeta}>\n <PopupContext.Provider value={this.popupToggleRender}>\n <div style={wrappeStyle} onClick={this.closePopup}>\n <SlotProvider>\n {this.props.children}\n </SlotProvider>\n </div>\n </PopupContext.Provider>\n </StartlibsMetacontext.Provider>\n </StartlibsContext.Provider>\n }\n}\n"],"names":["StartlibsContext","React","createContext","PopupContext","StartlibsMetacontext","StartlibsConsumer","Consumer","wrappeStyle","height","StartlibsProvider","Component","constructor","arguments","openToggles","Map","popupToggleRender","_ref","ref","isOpen","close","has","closePopup","set","clearPopups","startlibsMeta","getMeta","key","initValue","exists","get","callIfFunction","componentDidMount","fixMediaQuery","addVHFix","_document$documentEle","vh","window","innerHeight","document","documentElement","style","setProperty","concat","addEventListener","_debounce","render","createElement","Provider","value","props","onClick","SlotProvider","children"],"mappings":";;;;;;MAMaA,gBAAgB,gBAAGC,KAAK,CAACC,aAAa,CAAC,EAAE;MACzCC,YAAY,gBAAGF,KAAK,CAACC,aAAa,CAAC,EAAE;MACrCE,oBAAoB,gBAAGH,KAAK,CAACC,aAAa,CAAC,MAAI,EAAE;MAEjDG,iBAAiB,GAAGL,gBAAgB,CAACM;AAElD,MAAMC,WAAW,GAAG;EAACC,MAAM,EAAE;AAAM,CAAC;AAG7B,MAAMC,iBAAiB,SAASR,KAAK,CAACS,SAAS,CAAC;EAAAC;IAAA,SAAAC,SAAA;IAAA,KAYrDC,WAAW,GAAG,IAAIC,GAAG,EAAE;IAAA,KAEvBC,iBAAiB,GAAG,CAAAC,IAAA,EAAgBC,GAAG,KAAK;MAAA,IAAtBC,MAAM,GAAAF,IAAA,CAANE,MAAM;QAACC,KAAK,GAAAH,IAAA,CAALG,KAAK;MAChC,IAAID,MAAM,IAAI,CAAC,IAAI,CAACL,WAAW,CAACO,GAAG,CAACH,GAAG,CAAC,EAAE;QACxC,IAAI,CAACI,UAAU,EAAE;QACjB,IAAI,CAACR,WAAW,CAACS,GAAG,CAACL,GAAG,EAACE,KAAK,CAAC;;KAElC;IAAA,KACDE,UAAU,GAAG,MAAM;MACjBE,WAAW,EAAE;KACd;IAAA,KAEDC,aAAa,GAAG,IAAIV,GAAG,EAAE;IAAA,KAEzBW,OAAO,GAAG,CAACC,GAAG,EAACC,SAAS,KAAK;MAC3B,MAAMC,MAAM,GAAG,IAAI,CAACJ,aAAa,CAACK,GAAG,CAACH,GAAG,CAAC;MAC1C,I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
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
-
import _isArray from 'lodash/fp/isArray';
|
|
5
1
|
import React, { useReducer } from 'react';
|
|
6
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
7
|
|
|
8
8
|
const _excluded = ["value", "fallback", "children", "forwardProps"],
|
|
9
9
|
_excluded2 = ["value", "wrap", "fallback", "children", "forwardProps"];
|
|
@@ -1 +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":";;;;;;;;;;;AAIA,MAAMA,YAAY,GAAG,UAACC,OAAO,EAAEC,KAAK
|
|
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":";;;;;;;;;;;AAIA,MAAMA,YAAY,GAAG,UAACC,OAAO,EAAEC,KAAK;EAAA,IAAEC,QAAQ,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAAA,oBAAKG,KAAK,CAACC,YAAY,CAC1EP,OAAO,EACPE,QAAQ,GAAAM,aAAA,CAAAA,aAAA,KAAOR,OAAO,CAACS,KAAK,GAAIR,KAAK,IAAAO,aAAA,CAAAA,aAAA,KAAQP,KAAK,GAAID,OAAO,CAACS,KAAK,CAAC,EACpET,OAAO,CAACS,KAAK,CAACC,QAChB,CAAC;AAAA;MAEYC,mBAAmB,GAAGC,IAAA,IAAgE;EAAA,IAA9DC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAEJ,QAAQ,GAAAE,IAAA,CAARF,QAAQ;IAAAK,iBAAA,GAAAH,IAAA,CAAEI,YAAY;IAAZA,YAAY,GAAAD,iBAAA,cAAG,KAAK,GAAAA,iBAAA;IAAIN,KAAK,GAAAQ,wBAAA,CAAAL,IAAA,EAAAM,SAAA;EAC3F,oBAAOZ,KAAA,CAAAa,aAAA,CAACb,KAAK,CAACc,QAAQ;IAC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I,GAAGO,KAAA,IAAmC;EAAA,IAAjCpB,KAAK,GAAAoB,KAAA,CAALpB,KAAK;IAACH,QAAQ,GAAAuB,KAAA,CAARvB,QAAQ;IAACM,YAAY,GAAAiB,KAAA,CAAZjB,YAAY;EACxC,MAAMkB,MAAM,GAAGC,QAAA,CAAUtB,KAAK,CAAC,GAAIA,KAAK,CAACuB,OAAO,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,EAAE,CAAC,IAAIzB,KAAK,CAACS,GAAG,CAACe,CAAC,IAAIA,CAAC,CAACE,IAAI,EAAE,CAAC,GAAI1B,KAAK,CAAC0B,IAAI,EAAE;EAC9G,MAAAC,WAAA,GAAkBC,UAAU,CAAEC,CAAC,IAAKA,CAAC,GAAC,CAAC,EAAE,CAAC,CAAC;IAAAC,YAAA,GAAAC,cAAA,CAAAJ,WAAA;IAAnCK,MAAM,GAAAF,YAAA;EACd,MAAMG,OAAO,GAAGA,MAAMC,OAAO,CAACC,GAAG,CAACb,QAAA,CAAUtB,KAAK,CAAC,GAAGA,KAAK,CAACS,GAAG,CAACe,CAAC,IAAIA,CAAC,CAACS,OAAO,EAAE,CAACR,OAAO,EAAE,CAAC,GAAG,CAACzB,KAAK,CAACiC,OAAO,EAAE,CAACR,OAAO,EAAE,CAAC,CAAC,CAACW,IAAI,CAACJ,MAAM,CAAC;EACtI,OAAO7B,YAAY,GAAGjB,YAAY,CAACW,QAAQ,CAACwB,MAAM,EAAC;IAACY,OAAO;IAACD;GAAO,CAAC,EAAC7B,YAAY,CAAC,GAAGN,QAAQ,CAACwB,MAAM,EAAE;IAACY,OAAO;IAACD;GAAO,CAAC;AACzH,CAAC;;;;"}
|
package/lib/hocs/WithRef.mjs.map
CHANGED
|
@@ -1 +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
|
|
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;;;;"}
|
package/lib/hocs/consumes.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
3
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
-
import React from 'react';
|
|
4
4
|
|
|
5
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
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; }
|
|
@@ -1 +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,
|
|
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;;;;"}
|
|
@@ -1 +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":";;;
|
|
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;;;;"}
|
|
@@ -1 +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":";;;;
|
|
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;;;;"}
|
|
@@ -2,8 +2,8 @@ import 'react';
|
|
|
2
2
|
import { useLazyConstant } from './useConstant.mjs';
|
|
3
3
|
|
|
4
4
|
const WithConstant = _ref => {
|
|
5
|
-
_ref.inputs
|
|
6
|
-
|
|
5
|
+
let _ref$inputs = _ref.inputs,
|
|
6
|
+
value = _ref.value,
|
|
7
7
|
children = _ref.children;
|
|
8
8
|
const constant = useLazyConstant(value);
|
|
9
9
|
return children(constant);
|
|
@@ -1 +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","inputs","value","children","constant","useLazyConstant"],"mappings":";;;
|
|
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;;;;"}
|
|
@@ -1 +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":";;
|
|
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;;;;"}
|
|
@@ -1 +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;
|
|
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;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
1
|
import { useState, useMemo } from 'react';
|
|
3
2
|
import '@startlibs/utils';
|
|
3
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
4
|
|
|
5
5
|
const useCallState = (defaultValue, setCallback) => {
|
|
6
6
|
const _useState = useState(defaultValue),
|
|
@@ -1 +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;
|
|
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;;;;"}
|
|
@@ -1 +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":";;
|
|
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;;;;"}
|
|
@@ -1 +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
|
|
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;;;;"}
|
|
@@ -1 +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;
|
|
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;;;;"}
|
|
@@ -1 +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":";;
|
|
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;;;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
1
|
import { useState } from 'react';
|
|
2
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
3
|
import { willUseSharedState } from './willUseSharedState.mjs';
|
|
4
4
|
|
|
5
5
|
const useForceUpdate = () => {
|
|
6
6
|
const _useState = useState(0),
|
|
7
|
-
_useState2 = _slicedToArray(_useState, 2)
|
|
8
|
-
_useState2[0]
|
|
9
|
-
|
|
7
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
8
|
+
value = _useState2[0],
|
|
9
|
+
setValue = _useState2[1]; // integer state
|
|
10
10
|
return () => setValue(value => value + 1); // update the state to force render
|
|
11
11
|
};
|
|
12
12
|
const willUseForceUpdate = () => {
|
|
@@ -16,9 +16,9 @@ const willUseForceUpdate = () => {
|
|
|
16
16
|
set = _willUseSharedState2[2];
|
|
17
17
|
const useForceUpdate = () => {
|
|
18
18
|
const _useValue = useValue(0),
|
|
19
|
-
_useValue2 = _slicedToArray(_useValue, 2)
|
|
20
|
-
_useValue2[0]
|
|
21
|
-
|
|
19
|
+
_useValue2 = _slicedToArray(_useValue, 2),
|
|
20
|
+
v = _useValue2[0],
|
|
21
|
+
setV = _useValue2[1];
|
|
22
22
|
return () => setV(value => value + 1);
|
|
23
23
|
};
|
|
24
24
|
return [useForceUpdate, () => set(value => value + 1)];
|
|
@@ -1 +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":";;;;
|
|
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;;;;"}
|
|
@@ -1 +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":";;
|
|
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;;;;"}
|
|
@@ -1 +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
|
|
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;;;;"}
|
|
@@ -1 +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;
|
|
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;;;;"}
|
|
@@ -1 +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","div","withConfig","displayName","componentId","useRecycleFocus","ref","enabled","arguments","length","undefined","lastIndex","recycle","i","e","current","nextTab","querySelectorAll","console","log","focus","React","createElement","tabIndex","onFocus"],"mappings":";;;AAKA,MAAMA,QAAQ,gBAAGC,MAAM,CAACC,GAAG,CAAAC,UAAA
|
|
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","div","withConfig","displayName","componentId","useRecycleFocus","ref","enabled","arguments","length","undefined","lastIndex","recycle","i","e","current","nextTab","querySelectorAll","console","log","focus","React","createElement","tabIndex","onFocus"],"mappings":";;;AAKA,MAAMA,QAAQ,gBAAGC,MAAM,CAACC,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,2CAAqC;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,CAACvB,QAAQ;IAACwB,QAAQ,EAAE,CAAE;IAACC,OAAO,EAAEZ,OAAO,CAAC,CAAC;GAAa,CAAC,eAACS,KAAA,CAAAC,aAAA,CAACvB,QAAQ;IAACwB,QAAQ,EAAEZ,SAAS,IAAI,CAAE;IAACa,OAAO,EAAEZ,OAAO,CAAC,CAAC,CAAC;GAAa,CAAC,CAAC;AACxI;;;;"}
|
|
@@ -1 +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":";;;
|
|
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;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRef, useMemo } from 'react';
|
|
2
|
-
import { callIfFunction,
|
|
2
|
+
import { callIfFunction, _s, callIfFunctions } from '@startlibs/utils';
|
|
3
3
|
|
|
4
4
|
const isPath = path => typeof path === 'string' || typeof path === 'number' || Array.isArray(path);
|
|
5
5
|
const getter = value => path => path !== "" && isPath(path) ? _s.get(path, value) : value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRefState.mjs","sources":["../../src/hooks/useRefState.js"],"sourcesContent":["import React, {useMemo, useRef} from 'react'\nimport {_s, callIfFunction, callIfFunctions} from '@startlibs/utils'\n\nconst isPath = (path) => typeof path === 'string' || typeof path === 'number' || Array.isArray(path)\n\nconst getter = (value) => path => path !== \"\" && isPath(path) ? _s.get(path,value) : value\n\nconst uninitialized = {}\n\nexport const useRefState = (defaultValue, setCallback) => {\n const ref = useRef(uninitialized)\n if (ref.current === uninitialized) {\n ref.current = callIfFunction(defaultValue)\n }\n return useMemo(() => {\n const get = (path) => getter(ref.current)(path)\n const set = (v, config) => {\n const prev = ref.current\n ref.current = callIfFunctions(v, () => get())\n if (prev !== ref.current && (!config || !config.ignoreCallback)) {\n callIfFunction(setCallback, prev, ref.current)\n }\n }\n return {get, set}\n }, [])\n}\n"],"names":["isPath","path","Array","isArray","getter","value","_s","get","uninitialized","useRefState","defaultValue","setCallback","ref","useRef","current","callIfFunction","useMemo","set","v","config","prev","callIfFunctions","ignoreCallback"],"mappings":";;;AAGA,MAAMA,MAAM,GAAIC,IAAI,IAAK,OAAOA,IAAI,KAAK,QAAQ,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAIC,KAAK,CAACC,OAAO,CAACF,IAAI,CAAC
|
|
1
|
+
{"version":3,"file":"useRefState.mjs","sources":["../../src/hooks/useRefState.js"],"sourcesContent":["import React, {useMemo, useRef} from 'react'\nimport {_s, callIfFunction, callIfFunctions} from '@startlibs/utils'\n\nconst isPath = (path) => typeof path === 'string' || typeof path === 'number' || Array.isArray(path)\n\nconst getter = (value) => path => path !== \"\" && isPath(path) ? _s.get(path,value) : value\n\nconst uninitialized = {}\n\nexport const useRefState = (defaultValue, setCallback) => {\n const ref = useRef(uninitialized)\n if (ref.current === uninitialized) {\n ref.current = callIfFunction(defaultValue)\n }\n return useMemo(() => {\n const get = (path) => getter(ref.current)(path)\n const set = (v, config) => {\n const prev = ref.current\n ref.current = callIfFunctions(v, () => get())\n if (prev !== ref.current && (!config || !config.ignoreCallback)) {\n callIfFunction(setCallback, prev, ref.current)\n }\n }\n return {get, set}\n }, [])\n}\n"],"names":["isPath","path","Array","isArray","getter","value","_s","get","uninitialized","useRefState","defaultValue","setCallback","ref","useRef","current","callIfFunction","useMemo","set","v","config","prev","callIfFunctions","ignoreCallback"],"mappings":";;;AAGA,MAAMA,MAAM,GAAIC,IAAI,IAAK,OAAOA,IAAI,KAAK,QAAQ,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAIC,KAAK,CAACC,OAAO,CAACF,IAAI,CAAC;AAEpG,MAAMG,MAAM,GAAIC,KAAK,IAAKJ,IAAI,IAAIA,IAAI,KAAK,EAAE,IAAID,MAAM,CAACC,IAAI,CAAC,GAAGK,EAAE,CAACC,GAAG,CAACN,IAAI,EAACI,KAAK,CAAC,GAAGA,KAAK;AAE1F,MAAMG,aAAa,GAAG,EAAE;MAEXC,WAAW,GAAGA,CAACC,YAAY,EAAEC,WAAW,KAAK;EACxD,MAAMC,GAAG,GAAGC,MAAM,CAACL,aAAa,CAAC;EACjC,IAAII,GAAG,CAACE,OAAO,KAAKN,aAAa,EAAE;IACjCI,GAAG,CAACE,OAAO,GAAGC,cAAc,CAACL,YAAY,CAAC;;EAE5C,OAAOM,OAAO,CAAC,MAAM;IACnB,MAAMT,GAAG,GAAIN,IAAI,IAAKG,MAAM,CAACQ,GAAG,CAACE,OAAO,CAAC,CAACb,IAAI,CAAC;IAC/C,MAAMgB,GAAG,GAAGA,CAACC,CAAC,EAAEC,MAAM,KAAK;MACzB,MAAMC,IAAI,GAAGR,GAAG,CAACE,OAAO;MACxBF,GAAG,CAACE,OAAO,GAAGO,eAAe,CAACH,CAAC,EAAE,MAAMX,GAAG,EAAE,CAAC;MAC7C,IAAIa,IAAI,KAAKR,GAAG,CAACE,OAAO,KAAK,CAACK,MAAM,IAAI,CAACA,MAAM,CAACG,cAAc,CAAC,EAAE;QAC/DP,cAAc,CAACJ,WAAW,EAAES,IAAI,EAAER,GAAG,CAACE,OAAO,CAAC;;KAEjD;IACD,OAAO;MAACP,GAAG;MAAEU;KAAI;GAClB,EAAE,EAAE,CAAC;AACR;;;;"}
|
package/lib/hooks/useSignal.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import React, { useRef, useEffect, startTransition, useContext, useState, use, useCallback, useMemo } from 'react';
|
|
2
|
+
import { _s, callIfFunction } from '@startlibs/utils';
|
|
1
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
4
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
-
import _isPlainObject from 'lodash/fp/isPlainObject';
|
|
4
5
|
import _update from 'lodash/fp/update';
|
|
5
|
-
import _identity from 'lodash/fp/identity';
|
|
6
|
-
import _isArray from 'lodash/fp/isArray';
|
|
7
|
-
import React, { useRef, useEffect, startTransition, useContext, useState, use, useCallback, useMemo } from 'react';
|
|
8
6
|
import { useLazyConstant, useConstant } from './useConstant.mjs';
|
|
7
|
+
import _isArray from 'lodash/fp/isArray';
|
|
9
8
|
import { useForceUpdate } from './useForceUpdate.mjs';
|
|
10
|
-
import
|
|
9
|
+
import _isPlainObject from 'lodash/fp/isPlainObject';
|
|
10
|
+
import _identity from 'lodash/fp/identity';
|
|
11
11
|
|
|
12
12
|
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; }
|
|
13
13
|
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; }
|
|
@@ -123,17 +123,17 @@ const createStatefulContext = (v, defaultIsEqual) => {
|
|
|
123
123
|
};
|
|
124
124
|
const useSetValue = path => {
|
|
125
125
|
const _useCtx3 = useCtx(),
|
|
126
|
-
_useCtx4 = _slicedToArray(_useCtx3, 2)
|
|
127
|
-
_useCtx4[0]
|
|
128
|
-
|
|
126
|
+
_useCtx4 = _slicedToArray(_useCtx3, 2),
|
|
127
|
+
reg = _useCtx4[0],
|
|
128
|
+
set = _useCtx4[1];
|
|
129
129
|
return useConstant(update => set(updateStateFn(path, update)));
|
|
130
130
|
};
|
|
131
131
|
const useUtils = (path, deps) => {
|
|
132
132
|
const _useCtx5 = useCtx(),
|
|
133
|
-
_useCtx6 = _slicedToArray(_useCtx5, 3)
|
|
134
|
-
_useCtx6[0]
|
|
135
|
-
_useCtx6[1]
|
|
136
|
-
|
|
133
|
+
_useCtx6 = _slicedToArray(_useCtx5, 3),
|
|
134
|
+
reg = _useCtx6[0],
|
|
135
|
+
set = _useCtx6[1],
|
|
136
|
+
utils = _useCtx6[2];
|
|
137
137
|
return utils;
|
|
138
138
|
};
|
|
139
139
|
return [Provider, [useSelectValue, useSetValue, useUtils, useCtx]];
|
|
@@ -169,9 +169,9 @@ const createLazyStatefulContext = (toPromise, defaultIsEqual) => {
|
|
|
169
169
|
_createStatefulContex5 = _slicedToArray(_createStatefulContex4, 2),
|
|
170
170
|
Provider = _createStatefulContex5[0],
|
|
171
171
|
_createStatefulContex6 = _slicedToArray(_createStatefulContex5[1], 4),
|
|
172
|
-
useSelectValue = _createStatefulContex6[0]
|
|
173
|
-
_createStatefulContex6[1]
|
|
174
|
-
|
|
172
|
+
useSelectValue = _createStatefulContex6[0],
|
|
173
|
+
useSetValue = _createStatefulContex6[1],
|
|
174
|
+
useUtils = _createStatefulContex6[2],
|
|
175
175
|
useCtx = _createStatefulContex6[3];
|
|
176
176
|
const useSelectLazyValue = function (selector, deps) {
|
|
177
177
|
let isEqual = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultIsEqual;
|