@elliemae/ds-utilities 3.1.5-rc.9 → 3.2.0-rc.3
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/dist/cjs/hooks/useExpandState.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/props-helpers/propTypes/describe.js +0 -3
- package/dist/cjs/props-helpers/propTypes/describe.js.map +2 -2
- package/dist/cjs/props-helpers/propTypes/describeConversions.js +1 -1
- package/dist/cjs/props-helpers/propTypes/describeConversions.js.map +2 -2
- package/dist/cjs/system.js +12 -0
- package/dist/cjs/system.js.map +2 -2
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/hooks/useExpandState.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/props-helpers/propTypes/describe.js +0 -3
- package/dist/esm/props-helpers/propTypes/describe.js.map +2 -2
- package/dist/esm/props-helpers/propTypes/describeConversions.js +1 -1
- package/dist/esm/props-helpers/propTypes/describeConversions.js.map +2 -2
- package/dist/esm/system.js +12 -0
- package/dist/esm/system.js.map +2 -2
- package/dist/esm/utils.js.map +1 -1
- package/package.json +6 -6
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useExpandState.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["import { useMemo } from 'react';\nimport { isFunction } from '../utils';\nimport { useDerivedStateFromProps } from './useDerivedStateFromProps';\n\ntype ItemT = Record<string, string>;\ninterface UseExpandStateArg {\n items?: ItemT[];\n itemKey?: keyof ItemT;\n expanded?: Record<string, boolean>;\n onExpand: (item: ItemT) => void;\n onExpandChange: (nextState: Record<string, boolean>, item?: ItemT) => void;\n onExpandAll: (nextState: Record<string, boolean>) => void;\n onToggleExpand: (item: ItemT) => void;\n onCollapse: (item: ItemT) => void;\n}\n\nconst toggleStateInObject = <T,>(obj: Record<string, T>, key: string, value: T) => {\n const nextObj = { ...obj };\n if (nextObj[key]) {\n delete nextObj[key];\n } else {\n nextObj[key] = value;\n }\n return nextObj;\n};\n\nconst noop = () => null;\n\nexport const useExpandState = ({\n items = [],\n itemKey = 'id',\n expanded: expandedProp = {},\n onExpand,\n onExpandChange = noop,\n onExpandAll = noop,\n onToggleExpand,\n onCollapse,\n}: UseExpandStateArg) => {\n const [expanded, setExpanded] = useDerivedStateFromProps(expandedProp);\n\n const isExpandedAll = useMemo(() => Object.keys(expanded).length === items.length, [expanded, items]);\n\n const toggleExpandAll = (stateData = true) => {\n setExpanded(() => {\n const nextState: Record<string, boolean> = {};\n if (!isExpandedAll) {\n items.forEach((item) => {\n nextState[item[itemKey]] = stateData;\n });\n }\n onExpandChange(nextState);\n onExpandAll(nextState);\n return nextState;\n });\n };\n\n const expand = (item: ItemT, stateData = true) => {\n if (!item) return;\n if (isFunction(onExpand)) {\n onExpand(item);\n }\n setExpanded((prevState) => {\n const key = item[itemKey];\n const nextState = { ...prevState, [key]: stateData };\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n const toggleExpand = (item: ItemT, stateData = true) => {\n if (isFunction(onToggleExpand)) {\n onToggleExpand(item);\n }\n setExpanded((prevState) => {\n const key = item[itemKey];\n const nextState = toggleStateInObject(prevState, key, stateData);\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n const collapse = (item: ItemT) => {\n if (isFunction(onCollapse)) {\n onCollapse(item);\n }\n setExpanded((prevState) => {\n const nextState = { ...prevState };\n delete nextState[item[itemKey]];\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n return {\n state: { expanded, isExpandedAll },\n actions: {\n expand,\n toggleExpandAll,\n toggleExpand,\n collapse,\n },\n setExpanded,\n };\n};\n\nexport default useExpandState;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;A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IACrB;AACA,gBAAY,CAAC,cAAc;AACzB,YAAM,MAAM,KAAK;AACjB,YAAM,YAAY,oBAAoB,WAAW,KAAK,SAAS;AAC/D,qBAAe,WAAW,IAAI;AAC9B,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,CAAC,SAAgB;AAChC,QAAI,6BAAW,UAAU,GAAG;AAC1B,iBAAW,IAAI;AAAA,IACjB;AACA,gBAAY,CAAC,cAAc;AACzB,YAAM,YAAY,mBAAK;AACvB,aAAO,UAAU,KAAK;AACtB,qBAAe,WAAW,IAAI;AAC9B,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,OAAO,EAAE,UAAU,cAAc;AAAA,IACjC,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAEA,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -90,6 +90,7 @@ __export(src_exports, {
|
|
|
90
90
|
runAll: () => import_utils.runAll,
|
|
91
91
|
safeCall: () => import_utils.safeCall,
|
|
92
92
|
set: () => import_utils.set,
|
|
93
|
+
setMultipleRefs: () => import_system.setMultipleRefs,
|
|
93
94
|
setRef: () => import_system.setRef,
|
|
94
95
|
sortBy: () => import_utils.sortBy,
|
|
95
96
|
startsWith: () => import_operators.startsWith,
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["export { default as getComponentFromProps } from './getComponentFromProps';\nexport { default as onClickHandlerForNonInteractiveElements } from './onClickHandlerForNonInteractiveElements';\nexport { capitalize } from './capitalize';\nexport { getObjectValuesToArray, getObjectKeysToArray } from './objectUtilities';\nexport {\n checkNotEmpty,\n checkEmpty,\n greaterThan,\n validDate,\n equal,\n notEqual,\n isNull,\n isNotNull,\n isIn,\n isNotIn,\n greaterThanOrEquals,\n lessThanOrEquals,\n startsWith,\n contains,\n} from './operators';\nexport {\n cx,\n runAll,\n hashArray,\n safeCall,\n removeUndefinedProperties,\n isObject,\n curry,\n arrayMove,\n uniq,\n filter,\n uniqBy,\n groupBy,\n property,\n get,\n set,\n cloneDeep,\n debounce,\n findIndex,\n isEmpty,\n isString,\n isEqual,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n pull,\n sortBy,\n sumBy,\n transform,\n isFunction,\n range,\n parseInt,\n padStart,\n isNaN,\n values,\n throttle,\n toggleInObject,\n toggleInArray,\n pick,\n pickBy,\n differenceBy,\n differenceWith,\n addOrRemove,\n isEqualWith,\n isBoolean,\n} from './utils';\nexport { setRef, mergeRefs, logger } from './system';\nexport {\n useMeasure,\n useForceUpdate,\n useOnClickOutside,\n useExecutionTimer,\n useExpandState,\n useHotkeys,\n useHoverHandlersDelay,\n useResizeObserver,\n useShouldRecalculate,\n useWindowScrollerList,\n usePrevious,\n useCancellableDelayedCallback,\n useDerivedStateFromProps,\n useOnElementResize,\n useIsShowingEllipsis,\n useCallbackAfterRender,\n useFocusTrap,\n UseFocusTrapWithSchema,\n useIsMobile,\n useOnBlurOut,\n UseOnBlurOutWithSchema,\n useOnFirstFocusIn,\n UseOnFirstFocusInWithSchema,\n useOnSpecificFocus,\n UseOnSpecificFocusWithSchema,\n} from './hooks';\nexport { getVisibleTimeByFormat, addLeadingZeros } from './timeUtils';\nexport { compose } from './compose';\nexport { DOCUMENT, WINDOW } from './platform';\nexport { isDOMTypeElement } from './reactTypesUtility';\nexport { isRequired, isGreaterThan, isValidDate } from './validations';\n\n// TODO -- REMOVE WHEN READY\nexport * from './deprecated';\nexport * from './props-helpers';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mCAAiD;AACjD,qDAAmE;AACnE,wBAA2B;AAC3B,6BAA6D;AAC7D,uBAeO;AACP,mBA+CO;AACP,
|
|
4
|
+
"sourcesContent": ["export { default as getComponentFromProps } from './getComponentFromProps';\nexport { default as onClickHandlerForNonInteractiveElements } from './onClickHandlerForNonInteractiveElements';\nexport { capitalize } from './capitalize';\nexport { getObjectValuesToArray, getObjectKeysToArray } from './objectUtilities';\nexport {\n checkNotEmpty,\n checkEmpty,\n greaterThan,\n validDate,\n equal,\n notEqual,\n isNull,\n isNotNull,\n isIn,\n isNotIn,\n greaterThanOrEquals,\n lessThanOrEquals,\n startsWith,\n contains,\n} from './operators';\nexport {\n cx,\n runAll,\n hashArray,\n safeCall,\n removeUndefinedProperties,\n isObject,\n curry,\n arrayMove,\n uniq,\n filter,\n uniqBy,\n groupBy,\n property,\n get,\n set,\n cloneDeep,\n debounce,\n findIndex,\n isEmpty,\n isString,\n isEqual,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n pull,\n sortBy,\n sumBy,\n transform,\n isFunction,\n range,\n parseInt,\n padStart,\n isNaN,\n values,\n throttle,\n toggleInObject,\n toggleInArray,\n pick,\n pickBy,\n differenceBy,\n differenceWith,\n addOrRemove,\n isEqualWith,\n isBoolean,\n} from './utils';\nexport { setRef, mergeRefs, setMultipleRefs, logger } from './system';\nexport {\n useMeasure,\n useForceUpdate,\n useOnClickOutside,\n useExecutionTimer,\n useExpandState,\n useHotkeys,\n useHoverHandlersDelay,\n useResizeObserver,\n useShouldRecalculate,\n useWindowScrollerList,\n usePrevious,\n useCancellableDelayedCallback,\n useDerivedStateFromProps,\n useOnElementResize,\n useIsShowingEllipsis,\n useCallbackAfterRender,\n useFocusTrap,\n UseFocusTrapWithSchema,\n useIsMobile,\n useOnBlurOut,\n UseOnBlurOutWithSchema,\n useOnFirstFocusIn,\n UseOnFirstFocusInWithSchema,\n useOnSpecificFocus,\n UseOnSpecificFocusWithSchema,\n} from './hooks';\nexport { getVisibleTimeByFormat, addLeadingZeros } from './timeUtils';\nexport { compose } from './compose';\nexport { DOCUMENT, WINDOW } from './platform';\nexport { isDOMTypeElement } from './reactTypesUtility';\nexport { isRequired, isGreaterThan, isValidDate } from './validations';\n\n// TODO -- REMOVE WHEN READY\nexport * from './deprecated';\nexport * from './props-helpers';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mCAAiD;AACjD,qDAAmE;AACnE,wBAA2B;AAC3B,6BAA6D;AAC7D,uBAeO;AACP,mBA+CO;AACP,oBAA2D;AAC3D,mBA0BO;AACP,uBAAwD;AACxD,qBAAwB;AACxB,sBAAiC;AACjC,+BAAiC;AACjC,yBAAuD;AAGvD,wBAAc,yBAvGd;AAwGA,wBAAc,4BAxGd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -59,9 +59,6 @@ function describe(ComponentInstance) {
|
|
|
59
59
|
let realPropType;
|
|
60
60
|
documentation.propTypes[name] = propType;
|
|
61
61
|
realPropType = (0, import_describeConversions.convertPropType)(propType);
|
|
62
|
-
if (value[name].reactDesc.required) {
|
|
63
|
-
realPropType = realPropType.isRequired;
|
|
64
|
-
}
|
|
65
62
|
DocumentedComponent.propTypesValue[name] = realPropType;
|
|
66
63
|
return propType;
|
|
67
64
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/props-helpers/propTypes/describe.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable react/forbid-foreign-prop-types */\nimport { Requireable, Validator } from 'prop-types';\nimport React from 'react';\nimport { convertPropType } from './describeConversions';\nimport descToTypescript from './toTypescript';\nimport { ReactDescT, Hook, ComponentDocumentation, DocumentedReactComponent } from './types';\n\nexport default function describe<C, R>(ComponentInstance: React.ComponentType<C> | Hook<C, R>) {\n if (!ComponentInstance) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: ComponentDocumentation = {\n propTypes: {},\n };\n\n const DocumentedComponent = ComponentInstance as DocumentedReactComponent<C>;\n\n const addDocumentationProp = <T extends keyof ComponentDocumentation>(propName: T) => {\n const func = (value: ComponentDocumentation[T]): DocumentedReactComponent<C> => {\n documentation[propName] = value;\n return DocumentedComponent;\n };\n return func;\n };\n\n DocumentedComponent.availableAt = addDocumentationProp('availableAt');\n DocumentedComponent.description = addDocumentationProp('description');\n DocumentedComponent.details = addDocumentationProp('details');\n DocumentedComponent.deprecated = addDocumentationProp('deprecated');\n DocumentedComponent.usage = addDocumentationProp('usage');\n DocumentedComponent.intrinsicElement = addDocumentationProp('intrinsicElement');\n\n DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);\n\n Object.defineProperty(DocumentedComponent, 'propTypes', {\n get: () => DocumentedComponent.propTypesValue,\n set: (value: Record<string, ReactDescT>) => {\n if (!DocumentedComponent.propTypesValue) {\n DocumentedComponent.propTypesValue = {};\n }\n\n Object.keys(value).forEach((name) => {\n const propType: ReactDescT = value[name];\n let realPropType: Requireable<unknown> | Validator<unknown>;\n documentation.propTypes[name] = propType;\n realPropType = convertPropType(propType);\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,iCAAgC;AAChC,0BAA6B;AAGd,kBAAwB,mBAAwD;AAC7F,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,QAAM,gBAAwC;AAAA,IAC5C,WAAW,CAAC;AAAA,EACd;AAEA,QAAM,sBAAsB;AAE5B,QAAM,uBAAuB,CAAyC,aAAgB;AACpF,UAAM,OAAO,CAAC,UAAkE;AAC9E,oBAAc,YAAY;AAC1B,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAEA,sBAAoB,cAAc,qBAAqB,aAAa;AACpE,sBAAoB,cAAc,qBAAqB,aAAa;AACpE,sBAAoB,UAAU,qBAAqB,SAAS;AAC5D,sBAAoB,aAAa,qBAAqB,YAAY;AAClE,sBAAoB,QAAQ,qBAAqB,OAAO;AACxD,sBAAoB,mBAAmB,qBAAqB,kBAAkB;AAE9E,sBAAoB,eAAe,MAAM,iCAAiB,mBAAmB,aAAa;AAE1F,SAAO,eAAe,qBAAqB,aAAa;AAAA,IACtD,KAAK,MAAM,oBAAoB;AAAA,IAC/B,KAAK,CAAC,UAAsC;AAC1C,UAAI,CAAC,oBAAoB,gBAAgB;AACvC,4BAAoB,iBAAiB,CAAC;AAAA,MACxC;AAEA,aAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,SAAS;AACnC,cAAM,WAAuB,MAAM;AACnC,YAAI;AACJ,sBAAc,UAAU,QAAQ;AAChC,uBAAe,gDAAgB,QAAQ;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/forbid-foreign-prop-types */\nimport { Requireable, Validator } from 'prop-types';\nimport React from 'react';\nimport { convertPropType } from './describeConversions';\nimport descToTypescript from './toTypescript';\nimport { ReactDescT, Hook, ComponentDocumentation, DocumentedReactComponent } from './types';\n\nexport default function describe<C, R>(ComponentInstance: React.ComponentType<C> | Hook<C, R>) {\n if (!ComponentInstance) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: ComponentDocumentation = {\n propTypes: {},\n };\n\n const DocumentedComponent = ComponentInstance as DocumentedReactComponent<C>;\n\n const addDocumentationProp = <T extends keyof ComponentDocumentation>(propName: T) => {\n const func = (value: ComponentDocumentation[T]): DocumentedReactComponent<C> => {\n documentation[propName] = value;\n return DocumentedComponent;\n };\n return func;\n };\n\n DocumentedComponent.availableAt = addDocumentationProp('availableAt');\n DocumentedComponent.description = addDocumentationProp('description');\n DocumentedComponent.details = addDocumentationProp('details');\n DocumentedComponent.deprecated = addDocumentationProp('deprecated');\n DocumentedComponent.usage = addDocumentationProp('usage');\n DocumentedComponent.intrinsicElement = addDocumentationProp('intrinsicElement');\n\n DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);\n\n Object.defineProperty(DocumentedComponent, 'propTypes', {\n get: () => DocumentedComponent.propTypesValue,\n set: (value: Record<string, ReactDescT>) => {\n if (!DocumentedComponent.propTypesValue) {\n DocumentedComponent.propTypesValue = {};\n }\n\n Object.keys(value).forEach((name) => {\n const propType: ReactDescT = value[name];\n let realPropType: Requireable<unknown> | Validator<unknown>;\n documentation.propTypes[name] = propType;\n realPropType = convertPropType(propType);\n // We don't need to rely on the isRequired from prop-types package\n // So no need to invoke (realPropType).isRequired if our own proptype is required\n // Validation will handle that case for us\n DocumentedComponent.propTypesValue[name] = realPropType as Validator<unknown>;\n return propType;\n });\n },\n enumerable: true,\n configurable: true,\n });\n\n return DocumentedComponent;\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,iCAAgC;AAChC,0BAA6B;AAGd,kBAAwB,mBAAwD;AAC7F,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,QAAM,gBAAwC;AAAA,IAC5C,WAAW,CAAC;AAAA,EACd;AAEA,QAAM,sBAAsB;AAE5B,QAAM,uBAAuB,CAAyC,aAAgB;AACpF,UAAM,OAAO,CAAC,UAAkE;AAC9E,oBAAc,YAAY;AAC1B,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAEA,sBAAoB,cAAc,qBAAqB,aAAa;AACpE,sBAAoB,cAAc,qBAAqB,aAAa;AACpE,sBAAoB,UAAU,qBAAqB,SAAS;AAC5D,sBAAoB,aAAa,qBAAqB,YAAY;AAClE,sBAAoB,QAAQ,qBAAqB,OAAO;AACxD,sBAAoB,mBAAmB,qBAAqB,kBAAkB;AAE9E,sBAAoB,eAAe,MAAM,iCAAiB,mBAAmB,aAAa;AAE1F,SAAO,eAAe,qBAAqB,aAAa;AAAA,IACtD,KAAK,MAAM,oBAAoB;AAAA,IAC/B,KAAK,CAAC,UAAsC;AAC1C,UAAI,CAAC,oBAAoB,gBAAgB;AACvC,4BAAoB,iBAAiB,CAAC;AAAA,MACxC;AAEA,aAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,SAAS;AACnC,cAAM,WAAuB,MAAM;AACnC,YAAI;AACJ,sBAAc,UAAU,QAAQ;AAChC,uBAAe,gDAAgB,QAAQ;AAIvC,4BAAoB,eAAe,QAAQ;AAC3C,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,IACA,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AAED,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -33,7 +33,7 @@ const enrichPropType = (propType, reactDesc) => {
|
|
|
33
33
|
const { version = "", message = "" } = reactDesc.deprecated;
|
|
34
34
|
const error = `Warning: "${propName}" property of "${componentName}" will be deprecated in version: ${version}.
|
|
35
35
|
${message}`;
|
|
36
|
-
console.
|
|
36
|
+
console.warn(error);
|
|
37
37
|
reactDesc.warned = true;
|
|
38
38
|
}
|
|
39
39
|
return propType(props, propName, componentName, ...rest);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/props-helpers/propTypes/describeConversions.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-params */\n/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport PropTypes, { ValidationMap, Requireable } from 'prop-types';\nimport { tupleValidator } from './customPropTypes';\nimport {\n hasArguments,\n isArrayOf,\n isExact,\n isInstanceOf,\n isObjectOf,\n isOneOf,\n isOneOfType,\n isShape,\n} from './describeGuards';\nimport { ReactDescT, ReactDescObjT, InstanceOfT, OneOfT, ObjectOfT, ExactT } from './types';\n\nconst enrichPropType = (propType: Requireable<unknown>, reactDesc: ReactDescObjT): Requireable<unknown> => {\n const func = (props: Record<string, unknown>, propName: string, componentName: string, ...rest: [string, string]) => {\n if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {\n const { version = '', message = '' } = reactDesc.deprecated;\n const error = `Warning: \"${propName}\" property of \"${componentName}\" will be deprecated in version: ${version}.\\n${message}`;\n console.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,wBAAsD;AACtD,6BAA+B;AAC/B,4BASO;AAGP,MAAM,iBAAiB,CAAC,UAAgC,cAAmD;AACzG,QAAM,OAAO,CAAC,OAAgC,UAAkB,kBAA0B,SAA2B;AACnH,QAAI,aAAa,UAAU,cAAc,YAAY,SAAS,CAAC,UAAU,QAAQ;AAC/E,YAAM,EAAE,UAAU,IAAI,UAAU,OAAO,UAAU;AACjD,YAAM,QAAQ,aAAa,0BAA0B,iDAAiD;AAAA,EAAa;AACnH,cAAQ,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-params */\n/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport PropTypes, { ValidationMap, Requireable } from 'prop-types';\nimport { tupleValidator } from './customPropTypes';\nimport {\n hasArguments,\n isArrayOf,\n isExact,\n isInstanceOf,\n isObjectOf,\n isOneOf,\n isOneOfType,\n isShape,\n} from './describeGuards';\nimport { ReactDescT, ReactDescObjT, InstanceOfT, OneOfT, ObjectOfT, ExactT } from './types';\n\nconst enrichPropType = (propType: Requireable<unknown>, reactDesc: ReactDescObjT): Requireable<unknown> => {\n const func = (props: Record<string, unknown>, propName: string, componentName: string, ...rest: [string, string]) => {\n if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {\n const { version = '', message = '' } = reactDesc.deprecated;\n const error = `Warning: \"${propName}\" property of \"${componentName}\" will be deprecated in version: ${version}.\\n${message}`;\n console.warn(error);\n reactDesc.warned = true;\n }\n return propType(props, propName, componentName, ...rest);\n };\n Object.defineProperty(\n func,\n 'isRequired',\n Object.getOwnPropertyDescriptor(propType, 'isRequired') as PropertyDescriptor,\n );\n return func as Requireable<unknown>;\n};\n\nconst convertArray = (array: ReactDescT[]): Requireable<unknown>[] => array.map((type) => convertPropType(type));\n\nconst convertShape = (_shape: Record<string, ReactDescT>): ValidationMap<Record<string, unknown>> => {\n const result: ValidationMap<Record<string, unknown>> = {};\n Object.keys(_shape).forEach((key) => {\n result[key] = convertPropType(_shape[key]);\n });\n return result;\n};\n\nexport const convertPropType = (propType: ReactDescT): Requireable<unknown> => {\n if (!propType || !propType.type) {\n throw new Error(`react-desc: unknown error -- proptype is not well defined`);\n }\n\n // DimSum PropTypes conversion\n if (propType.type === 'tuple') {\n return enrichPropType(\n PropTypes.arrayOf(tupleValidator(convertArray(propType.args as ReactDescT[]))),\n propType.reactDesc,\n );\n }\n\n // Default PropType conversion\n const realPropType = PropTypes[propType.type];\n\n if (!realPropType) {\n throw new Error(`react-desc: unknown type ${propType.type}`);\n }\n\n if (hasArguments(propType, realPropType)) {\n if (isOneOfType(propType, realPropType)) {\n return enrichPropType(realPropType(convertArray(propType.args as ReactDescT[])), propType.reactDesc);\n }\n if (isArrayOf(propType, realPropType)) {\n return enrichPropType(realPropType(convertPropType(propType.args as ReactDescT)), propType.reactDesc);\n }\n if (isShape(propType, realPropType)) {\n return enrichPropType(\n realPropType(convertShape(propType.args as Record<string, ReactDescT>)),\n propType.reactDesc,\n );\n }\n if (isInstanceOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<InstanceOfT>[0]), propType.reactDesc);\n }\n if (isOneOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<OneOfT>[0]), propType.reactDesc);\n }\n if (isObjectOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<ObjectOfT>[0]), propType.reactDesc);\n }\n if (isExact(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<ExactT>[0]), propType.reactDesc);\n }\n throw new Error(`react-desc: unknown error -- proptype with args is not matching`);\n }\n\n return enrichPropType(realPropType, propType.reactDesc);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,wBAAsD;AACtD,6BAA+B;AAC/B,4BASO;AAGP,MAAM,iBAAiB,CAAC,UAAgC,cAAmD;AACzG,QAAM,OAAO,CAAC,OAAgC,UAAkB,kBAA0B,SAA2B;AACnH,QAAI,aAAa,UAAU,cAAc,YAAY,SAAS,CAAC,UAAU,QAAQ;AAC/E,YAAM,EAAE,UAAU,IAAI,UAAU,OAAO,UAAU;AACjD,YAAM,QAAQ,aAAa,0BAA0B,iDAAiD;AAAA,EAAa;AACnH,cAAQ,KAAK,KAAK;AAClB,gBAAU,SAAS;AAAA,IACrB;AACA,WAAO,SAAS,OAAO,UAAU,eAAe,GAAG,IAAI;AAAA,EACzD;AACA,SAAO,eACL,MACA,cACA,OAAO,yBAAyB,UAAU,YAAY,CACxD;AACA,SAAO;AACT;AAEA,MAAM,eAAe,CAAC,UAAgD,MAAM,IAAI,CAAC,SAAS,gBAAgB,IAAI,CAAC;AAE/G,MAAM,eAAe,CAAC,WAA+E;AACnG,QAAM,SAAiD,CAAC;AACxD,SAAO,KAAK,MAAM,EAAE,QAAQ,CAAC,QAAQ;AACnC,WAAO,OAAO,gBAAgB,OAAO,IAAI;AAAA,EAC3C,CAAC;AACD,SAAO;AACT;AAEO,MAAM,kBAAkB,CAAC,aAA+C;AAC7E,MAAI,CAAC,YAAY,CAAC,SAAS,MAAM;AAC/B,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AAGA,MAAI,SAAS,SAAS,SAAS;AAC7B,WAAO,eACL,0BAAU,QAAQ,2CAAe,aAAa,SAAS,IAAoB,CAAC,CAAC,GAC7E,SAAS,SACX;AAAA,EACF;AAGA,QAAM,eAAe,0BAAU,SAAS;AAExC,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,MAAM,4BAA4B,SAAS,MAAM;AAAA,EAC7D;AAEA,MAAI,wCAAa,UAAU,YAAY,GAAG;AACxC,QAAI,uCAAY,UAAU,YAAY,GAAG;AACvC,aAAO,eAAe,aAAa,aAAa,SAAS,IAAoB,CAAC,GAAG,SAAS,SAAS;AAAA,IACrG;AACA,QAAI,qCAAU,UAAU,YAAY,GAAG;AACrC,aAAO,eAAe,aAAa,gBAAgB,SAAS,IAAkB,CAAC,GAAG,SAAS,SAAS;AAAA,IACtG;AACA,QAAI,mCAAQ,UAAU,YAAY,GAAG;AACnC,aAAO,eACL,aAAa,aAAa,SAAS,IAAkC,CAAC,GACtE,SAAS,SACX;AAAA,IACF;AACA,QAAI,wCAAa,UAAU,YAAY,GAAG;AACxC,aAAO,eAAe,aAAa,SAAS,IAAkC,GAAG,SAAS,SAAS;AAAA,IACrG;AACA,QAAI,mCAAQ,UAAU,YAAY,GAAG;AACnC,aAAO,eAAe,aAAa,SAAS,IAA6B,GAAG,SAAS,SAAS;AAAA,IAChG;AACA,QAAI,sCAAW,UAAU,YAAY,GAAG;AACtC,aAAO,eAAe,aAAa,SAAS,IAAgC,GAAG,SAAS,SAAS;AAAA,IACnG;AACA,QAAI,mCAAQ,UAAU,YAAY,GAAG;AACnC,aAAO,eAAe,aAAa,SAAS,IAA6B,GAAG,SAAS,SAAS;AAAA,IAChG;AACA,UAAM,IAAI,MAAM,iEAAiE;AAAA,EACnF;AAEA,SAAO,eAAe,cAAc,SAAS,SAAS;AACxD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/system.js
CHANGED
|
@@ -22,6 +22,7 @@ var system_exports = {};
|
|
|
22
22
|
__export(system_exports, {
|
|
23
23
|
logger: () => logger,
|
|
24
24
|
mergeRefs: () => mergeRefs,
|
|
25
|
+
setMultipleRefs: () => setMultipleRefs,
|
|
25
26
|
setRef: () => setRef
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(system_exports);
|
|
@@ -42,6 +43,17 @@ const mergeRefs = (...refs) => {
|
|
|
42
43
|
};
|
|
43
44
|
return mergeRefsFunc;
|
|
44
45
|
};
|
|
46
|
+
function setMultipleRefs(refs) {
|
|
47
|
+
return (value) => {
|
|
48
|
+
refs.forEach((ref) => {
|
|
49
|
+
if (typeof ref === "function") {
|
|
50
|
+
ref(value);
|
|
51
|
+
} else if (ref != null) {
|
|
52
|
+
ref.current = value;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}
|
|
45
57
|
function logger(...args) {
|
|
46
58
|
console.log(...args);
|
|
47
59
|
}
|
package/dist/cjs/system.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/system.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { isFunction } from './utils';\n\ntype AnyRef<T extends HTMLElement> = React.MutableRefObject<T> | ((_ref: T) => void);\n\nexport const setRef = <T extends HTMLElement>(ref: AnyRef<T>, value: T) => {\n if (isFunction(ref)) {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n};\n\nexport const mergeRefs = <T extends HTMLElement>(...refs: AnyRef<T>[]) => {\n const mergeRefsFunc = (node: T) => {\n if (!node) return;\n refs.forEach((ref) => setRef(ref, node));\n };\n return mergeRefsFunc;\n};\n\nexport function logger(...args: unknown[]) {\n // eslint-disable-next-line no-console\n console.log(...args);\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA2B;AAIpB,MAAM,SAAS,CAAwB,KAAgB,UAAa;AACzE,MAAI,6BAAW,GAAG,GAAG;AACnB,QAAI,KAAK;AAAA,EACX,WAAW,KAAK;AACd,QAAI,UAAU;AAAA,EAChB;AACF;AAEO,MAAM,YAAY,IAA2B,SAAsB;AACxE,QAAM,gBAAgB,CAAC,SAAY;AACjC,QAAI,CAAC;AAAM;AACX,SAAK,QAAQ,CAAC,QAAQ,OAAO,KAAK,IAAI,CAAC;AAAA,EACzC;AACA,SAAO;AACT;AAEO,mBAAmB,MAAiB;AAEzC,UAAQ,IAAI,GAAG,IAAI;AACrB;",
|
|
4
|
+
"sourcesContent": ["import { isFunction } from './utils';\n\ntype AnyRef<T extends HTMLElement> = React.MutableRefObject<T> | ((_ref: T) => void);\n\nexport const setRef = <T extends HTMLElement>(ref: AnyRef<T>, value: T) => {\n if (isFunction(ref)) {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n};\n\nexport const mergeRefs = <T extends HTMLElement>(...refs: AnyRef<T>[]) => {\n const mergeRefsFunc = (node: T) => {\n if (!node) return;\n refs.forEach((ref) => setRef(ref, node));\n };\n return mergeRefsFunc;\n};\n\nexport function setMultipleRefs<T = unknown>(\n refs: Array<React.RefObject<T> | React.LegacyRef<T>>,\n): React.RefCallback<T> {\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref != null) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n });\n };\n}\n\nexport function logger(...args: unknown[]) {\n // eslint-disable-next-line no-console\n console.log(...args);\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA2B;AAIpB,MAAM,SAAS,CAAwB,KAAgB,UAAa;AACzE,MAAI,6BAAW,GAAG,GAAG;AACnB,QAAI,KAAK;AAAA,EACX,WAAW,KAAK;AACd,QAAI,UAAU;AAAA,EAChB;AACF;AAEO,MAAM,YAAY,IAA2B,SAAsB;AACxE,QAAM,gBAAgB,CAAC,SAAY;AACjC,QAAI,CAAC;AAAM;AACX,SAAK,QAAQ,CAAC,QAAQ,OAAO,KAAK,IAAI,CAAC;AAAA,EACzC;AACA,SAAO;AACT;AAEO,yBACL,MACsB;AACtB,SAAO,CAAC,UAAU;AAChB,SAAK,QAAQ,CAAC,QAAQ;AACpB,UAAI,OAAO,QAAQ,YAAY;AAC7B,YAAI,KAAK;AAAA,MACX,WAAW,OAAO,MAAM;AACtB,QAAC,IAAyC,UAAU;AAAA,MACtD;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,mBAAmB,MAAiB;AAEzC,UAAQ,IAAI,GAAG,IAAI;AACrB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/utils.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable no-param-reassign */\n/* eslint-disable max-lines */\n/**\n * commonly used functions\n * Add a level of indirection to lodash so we can replace\n * it if desired, while keeping function names the same\n */\n// TODO: Import individual packages vs referencing all of lodash\nimport {\n cloneDeep,\n filter,\n debounce,\n findIndex,\n isEmpty,\n isString,\n isEqual,\n noop,\n omit,\n orderBy,\n pull,\n sumBy,\n maxBy,\n meanBy,\n sortBy,\n transform,\n isFunction,\n uniq,\n uniqBy,\n groupBy,\n property,\n get,\n set,\n range,\n parseInt,\n padStart,\n isNaN,\n values,\n throttle,\n pick,\n pickBy,\n differenceBy,\n differenceWith,\n isEqualWith,\n curry,\n isObject,\n isBoolean,\n} from 'lodash';\n\ntype UnknownFunctionT = (...args: unknown[]) => unknown;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ValidKeys = string | number | symbol;\n\n/**\n * Concatenates classNames from arguments\n *\n * @param {...any} classnames classnames you want to join\n * @returns {string} All classnames string concatenated\n */\nexport const cx = (...classnames: string[]): string => classnames.reduce((result, cn) => `${result} ${cn || ''}`, '');\n\n// if entry exists, remove it, if not, add it\nconst toggleInObject = (obj: Record<string, unknown>, key: string, value: unknown) =>\n obj[key] !== undefined ? omit(obj, [key]) : { ...obj, [key]: value };\n\nconst toggleInArray = (array: unknown[], value: unknown) => (array.indexOf(value) === -1 ? [value] : []);\n\nconst arrayMoveMutate = (array: unknown[], from: number, to: number) => {\n array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);\n};\n\nconst arrayMove = <T,>(array: T[], from: number, to: number): T[] => {\n array = array.slice();\n arrayMoveMutate(array, from, to);\n return array;\n};\n\nconst accessorDefault = <T,>(item: T): T => item;\n\nconst addOrRemove = <T,>(array: T[], item: T, accessor = accessorDefault): T[] => {\n const index = array.findIndex((iItem) => accessor(iItem) === accessor(item));\n\n if (index !== -1) {\n const nextArray = cloneDeep(array);\n nextArray.splice(index, 1);\n return nextArray;\n }\n\n return [...array, item];\n};\n\nexport function runAll(...fns: (UnknownFunctionT | UnknownFunctionT[])[]) {\n return (...args: unknown[]) =>\n fns.forEach((fn) => {\n if (Array.isArray(fn)) runAll(fn);\n if (isFunction(fn)) fn(...args);\n });\n}\n\nexport function hashArray(arr: (ValidKeys | Record<string, ValidKeys>)[], fieldName?: string) {\n return arr.reduce<Record<ValidKeys, boolean>>((result, item) => {\n const newKey: ValidKeys = fieldName && typeof item === 'object' ? item[fieldName] : (item as ValidKeys);\n return {\n ...result,\n [newKey]: true,\n };\n }, {});\n}\n\nexport function safeCall(fun: unknown, ...args: unknown[]) {\n if (isFunction(fun)) {\n fun(...args);\n }\n}\n\nexport const removeUndefinedProperties = (obj: Record<string, unknown>) => {\n const cleanObject = { ...obj };\n Object.keys(obj).forEach((key) => cleanObject[key] === undefined && delete cleanObject[key]);\n return cleanObject;\n};\n\nexport default {};\nexport {\n isObject,\n curry,\n arrayMove,\n uniq,\n filter,\n uniqBy,\n groupBy,\n property,\n get,\n set,\n cloneDeep,\n debounce,\n findIndex,\n isEmpty,\n isString,\n isEqual,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n pull,\n sortBy,\n sumBy,\n transform,\n isFunction,\n range,\n parseInt,\n padStart,\n isNaN,\n values,\n throttle,\n toggleInObject,\n toggleInArray,\n pick,\n pickBy,\n differenceBy,\n differenceWith,\n addOrRemove,\n isEqualWith,\n isBoolean,\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADQvB,oBAsCO;AAYA,MAAM,KAAK,IAAI,eAAiC,WAAW,OAAO,CAAC,QAAQ,OAAO,GAAG,UAAU,MAAM,MAAM,EAAE;AAGpH,MAAM,iBAAiB,CAAC,KAA8B,KAAa,UACjE,IAAI,SAAS,SAAY,wBAAK,KAAK,CAAC,GAAG,CAAC,IAAI,iCAAK,MAAL,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAO,IAAI,OAAmC,CAAC,QAAQ,SAAS;AAC9D,UAAM,SAAoB,aAAa,OAAO,SAAS,WAAW,KAAK,aAAc;AACrF,WAAO,iCACF,SADE;AAAA,MAEL,CAAC,SAAS;AAAA,IACZ;AAAA,EACF,GAAG,CAAC,CAAC;AACP;AAEO,kBAAkB,QAAiB,MAAiB;AACzD,MAAI,8BAAW,GAAG,GAAG;AACnB,QAAI,GAAG,IAAI;AAAA,EACb;AACF;AAEO,MAAM,4BAA4B,CAAC,QAAiC;AACzE,QAAM,cAAc,mBAAK;AACzB,SAAO,KAAK,GAAG,EAAE,QAAQ,CAAC,QAAQ,YAAY,SAAS,UAAa,OAAO,YAAY,IAAI;AAC3F,SAAO;AACT;AAEA,IAAO,gBAAQ,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useExpandState.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport { isFunction } from '../utils';\nimport { useDerivedStateFromProps } from './useDerivedStateFromProps';\n\ntype ItemT = Record<string, string>;\ninterface UseExpandStateArg {\n items?: ItemT[];\n itemKey?: keyof ItemT;\n expanded?: Record<string, boolean>;\n onExpand: (item: ItemT) => void;\n onExpandChange: (nextState: Record<string, boolean>, item?: ItemT) => void;\n onExpandAll: (nextState: Record<string, boolean>) => void;\n onToggleExpand: (item: ItemT) => void;\n onCollapse: (item: ItemT) => void;\n}\n\nconst toggleStateInObject = <T,>(obj: Record<string, T>, key: string, value: T) => {\n const nextObj = { ...obj };\n if (nextObj[key]) {\n delete nextObj[key];\n } else {\n nextObj[key] = value;\n }\n return nextObj;\n};\n\nconst noop = () => null;\n\nexport const useExpandState = ({\n items = [],\n itemKey = 'id',\n expanded: expandedProp = {},\n onExpand,\n onExpandChange = noop,\n onExpandAll = noop,\n onToggleExpand,\n onCollapse,\n}: UseExpandStateArg) => {\n const [expanded, setExpanded] = useDerivedStateFromProps(expandedProp);\n\n const isExpandedAll = useMemo(() => Object.keys(expanded).length === items.length, [expanded, items]);\n\n const toggleExpandAll = (stateData = true) => {\n setExpanded(() => {\n const nextState: Record<string, boolean> = {};\n if (!isExpandedAll) {\n items.forEach((item) => {\n nextState[item[itemKey]] = stateData;\n });\n }\n onExpandChange(nextState);\n onExpandAll(nextState);\n return nextState;\n });\n };\n\n const expand = (item: ItemT, stateData = true) => {\n if (!item) return;\n if (isFunction(onExpand)) {\n onExpand(item);\n }\n setExpanded((prevState) => {\n const key = item[itemKey];\n const nextState = { ...prevState, [key]: stateData };\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n const toggleExpand = (item: ItemT, stateData = true) => {\n if (isFunction(onToggleExpand)) {\n onToggleExpand(item);\n }\n setExpanded((prevState) => {\n const key = item[itemKey];\n const nextState = toggleStateInObject(prevState, key, stateData);\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n const collapse = (item: ItemT) => {\n if (isFunction(onCollapse)) {\n onCollapse(item);\n }\n setExpanded((prevState) => {\n const nextState = { ...prevState };\n delete nextState[item[itemKey]];\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n return {\n state: { expanded, isExpandedAll },\n actions: {\n expand,\n toggleExpandAll,\n toggleExpand,\n collapse,\n },\n setExpanded,\n };\n};\n\nexport default useExpandState;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AAcA,MAAM,sBAAsB,CAAK,KAAwB,KAAa,UAAa;AACjF,QAAM,UAAU,mBAAK;AACrB,MAAI,QAAQ,MAAM;AAChB,WAAO,QAAQ;AAAA,EACjB,OAAO;AACL,YAAQ,OAAO;AAAA,EACjB;AACA,SAAO;AACT;AAEA,MAAM,OAAO,MAAM;AAEZ,MAAM,iBAAiB,CAAC;AAAA,EAC7B,QAAQ,CAAC;AAAA,EACT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A,IACjC,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAEA,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
isEqualWith,
|
|
68
68
|
isBoolean
|
|
69
69
|
} from "./utils";
|
|
70
|
-
import { setRef, mergeRefs, logger } from "./system";
|
|
70
|
+
import { setRef, mergeRefs, setMultipleRefs, logger } from "./system";
|
|
71
71
|
import {
|
|
72
72
|
useMeasure,
|
|
73
73
|
useForceUpdate,
|
|
@@ -172,6 +172,7 @@ export {
|
|
|
172
172
|
runAll,
|
|
173
173
|
safeCall,
|
|
174
174
|
set,
|
|
175
|
+
setMultipleRefs,
|
|
175
176
|
setRef,
|
|
176
177
|
sortBy,
|
|
177
178
|
startsWith,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default as getComponentFromProps } from './getComponentFromProps';\nexport { default as onClickHandlerForNonInteractiveElements } from './onClickHandlerForNonInteractiveElements';\nexport { capitalize } from './capitalize';\nexport { getObjectValuesToArray, getObjectKeysToArray } from './objectUtilities';\nexport {\n checkNotEmpty,\n checkEmpty,\n greaterThan,\n validDate,\n equal,\n notEqual,\n isNull,\n isNotNull,\n isIn,\n isNotIn,\n greaterThanOrEquals,\n lessThanOrEquals,\n startsWith,\n contains,\n} from './operators';\nexport {\n cx,\n runAll,\n hashArray,\n safeCall,\n removeUndefinedProperties,\n isObject,\n curry,\n arrayMove,\n uniq,\n filter,\n uniqBy,\n groupBy,\n property,\n get,\n set,\n cloneDeep,\n debounce,\n findIndex,\n isEmpty,\n isString,\n isEqual,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n pull,\n sortBy,\n sumBy,\n transform,\n isFunction,\n range,\n parseInt,\n padStart,\n isNaN,\n values,\n throttle,\n toggleInObject,\n toggleInArray,\n pick,\n pickBy,\n differenceBy,\n differenceWith,\n addOrRemove,\n isEqualWith,\n isBoolean,\n} from './utils';\nexport { setRef, mergeRefs, logger } from './system';\nexport {\n useMeasure,\n useForceUpdate,\n useOnClickOutside,\n useExecutionTimer,\n useExpandState,\n useHotkeys,\n useHoverHandlersDelay,\n useResizeObserver,\n useShouldRecalculate,\n useWindowScrollerList,\n usePrevious,\n useCancellableDelayedCallback,\n useDerivedStateFromProps,\n useOnElementResize,\n useIsShowingEllipsis,\n useCallbackAfterRender,\n useFocusTrap,\n UseFocusTrapWithSchema,\n useIsMobile,\n useOnBlurOut,\n UseOnBlurOutWithSchema,\n useOnFirstFocusIn,\n UseOnFirstFocusInWithSchema,\n useOnSpecificFocus,\n UseOnSpecificFocusWithSchema,\n} from './hooks';\nexport { getVisibleTimeByFormat, addLeadingZeros } from './timeUtils';\nexport { compose } from './compose';\nexport { DOCUMENT, WINDOW } from './platform';\nexport { isDOMTypeElement } from './reactTypesUtility';\nexport { isRequired, isGreaterThan, isValidDate } from './validations';\n\n// TODO -- REMOVE WHEN READY\nexport * from './deprecated';\nexport * from './props-helpers';\n"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default as getComponentFromProps } from './getComponentFromProps';\nexport { default as onClickHandlerForNonInteractiveElements } from './onClickHandlerForNonInteractiveElements';\nexport { capitalize } from './capitalize';\nexport { getObjectValuesToArray, getObjectKeysToArray } from './objectUtilities';\nexport {\n checkNotEmpty,\n checkEmpty,\n greaterThan,\n validDate,\n equal,\n notEqual,\n isNull,\n isNotNull,\n isIn,\n isNotIn,\n greaterThanOrEquals,\n lessThanOrEquals,\n startsWith,\n contains,\n} from './operators';\nexport {\n cx,\n runAll,\n hashArray,\n safeCall,\n removeUndefinedProperties,\n isObject,\n curry,\n arrayMove,\n uniq,\n filter,\n uniqBy,\n groupBy,\n property,\n get,\n set,\n cloneDeep,\n debounce,\n findIndex,\n isEmpty,\n isString,\n isEqual,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n pull,\n sortBy,\n sumBy,\n transform,\n isFunction,\n range,\n parseInt,\n padStart,\n isNaN,\n values,\n throttle,\n toggleInObject,\n toggleInArray,\n pick,\n pickBy,\n differenceBy,\n differenceWith,\n addOrRemove,\n isEqualWith,\n isBoolean,\n} from './utils';\nexport { setRef, mergeRefs, setMultipleRefs, logger } from './system';\nexport {\n useMeasure,\n useForceUpdate,\n useOnClickOutside,\n useExecutionTimer,\n useExpandState,\n useHotkeys,\n useHoverHandlersDelay,\n useResizeObserver,\n useShouldRecalculate,\n useWindowScrollerList,\n usePrevious,\n useCancellableDelayedCallback,\n useDerivedStateFromProps,\n useOnElementResize,\n useIsShowingEllipsis,\n useCallbackAfterRender,\n useFocusTrap,\n UseFocusTrapWithSchema,\n useIsMobile,\n useOnBlurOut,\n UseOnBlurOutWithSchema,\n useOnFirstFocusIn,\n UseOnFirstFocusInWithSchema,\n useOnSpecificFocus,\n UseOnSpecificFocusWithSchema,\n} from './hooks';\nexport { getVisibleTimeByFormat, addLeadingZeros } from './timeUtils';\nexport { compose } from './compose';\nexport { DOCUMENT, WINDOW } from './platform';\nexport { isDOMTypeElement } from './reactTypesUtility';\nexport { isRequired, isGreaterThan, isValidDate } from './validations';\n\n// TODO -- REMOVE WHEN READY\nexport * from './deprecated';\nexport * from './props-helpers';\n"],
|
|
5
5
|
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgDA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BA;AACA;AACA;AACA;AACA;AAGA;AACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,9 +34,6 @@ function describe(ComponentInstance) {
|
|
|
34
34
|
let realPropType;
|
|
35
35
|
documentation.propTypes[name] = propType;
|
|
36
36
|
realPropType = convertPropType(propType);
|
|
37
|
-
if (value[name].reactDesc.required) {
|
|
38
|
-
realPropType = realPropType.isRequired;
|
|
39
|
-
}
|
|
40
37
|
DocumentedComponent.propTypesValue[name] = realPropType;
|
|
41
38
|
return propType;
|
|
42
39
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/propTypes/describe.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/forbid-foreign-prop-types */\nimport { Requireable, Validator } from 'prop-types';\nimport React from 'react';\nimport { convertPropType } from './describeConversions';\nimport descToTypescript from './toTypescript';\nimport { ReactDescT, Hook, ComponentDocumentation, DocumentedReactComponent } from './types';\n\nexport default function describe<C, R>(ComponentInstance: React.ComponentType<C> | Hook<C, R>) {\n if (!ComponentInstance) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: ComponentDocumentation = {\n propTypes: {},\n };\n\n const DocumentedComponent = ComponentInstance as DocumentedReactComponent<C>;\n\n const addDocumentationProp = <T extends keyof ComponentDocumentation>(propName: T) => {\n const func = (value: ComponentDocumentation[T]): DocumentedReactComponent<C> => {\n documentation[propName] = value;\n return DocumentedComponent;\n };\n return func;\n };\n\n DocumentedComponent.availableAt = addDocumentationProp('availableAt');\n DocumentedComponent.description = addDocumentationProp('description');\n DocumentedComponent.details = addDocumentationProp('details');\n DocumentedComponent.deprecated = addDocumentationProp('deprecated');\n DocumentedComponent.usage = addDocumentationProp('usage');\n DocumentedComponent.intrinsicElement = addDocumentationProp('intrinsicElement');\n\n DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);\n\n Object.defineProperty(DocumentedComponent, 'propTypes', {\n get: () => DocumentedComponent.propTypesValue,\n set: (value: Record<string, ReactDescT>) => {\n if (!DocumentedComponent.propTypesValue) {\n DocumentedComponent.propTypesValue = {};\n }\n\n Object.keys(value).forEach((name) => {\n const propType: ReactDescT = value[name];\n let realPropType: Requireable<unknown> | Validator<unknown>;\n documentation.propTypes[name] = propType;\n realPropType = convertPropType(propType);\n
|
|
5
|
-
"mappings": "AAAA;ACGA;AACA;AAGe,kBAAwB,mBAAwD;AAC7F,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,QAAM,gBAAwC;AAAA,IAC5C,WAAW,CAAC;AAAA,EACd;AAEA,QAAM,sBAAsB;AAE5B,QAAM,uBAAuB,CAAyC,aAAgB;AACpF,UAAM,OAAO,CAAC,UAAkE;AAC9E,oBAAc,YAAY;AAC1B,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAEA,sBAAoB,cAAc,qBAAqB,aAAa;AACpE,sBAAoB,cAAc,qBAAqB,aAAa;AACpE,sBAAoB,UAAU,qBAAqB,SAAS;AAC5D,sBAAoB,aAAa,qBAAqB,YAAY;AAClE,sBAAoB,QAAQ,qBAAqB,OAAO;AACxD,sBAAoB,mBAAmB,qBAAqB,kBAAkB;AAE9E,sBAAoB,eAAe,MAAM,iBAAiB,mBAAmB,aAAa;AAE1F,SAAO,eAAe,qBAAqB,aAAa;AAAA,IACtD,KAAK,MAAM,oBAAoB;AAAA,IAC/B,KAAK,CAAC,UAAsC;AAC1C,UAAI,CAAC,oBAAoB,gBAAgB;AACvC,4BAAoB,iBAAiB,CAAC;AAAA,MACxC;AAEA,aAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,SAAS;AACnC,cAAM,WAAuB,MAAM;AACnC,YAAI;AACJ,sBAAc,UAAU,QAAQ;AAChC,uBAAe,gBAAgB,QAAQ;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/forbid-foreign-prop-types */\nimport { Requireable, Validator } from 'prop-types';\nimport React from 'react';\nimport { convertPropType } from './describeConversions';\nimport descToTypescript from './toTypescript';\nimport { ReactDescT, Hook, ComponentDocumentation, DocumentedReactComponent } from './types';\n\nexport default function describe<C, R>(ComponentInstance: React.ComponentType<C> | Hook<C, R>) {\n if (!ComponentInstance) {\n throw new Error('react-desc: component is required');\n }\n\n const documentation: ComponentDocumentation = {\n propTypes: {},\n };\n\n const DocumentedComponent = ComponentInstance as DocumentedReactComponent<C>;\n\n const addDocumentationProp = <T extends keyof ComponentDocumentation>(propName: T) => {\n const func = (value: ComponentDocumentation[T]): DocumentedReactComponent<C> => {\n documentation[propName] = value;\n return DocumentedComponent;\n };\n return func;\n };\n\n DocumentedComponent.availableAt = addDocumentationProp('availableAt');\n DocumentedComponent.description = addDocumentationProp('description');\n DocumentedComponent.details = addDocumentationProp('details');\n DocumentedComponent.deprecated = addDocumentationProp('deprecated');\n DocumentedComponent.usage = addDocumentationProp('usage');\n DocumentedComponent.intrinsicElement = addDocumentationProp('intrinsicElement');\n\n DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);\n\n Object.defineProperty(DocumentedComponent, 'propTypes', {\n get: () => DocumentedComponent.propTypesValue,\n set: (value: Record<string, ReactDescT>) => {\n if (!DocumentedComponent.propTypesValue) {\n DocumentedComponent.propTypesValue = {};\n }\n\n Object.keys(value).forEach((name) => {\n const propType: ReactDescT = value[name];\n let realPropType: Requireable<unknown> | Validator<unknown>;\n documentation.propTypes[name] = propType;\n realPropType = convertPropType(propType);\n // We don't need to rely on the isRequired from prop-types package\n // So no need to invoke (realPropType).isRequired if our own proptype is required\n // Validation will handle that case for us\n DocumentedComponent.propTypesValue[name] = realPropType as Validator<unknown>;\n return propType;\n });\n },\n enumerable: true,\n configurable: true,\n });\n\n return DocumentedComponent;\n}\n"],
|
|
5
|
+
"mappings": "AAAA;ACGA;AACA;AAGe,kBAAwB,mBAAwD;AAC7F,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,QAAM,gBAAwC;AAAA,IAC5C,WAAW,CAAC;AAAA,EACd;AAEA,QAAM,sBAAsB;AAE5B,QAAM,uBAAuB,CAAyC,aAAgB;AACpF,UAAM,OAAO,CAAC,UAAkE;AAC9E,oBAAc,YAAY;AAC1B,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAEA,sBAAoB,cAAc,qBAAqB,aAAa;AACpE,sBAAoB,cAAc,qBAAqB,aAAa;AACpE,sBAAoB,UAAU,qBAAqB,SAAS;AAC5D,sBAAoB,aAAa,qBAAqB,YAAY;AAClE,sBAAoB,QAAQ,qBAAqB,OAAO;AACxD,sBAAoB,mBAAmB,qBAAqB,kBAAkB;AAE9E,sBAAoB,eAAe,MAAM,iBAAiB,mBAAmB,aAAa;AAE1F,SAAO,eAAe,qBAAqB,aAAa;AAAA,IACtD,KAAK,MAAM,oBAAoB;AAAA,IAC/B,KAAK,CAAC,UAAsC;AAC1C,UAAI,CAAC,oBAAoB,gBAAgB;AACvC,4BAAoB,iBAAiB,CAAC;AAAA,MACxC;AAEA,aAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,SAAS;AACnC,cAAM,WAAuB,MAAM;AACnC,YAAI;AACJ,sBAAc,UAAU,QAAQ;AAChC,uBAAe,gBAAgB,QAAQ;AAIvC,4BAAoB,eAAe,QAAQ;AAC3C,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,IACA,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB,CAAC;AAED,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ const enrichPropType = (propType, reactDesc) => {
|
|
|
17
17
|
const { version = "", message = "" } = reactDesc.deprecated;
|
|
18
18
|
const error = `Warning: "${propName}" property of "${componentName}" will be deprecated in version: ${version}.
|
|
19
19
|
${message}`;
|
|
20
|
-
console.
|
|
20
|
+
console.warn(error);
|
|
21
21
|
reactDesc.warned = true;
|
|
22
22
|
}
|
|
23
23
|
return propType(props, propName, componentName, ...rest);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/propTypes/describeConversions.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-params */\n/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport PropTypes, { ValidationMap, Requireable } from 'prop-types';\nimport { tupleValidator } from './customPropTypes';\nimport {\n hasArguments,\n isArrayOf,\n isExact,\n isInstanceOf,\n isObjectOf,\n isOneOf,\n isOneOfType,\n isShape,\n} from './describeGuards';\nimport { ReactDescT, ReactDescObjT, InstanceOfT, OneOfT, ObjectOfT, ExactT } from './types';\n\nconst enrichPropType = (propType: Requireable<unknown>, reactDesc: ReactDescObjT): Requireable<unknown> => {\n const func = (props: Record<string, unknown>, propName: string, componentName: string, ...rest: [string, string]) => {\n if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {\n const { version = '', message = '' } = reactDesc.deprecated;\n const error = `Warning: \"${propName}\" property of \"${componentName}\" will be deprecated in version: ${version}.\\n${message}`;\n console.
|
|
5
|
-
"mappings": "AAAA;ACKA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,MAAM,iBAAiB,CAAC,UAAgC,cAAmD;AACzG,QAAM,OAAO,CAAC,OAAgC,UAAkB,kBAA0B,SAA2B;AACnH,QAAI,aAAa,UAAU,cAAc,YAAY,SAAS,CAAC,UAAU,QAAQ;AAC/E,YAAM,EAAE,UAAU,IAAI,UAAU,OAAO,UAAU;AACjD,YAAM,QAAQ,aAAa,0BAA0B,iDAAiD;AAAA,EAAa;AACnH,cAAQ,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-params */\n/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-use-before-define */\nimport PropTypes, { ValidationMap, Requireable } from 'prop-types';\nimport { tupleValidator } from './customPropTypes';\nimport {\n hasArguments,\n isArrayOf,\n isExact,\n isInstanceOf,\n isObjectOf,\n isOneOf,\n isOneOfType,\n isShape,\n} from './describeGuards';\nimport { ReactDescT, ReactDescObjT, InstanceOfT, OneOfT, ObjectOfT, ExactT } from './types';\n\nconst enrichPropType = (propType: Requireable<unknown>, reactDesc: ReactDescObjT): Requireable<unknown> => {\n const func = (props: Record<string, unknown>, propName: string, componentName: string, ...rest: [string, string]) => {\n if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {\n const { version = '', message = '' } = reactDesc.deprecated;\n const error = `Warning: \"${propName}\" property of \"${componentName}\" will be deprecated in version: ${version}.\\n${message}`;\n console.warn(error);\n reactDesc.warned = true;\n }\n return propType(props, propName, componentName, ...rest);\n };\n Object.defineProperty(\n func,\n 'isRequired',\n Object.getOwnPropertyDescriptor(propType, 'isRequired') as PropertyDescriptor,\n );\n return func as Requireable<unknown>;\n};\n\nconst convertArray = (array: ReactDescT[]): Requireable<unknown>[] => array.map((type) => convertPropType(type));\n\nconst convertShape = (_shape: Record<string, ReactDescT>): ValidationMap<Record<string, unknown>> => {\n const result: ValidationMap<Record<string, unknown>> = {};\n Object.keys(_shape).forEach((key) => {\n result[key] = convertPropType(_shape[key]);\n });\n return result;\n};\n\nexport const convertPropType = (propType: ReactDescT): Requireable<unknown> => {\n if (!propType || !propType.type) {\n throw new Error(`react-desc: unknown error -- proptype is not well defined`);\n }\n\n // DimSum PropTypes conversion\n if (propType.type === 'tuple') {\n return enrichPropType(\n PropTypes.arrayOf(tupleValidator(convertArray(propType.args as ReactDescT[]))),\n propType.reactDesc,\n );\n }\n\n // Default PropType conversion\n const realPropType = PropTypes[propType.type];\n\n if (!realPropType) {\n throw new Error(`react-desc: unknown type ${propType.type}`);\n }\n\n if (hasArguments(propType, realPropType)) {\n if (isOneOfType(propType, realPropType)) {\n return enrichPropType(realPropType(convertArray(propType.args as ReactDescT[])), propType.reactDesc);\n }\n if (isArrayOf(propType, realPropType)) {\n return enrichPropType(realPropType(convertPropType(propType.args as ReactDescT)), propType.reactDesc);\n }\n if (isShape(propType, realPropType)) {\n return enrichPropType(\n realPropType(convertShape(propType.args as Record<string, ReactDescT>)),\n propType.reactDesc,\n );\n }\n if (isInstanceOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<InstanceOfT>[0]), propType.reactDesc);\n }\n if (isOneOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<OneOfT>[0]), propType.reactDesc);\n }\n if (isObjectOf(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<ObjectOfT>[0]), propType.reactDesc);\n }\n if (isExact(propType, realPropType)) {\n return enrichPropType(realPropType(propType.args as Parameters<ExactT>[0]), propType.reactDesc);\n }\n throw new Error(`react-desc: unknown error -- proptype with args is not matching`);\n }\n\n return enrichPropType(realPropType, propType.reactDesc);\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACKA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,MA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AU,YAAY,GAAG;AACrC,aAAO,eAAe,aAAa,gBAAgB,SAAS,IAAkB,CAAC,GAAG,SAAS,SAAS;AAAA,IACtG;AACA,QAAI,QAAQ,UAAU,YAAY,GAAG;AACnC,aAAO,eACL,aAAa,aAAa,SAAS,IAAkC,CAAC,GACtE,SAAS,SACX;AAAA,IACF;AACA,QAAI,aAAa,UAAU,YAAY,GAAG;AACxC,aAAO,eAAe,aAAa,SAAS,IAAkC,GAAG,SAAS,SAAS;AAAA,IACrG;AACA,QAAI,QAAQ,UAAU,YAAY,GAAG;AACnC,aAAO,eAAe,aAAa,SAAS,IAA6B,GAAG,SAAS,SAAS;AAAA,IAChG;AACA,QAAI,WAAW,UAAU,YAAY,GAAG;AACtC,aAAO,eAAe,aAAa,SAAS,IAAgC,GAAG,SAAS,SAAS;AAAA,IACnG;AACA,QAAI,QAAQ,UAAU,YAAY,GAAG;AACnC,aAAO,eAAe,aAAa,SAAS,IAA6B,GAAG,SAAS,SAAS;AAAA,IAChG;AACA,UAAM,IAAI,MAAM,iEAAiE;AAAA,EACnF;AAEA,SAAO,eAAe,cAAc,SAAS,SAAS;AACxD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/system.js
CHANGED
|
@@ -15,12 +15,24 @@ const mergeRefs = (...refs) => {
|
|
|
15
15
|
};
|
|
16
16
|
return mergeRefsFunc;
|
|
17
17
|
};
|
|
18
|
+
function setMultipleRefs(refs) {
|
|
19
|
+
return (value) => {
|
|
20
|
+
refs.forEach((ref) => {
|
|
21
|
+
if (typeof ref === "function") {
|
|
22
|
+
ref(value);
|
|
23
|
+
} else if (ref != null) {
|
|
24
|
+
ref.current = value;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
}
|
|
18
29
|
function logger(...args) {
|
|
19
30
|
console.log(...args);
|
|
20
31
|
}
|
|
21
32
|
export {
|
|
22
33
|
logger,
|
|
23
34
|
mergeRefs,
|
|
35
|
+
setMultipleRefs,
|
|
24
36
|
setRef
|
|
25
37
|
};
|
|
26
38
|
//# sourceMappingURL=system.js.map
|
package/dist/esm/system.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/system.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { isFunction } from './utils';\n\ntype AnyRef<T extends HTMLElement> = React.MutableRefObject<T> | ((_ref: T) => void);\n\nexport const setRef = <T extends HTMLElement>(ref: AnyRef<T>, value: T) => {\n if (isFunction(ref)) {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n};\n\nexport const mergeRefs = <T extends HTMLElement>(...refs: AnyRef<T>[]) => {\n const mergeRefsFunc = (node: T) => {\n if (!node) return;\n refs.forEach((ref) => setRef(ref, node));\n };\n return mergeRefsFunc;\n};\n\nexport function logger(...args: unknown[]) {\n // eslint-disable-next-line no-console\n console.log(...args);\n}\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AAIO,MAAM,SAAS,CAAwB,KAAgB,UAAa;AACzE,MAAI,WAAW,GAAG,GAAG;AACnB,QAAI,KAAK;AAAA,EACX,WAAW,KAAK;AACd,QAAI,UAAU;AAAA,EAChB;AACF;AAEO,MAAM,YAAY,IAA2B,SAAsB;AACxE,QAAM,gBAAgB,CAAC,SAAY;AACjC,QAAI,CAAC;AAAM;AACX,SAAK,QAAQ,CAAC,QAAQ,OAAO,KAAK,IAAI,CAAC;AAAA,EACzC;AACA,SAAO;AACT;AAEO,mBAAmB,MAAiB;AAEzC,UAAQ,IAAI,GAAG,IAAI;AACrB;",
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { isFunction } from './utils';\n\ntype AnyRef<T extends HTMLElement> = React.MutableRefObject<T> | ((_ref: T) => void);\n\nexport const setRef = <T extends HTMLElement>(ref: AnyRef<T>, value: T) => {\n if (isFunction(ref)) {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n};\n\nexport const mergeRefs = <T extends HTMLElement>(...refs: AnyRef<T>[]) => {\n const mergeRefsFunc = (node: T) => {\n if (!node) return;\n refs.forEach((ref) => setRef(ref, node));\n };\n return mergeRefsFunc;\n};\n\nexport function setMultipleRefs<T = unknown>(\n refs: Array<React.RefObject<T> | React.LegacyRef<T>>,\n): React.RefCallback<T> {\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref != null) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n });\n };\n}\n\nexport function logger(...args: unknown[]) {\n // eslint-disable-next-line no-console\n console.log(...args);\n}\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAIO,MAAM,SAAS,CAAwB,KAAgB,UAAa;AACzE,MAAI,WAAW,GAAG,GAAG;AACnB,QAAI,KAAK;AAAA,EACX,WAAW,KAAK;AACd,QAAI,UAAU;AAAA,EAChB;AACF;AAEO,MAAM,YAAY,IAA2B,SAAsB;AACxE,QAAM,gBAAgB,CAAC,SAAY;AACjC,QAAI,CAAC;AAAM;AACX,SAAK,QAAQ,CAAC,QAAQ,OAAO,KAAK,IAAI,CAAC;AAAA,EACzC;AACA,SAAO;AACT;AAEO,yBACL,MACsB;AACtB,SAAO,CAAC,UAAU;AAChB,SAAK,QAAQ,CAAC,QAAQ;AACpB,UAAI,OAAO,QAAQ,YAAY;AAC7B,YAAI,KAAK;AAAA,MACX,WAAW,OAAO,MAAM;AACtB,QAAC,IAAyC,UAAU;AAAA,MACtD;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,mBAAmB,MAAiB;AAEzC,UAAQ,IAAI,GAAG,IAAI;AACrB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/utils.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/utils.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-param-reassign */\n/* eslint-disable max-lines */\n/**\n * commonly used functions\n * Add a level of indirection to lodash so we can replace\n * it if desired, while keeping function names the same\n */\n// TODO: Import individual packages vs referencing all of lodash\nimport {\n cloneDeep,\n filter,\n debounce,\n findIndex,\n isEmpty,\n isString,\n isEqual,\n noop,\n omit,\n orderBy,\n pull,\n sumBy,\n maxBy,\n meanBy,\n sortBy,\n transform,\n isFunction,\n uniq,\n uniqBy,\n groupBy,\n property,\n get,\n set,\n range,\n parseInt,\n padStart,\n isNaN,\n values,\n throttle,\n pick,\n pickBy,\n differenceBy,\n differenceWith,\n isEqualWith,\n curry,\n isObject,\n isBoolean,\n} from 'lodash';\n\ntype UnknownFunctionT = (...args: unknown[]) => unknown;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ValidKeys = string | number | symbol;\n\n/**\n * Concatenates classNames from arguments\n *\n * @param {...any} classnames classnames you want to join\n * @returns {string} All classnames string concatenated\n */\nexport const cx = (...classnames: string[]): string => classnames.reduce((result, cn) => `${result} ${cn || ''}`, '');\n\n// if entry exists, remove it, if not, add it\nconst toggleInObject = (obj: Record<string, unknown>, key: string, value: unknown) =>\n obj[key] !== undefined ? omit(obj, [key]) : { ...obj, [key]: value };\n\nconst toggleInArray = (array: unknown[], value: unknown) => (array.indexOf(value) === -1 ? [value] : []);\n\nconst arrayMoveMutate = (array: unknown[], from: number, to: number) => {\n array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);\n};\n\nconst arrayMove = <T,>(array: T[], from: number, to: number): T[] => {\n array = array.slice();\n arrayMoveMutate(array, from, to);\n return array;\n};\n\nconst accessorDefault = <T,>(item: T): T => item;\n\nconst addOrRemove = <T,>(array: T[], item: T, accessor = accessorDefault): T[] => {\n const index = array.findIndex((iItem) => accessor(iItem) === accessor(item));\n\n if (index !== -1) {\n const nextArray = cloneDeep(array);\n nextArray.splice(index, 1);\n return nextArray;\n }\n\n return [...array, item];\n};\n\nexport function runAll(...fns: (UnknownFunctionT | UnknownFunctionT[])[]) {\n return (...args: unknown[]) =>\n fns.forEach((fn) => {\n if (Array.isArray(fn)) runAll(fn);\n if (isFunction(fn)) fn(...args);\n });\n}\n\nexport function hashArray(arr: (ValidKeys | Record<string, ValidKeys>)[], fieldName?: string) {\n return arr.reduce<Record<ValidKeys, boolean>>((result, item) => {\n const newKey: ValidKeys = fieldName && typeof item === 'object' ? item[fieldName] : (item as ValidKeys);\n return {\n ...result,\n [newKey]: true,\n };\n }, {});\n}\n\nexport function safeCall(fun: unknown, ...args: unknown[]) {\n if (isFunction(fun)) {\n fun(...args);\n }\n}\n\nexport const removeUndefinedProperties = (obj: Record<string, unknown>) => {\n const cleanObject = { ...obj };\n Object.keys(obj).forEach((key) => cleanObject[key] === undefined && delete cleanObject[key]);\n return cleanObject;\n};\n\nexport default {};\nexport {\n isObject,\n curry,\n arrayMove,\n uniq,\n filter,\n uniqBy,\n groupBy,\n property,\n get,\n set,\n cloneDeep,\n debounce,\n findIndex,\n isEmpty,\n isString,\n isEqual,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n pull,\n sortBy,\n sumBy,\n transform,\n isFunction,\n range,\n parseInt,\n padStart,\n isNaN,\n values,\n throttle,\n toggleInObject,\n toggleInArray,\n pick,\n pickBy,\n differenceBy,\n differenceWith,\n addOrRemove,\n isEqualWith,\n isBoolean,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkDO,MAAM,KAAK,IAAI,eAAiC,WAAW,OAAO,CAAC,QAAQ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AM,YAAY,UAAU,KAAK;AACjC,cAAU,OAAO,OAAO,CAAC;AACzB,WAAO;AAAA,EACT;AAEA,SAAO,CAAC,GAAG,OAAO,IAAI;AACxB;AAEO,mBAAmB,KAAgD;AACxE,SAAO,IAAI,SACT,IAAI,QAAQ,CAAC,OAAO;AAClB,QAAI,MAAM,QAAQ,EAAE;AAAG,aAAO,EAAE;AAChC,QAAI,WAAW,EAAE;AAAG,SAAG,GAAG,IAAI;AAAA,EAChC,CAAC;AACL;AAEO,mBAAmB,KAAgD,WAAoB;AAC5F,SAAO,IAAI,OAAmC,CAAC,QAAQ,SAAS;AAC9D,UAAM,SAAoB,aAAa,OAAO,SAAS,WAAW,KAAK,aAAc;AACrF,WAAO,iCACF,SADE;AAAA,MAEL,CAAC,SAAS;AAAA,IACZ;AAAA,EACF,GAAG,CAAC,CAAC;AACP;AAEO,kBAAkB,QAAiB,MAAiB;AACzD,MAAI,WAAW,GAAG,GAAG;AACnB,QAAI,GAAG,IAAI;AAAA,EACb;AACF;AAEO,MAAM,4BAA4B,CAAC,QAAiC;AACzE,QAAM,cAAc,mBAAK;AACzB,SAAO,KAAK,GAAG,EAAE,QAAQ,CAAC,QAAQ,YAAY,SAAS,UAAa,OAAO,YAAY,IAAI;AAC3F,SAAO;AACT;AAEA,IAAO,gBAAQ,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-utilities",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0-rc.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Utilities",
|
|
6
6
|
"files": [
|
|
@@ -151,21 +151,21 @@
|
|
|
151
151
|
"typeSafety": true
|
|
152
152
|
},
|
|
153
153
|
"dependencies": {
|
|
154
|
-
"@elliemae/ds-system": "3.
|
|
154
|
+
"@elliemae/ds-system": "3.2.0-rc.3",
|
|
155
155
|
"@elliemae/pui-theme": "~2.6.0",
|
|
156
156
|
"fast-deep-equal": "~3.1.3",
|
|
157
|
-
"hotkeys-js": "~3.
|
|
157
|
+
"hotkeys-js": "~3.9.3",
|
|
158
158
|
"prop-types": "~15.8.1",
|
|
159
159
|
"raf": "~3.4.1",
|
|
160
160
|
"resize-observer-polyfill": "~1.5.1",
|
|
161
161
|
"uncontrollable": "~6.2.3",
|
|
162
|
-
"use-force-update": "~1.0.
|
|
162
|
+
"use-force-update": "~1.0.8",
|
|
163
163
|
"use-measure": "~0.3.0",
|
|
164
|
-
"use-onclickoutside": "~0.
|
|
164
|
+
"use-onclickoutside": "~0.4.0"
|
|
165
165
|
},
|
|
166
166
|
"devDependencies": {
|
|
167
167
|
"@testing-library/jest-dom": "~5.16.4",
|
|
168
|
-
"@testing-library/react": "~12.1.
|
|
168
|
+
"@testing-library/react": "~12.1.3"
|
|
169
169
|
},
|
|
170
170
|
"peerDependencies": {
|
|
171
171
|
"lodash": "^4.17.21",
|