@e1011/es-kit 1.1.60 → 1.1.64
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/hooks/esm/index.css +379 -363
- package/dist/hooks/esm/src/core/hooks/useAnimation.js +1 -1
- package/dist/hooks/esm/src/core/hooks/useAnimation.js.map +1 -1
- package/dist/hooks/index.css +379 -363
- package/dist/hooks/src/core/hooks/useAnimation.js +1 -1
- package/dist/hooks/src/core/hooks/useAnimation.js.map +1 -1
- package/dist/lib/cjs/index.css +16 -0
- package/dist/lib/cjs/src/core/hooks/useAnimation.js +1 -1
- package/dist/lib/cjs/src/core/hooks/useAnimation.js.map +1 -1
- package/dist/lib/cjs/src/core/ui/components/atoms/button/Button.js +1 -1
- package/dist/lib/cjs/src/core/ui/components/atoms/button/Button.js.map +1 -1
- package/dist/lib/cjs/src/core/ui/components/atoms/button/button.module.scss.js +1 -1
- package/dist/lib/cjs/src/core/ui/components/field/Field.js +1 -1
- package/dist/lib/cjs/src/core/ui/components/field/Field.js.map +1 -1
- package/dist/lib/cjs/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
- package/dist/lib/esm/index.css +16 -0
- package/dist/lib/esm/src/core/hooks/useAnimation.js +1 -1
- package/dist/lib/esm/src/core/hooks/useAnimation.js.map +1 -1
- package/dist/lib/esm/src/core/ui/components/atoms/button/Button.js +1 -1
- package/dist/lib/esm/src/core/ui/components/atoms/button/Button.js.map +1 -1
- package/dist/lib/esm/src/core/ui/components/atoms/button/button.module.scss.js +1 -1
- package/dist/lib/esm/src/core/ui/components/field/Field.js +1 -1
- package/dist/lib/esm/src/core/ui/components/field/Field.js.map +1 -1
- package/dist/lib/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/core/hooks/useAnimation.d.ts +4 -3
- package/dist/types/src/core/hooks/useAnimation.d.ts.map +1 -1
- package/dist/types/src/core/ui/components/atoms/animatedSnippet/AnimatedSnippet.d.ts +5 -0
- package/dist/types/src/core/ui/components/atoms/animatedSnippet/AnimatedSnippet.d.ts.map +1 -0
- package/dist/types/src/core/ui/components/atoms/animatedSnippet/animatedSnippet.stories.d.ts +5 -0
- package/dist/types/src/core/ui/components/atoms/animatedSnippet/animatedSnippet.stories.d.ts.map +1 -0
- package/dist/types/src/core/ui/components/atoms/button/Button.d.ts.map +1 -1
- package/dist/types/src/core/ui/components/atoms/button/button.stories.d.ts.map +1 -1
- package/dist/types/src/core/ui/components/atoms/text/Typography.stories.d.ts.map +1 -1
- package/dist/types/src/core/ui/types/CommonProps.d.ts +1 -0
- package/dist/types/src/core/ui/types/CommonProps.d.ts.map +1 -1
- package/dist/types/src/core/utils/appState/peregrineMQ/peregrineMQ.d.ts.map +1 -1
- package/dist/types/src/core/utils/appState/stateMachine/tiny-state-machine.base.d.ts +1 -1
- package/dist/ui/esm/index.css +16 -0
- package/dist/ui/esm/src/core/ui/components/atoms/button/Button.js +1 -1
- package/dist/ui/esm/src/core/ui/components/atoms/button/Button.js.map +1 -1
- package/dist/ui/esm/src/core/ui/components/atoms/button/button.module.scss.js +1 -1
- package/dist/ui/esm/src/core/ui/components/field/Field.js +1 -1
- package/dist/ui/esm/src/core/ui/components/field/Field.js.map +1 -1
- package/dist/ui/index.css +16 -0
- package/dist/ui/src/core/ui/components/atoms/button/Button.js +1 -1
- package/dist/ui/src/core/ui/components/atoms/button/Button.js.map +1 -1
- package/dist/ui/src/core/ui/components/atoms/button/button.module.scss.js +1 -1
- package/dist/ui/src/core/ui/components/field/Field.js +1 -1
- package/dist/ui/src/core/ui/components/field/Field.js.map +1 -1
- package/dist/utils/esm/index.css +379 -363
- package/dist/utils/esm/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
- package/dist/utils/index.css +379 -363
- package/dist/utils/src/core/utils/appState/peregrineMQ/peregrineMQ.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../../../node_modules/gsap/index.js"),t=require("react");exports.useAnimation=r=>{let{start:
|
|
1
|
+
"use strict";var e=require("../../../node_modules/gsap/index.js"),t=require("react");exports.useAnimation=r=>{let{start:n=0,end:a,duration:u=2,ease:o="expo.inOut",rounded:s,roundingFn:d}=r;const[i,l]=t.useState(a),c=t.useRef(n);return t.useEffect((()=>{c.current=i}),[i]),t.useLayoutEffect((()=>{const t={val:c.current},r=e.gsap.context((()=>{e.gsap.to(t,u,{val:a,ease:o,duration:u,...s?{roundProps:"val"}:{},onUpdate(){l(d?d(t.val):t.val)},onComplete(){l(d?d(t.val):t.val)}})}));return()=>r.revert()}),[u,o,a,s,d,n]),i};
|
|
2
2
|
//# sourceMappingURL=useAnimation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnimation.js","sources":["../../../../../src/core/hooks/useAnimation.ts"],"sourcesContent":["import gsap from 'gsap'\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\n\n/**\n * Type definition for the parameters used in the `useAnimation` hook.\n * @typedef {Object} UseAnimationType\n * @property {number} start - The starting value of the animation.\n * @property {number} end - The ending value of the animation.\n * @property {number} duration - The duration of the animation in seconds.\n * @property {string} [ease='expo.inOut'] - The easing function for the animation.\n * @property {boolean} [rounded] - Flag to determine if the value should be rounded during the animation.\n */\nexport type UseAnimationType = {\n start
|
|
1
|
+
{"version":3,"file":"useAnimation.js","sources":["../../../../../src/core/hooks/useAnimation.ts"],"sourcesContent":["import gsap from 'gsap'\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\n\n/**\n * Type definition for the parameters used in the `useAnimation` hook.\n * @typedef {Object} UseAnimationType\n * @property {number} start - The starting value of the animation.\n * @property {number} end - The ending value of the animation.\n * @property {number} duration - The duration of the animation in seconds.\n * @property {string} [ease='expo.inOut'] - The easing function for the animation.\n * @property {boolean} [rounded] - Flag to determine if the value should be rounded during the animation.\n */\nexport type UseAnimationType = {\n start?: number\n end: number\n duration?: number\n ease?: string\n rounded?: boolean\n roundingFn?: (value: number | string) => number | string\n}\n\n/**\n * Custom hook to create an animation using GSAP.\n * @param {UseAnimationType} params - The parameters for the animation.\n * @returns {number} The current value of the animation.\n */\nexport const useAnimation = ({\n start = 0,\n end,\n duration = 2,\n ease = 'expo.inOut',\n rounded,\n roundingFn,\n}: UseAnimationType): number | string => {\n const [val, setVal] = useState<number | string>(end)\n\n const startValueRef = useRef<number | string>(start)\n\n useEffect(() => {\n startValueRef.current = val\n }, [val])\n\n useLayoutEffect(() => {\n const valObj = { val: startValueRef.current }\n\n const gsapCtx = gsap.context(() => {\n gsap.to(valObj, duration, {\n val: end,\n ease,\n duration,\n ...(rounded ? { roundProps: 'val' } : {}),\n onUpdate () {\n setVal(roundingFn ? roundingFn(valObj.val) : valObj.val)\n },\n onComplete () {\n setVal(roundingFn ? roundingFn(valObj.val) : valObj.val)\n },\n })\n })\n\n return (): void => gsapCtx.revert()\n }, [duration, ease, end, rounded, roundingFn, start])\n\n return val\n}\n"],"names":["_ref","start","end","duration","ease","rounded","roundingFn","val","setVal","useState","startValueRef","useRef","useEffect","current","useLayoutEffect","valObj","gsapCtx","gsap","context","to","roundProps","onUpdate","onComplete","revert"],"mappings":"0GA0B4BA,IAOa,IAPZC,MAC3BA,EAAQ,EAACC,IACTA,EAAGC,SACHA,EAAW,EAACC,KACZA,EAAO,aAAYC,QACnBA,EAAOC,WACPA,GACiBN,EACjB,MAAOO,EAAKC,GAAUC,EAAQA,SAAkBP,GAE1CQ,EAAgBC,SAAwBV,GA2B9C,OAzBAW,EAAAA,WAAU,KACRF,EAAcG,QAAUN,CAAG,GAC1B,CAACA,IAEJO,EAAAA,iBAAgB,KACd,MAAMC,EAAS,CAAER,IAAKG,EAAcG,SAE9BG,EAAUC,OAAKC,SAAQ,KAC3BD,OAAKE,GAAGJ,EAAQZ,EAAU,CACxBI,IAAKL,EACLE,OACAD,cACIE,EAAU,CAAEe,WAAY,OAAU,GACtCC,QAAAA,GACEb,EAAOF,EAAaA,EAAWS,EAAOR,KAAOQ,EAAOR,IACrD,EACDe,UAAAA,GACEd,EAAOF,EAAaA,EAAWS,EAAOR,KAAOQ,EAAOR,IACtD,GACA,IAGJ,MAAO,IAAYS,EAAQO,QAAQ,GAClC,CAACpB,EAAUC,EAAMF,EAAKG,EAASC,EAAYL,IAEvCM,CAAG"}
|
package/dist/lib/cjs/index.css
CHANGED
|
@@ -392,6 +392,19 @@
|
|
|
392
392
|
.button-module_button__NDMQS.button-module_warning__MdmiZ.button-module_transparent__zbeBu {
|
|
393
393
|
border: 1px solid #FFCC3D !important;
|
|
394
394
|
}
|
|
395
|
+
.button-module_button__NDMQS.button-module_link__e-4Fu {
|
|
396
|
+
border: none !important;
|
|
397
|
+
background-color: transparent !important;
|
|
398
|
+
background: transparent !important;
|
|
399
|
+
}
|
|
400
|
+
.button-module_button__NDMQS.button-module_link__e-4Fu:hover {
|
|
401
|
+
border: none !important;
|
|
402
|
+
background-color: transparent !important;
|
|
403
|
+
background: transparent !important;
|
|
404
|
+
}
|
|
405
|
+
.button-module_button__NDMQS.button-module_link__e-4Fu:hover * {
|
|
406
|
+
text-decoration: underline !important;
|
|
407
|
+
}
|
|
395
408
|
.button-module_button__NDMQS.button-module_transparent__zbeBu {
|
|
396
409
|
border: none !important;
|
|
397
410
|
background-color: transparent !important;
|
|
@@ -432,6 +445,9 @@
|
|
|
432
445
|
.button-module_button__NDMQS:hover.button-module_animated__gLwPl {
|
|
433
446
|
transform: scale(1.2);
|
|
434
447
|
}
|
|
448
|
+
.button-module_button__NDMQS:hover.button-module_transparent__zbeBu {
|
|
449
|
+
background-color: rgba(197, 197, 197, 0.1254901961) !important;
|
|
450
|
+
}
|
|
435
451
|
.button-module_button__NDMQS.button-module_disabled__hEydO {
|
|
436
452
|
user-select: none;
|
|
437
453
|
pointer-events: none;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../../../node_modules/gsap/index.js"),t=require("react");exports.useAnimation=r=>{let{start:
|
|
1
|
+
"use strict";var e=require("../../../node_modules/gsap/index.js"),t=require("react");exports.useAnimation=r=>{let{start:n=0,end:a,duration:u=2,ease:o="expo.inOut",rounded:s,roundingFn:d}=r;const[i,l]=t.useState(a),c=t.useRef(n);return t.useEffect((()=>{c.current=i}),[i]),t.useLayoutEffect((()=>{const t={val:c.current},r=e.gsap.context((()=>{e.gsap.to(t,u,{val:a,ease:o,duration:u,...s?{roundProps:"val"}:{},onUpdate(){l(d?d(t.val):t.val)},onComplete(){l(d?d(t.val):t.val)}})}));return()=>r.revert()}),[u,o,a,s,d,n]),i};
|
|
2
2
|
//# sourceMappingURL=useAnimation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnimation.js","sources":["../../../../../../src/core/hooks/useAnimation.ts"],"sourcesContent":["import gsap from 'gsap'\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\n\n/**\n * Type definition for the parameters used in the `useAnimation` hook.\n * @typedef {Object} UseAnimationType\n * @property {number} start - The starting value of the animation.\n * @property {number} end - The ending value of the animation.\n * @property {number} duration - The duration of the animation in seconds.\n * @property {string} [ease='expo.inOut'] - The easing function for the animation.\n * @property {boolean} [rounded] - Flag to determine if the value should be rounded during the animation.\n */\nexport type UseAnimationType = {\n start
|
|
1
|
+
{"version":3,"file":"useAnimation.js","sources":["../../../../../../src/core/hooks/useAnimation.ts"],"sourcesContent":["import gsap from 'gsap'\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\n\n/**\n * Type definition for the parameters used in the `useAnimation` hook.\n * @typedef {Object} UseAnimationType\n * @property {number} start - The starting value of the animation.\n * @property {number} end - The ending value of the animation.\n * @property {number} duration - The duration of the animation in seconds.\n * @property {string} [ease='expo.inOut'] - The easing function for the animation.\n * @property {boolean} [rounded] - Flag to determine if the value should be rounded during the animation.\n */\nexport type UseAnimationType = {\n start?: number\n end: number\n duration?: number\n ease?: string\n rounded?: boolean\n roundingFn?: (value: number | string) => number | string\n}\n\n/**\n * Custom hook to create an animation using GSAP.\n * @param {UseAnimationType} params - The parameters for the animation.\n * @returns {number} The current value of the animation.\n */\nexport const useAnimation = ({\n start = 0,\n end,\n duration = 2,\n ease = 'expo.inOut',\n rounded,\n roundingFn,\n}: UseAnimationType): number | string => {\n const [val, setVal] = useState<number | string>(end)\n\n const startValueRef = useRef<number | string>(start)\n\n useEffect(() => {\n startValueRef.current = val\n }, [val])\n\n useLayoutEffect(() => {\n const valObj = { val: startValueRef.current }\n\n const gsapCtx = gsap.context(() => {\n gsap.to(valObj, duration, {\n val: end,\n ease,\n duration,\n ...(rounded ? { roundProps: 'val' } : {}),\n onUpdate () {\n setVal(roundingFn ? roundingFn(valObj.val) : valObj.val)\n },\n onComplete () {\n setVal(roundingFn ? roundingFn(valObj.val) : valObj.val)\n },\n })\n })\n\n return (): void => gsapCtx.revert()\n }, [duration, ease, end, rounded, roundingFn, start])\n\n return val\n}\n"],"names":["_ref","start","end","duration","ease","rounded","roundingFn","val","setVal","useState","startValueRef","useRef","useEffect","current","useLayoutEffect","valObj","gsapCtx","gsap","context","to","roundProps","onUpdate","onComplete","revert"],"mappings":"0GA0B4BA,IAOa,IAPZC,MAC3BA,EAAQ,EAACC,IACTA,EAAGC,SACHA,EAAW,EAACC,KACZA,EAAO,aAAYC,QACnBA,EAAOC,WACPA,GACiBN,EACjB,MAAOO,EAAKC,GAAUC,EAAQA,SAAkBP,GAE1CQ,EAAgBC,SAAwBV,GA2B9C,OAzBAW,EAAAA,WAAU,KACRF,EAAcG,QAAUN,CAAG,GAC1B,CAACA,IAEJO,EAAAA,iBAAgB,KACd,MAAMC,EAAS,CAAER,IAAKG,EAAcG,SAE9BG,EAAUC,OAAKC,SAAQ,KAC3BD,OAAKE,GAAGJ,EAAQZ,EAAU,CACxBI,IAAKL,EACLE,OACAD,cACIE,EAAU,CAAEe,WAAY,OAAU,GACtCC,QAAAA,GACEb,EAAOF,EAAaA,EAAWS,EAAOR,KAAOQ,EAAOR,IACrD,EACDe,UAAAA,GACEd,EAAOF,EAAaA,EAAWS,EAAOR,KAAOQ,EAAOR,IACtD,GACA,IAGJ,MAAO,IAAYS,EAAQO,QAAQ,GAClC,CAACpB,EAAUC,EAAMF,EAAKG,EAASC,EAAYL,IAEvCM,CAAG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../../../../../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),a=require("
|
|
1
|
+
"use strict";var e=require("../../../../../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),a=require("./button.module.scss.js"),n=require("../text/Link.js"),r=require("../../../../utils/helpers/ui.js"),o=require("../../../../utils/helpers/text.js"),i=require("../../icon/IconBase.js");const s={ENTER:{key:"Enter",keyCode:13}},l=t.memo((e=>{let{variant:a,href:o,target:i,children:s,...l}=e;return"link"===a?t.createElement(n.Link,{width:"100%",href:o,target:i,...l,onClick:r.noop},s):t.createElement("span",{},s)}));l.displayName="InnerElement";const c=t.memo((n=>{let{label:i,children:c,variant:d,tiny:u,truncate:p,fluid:m,preventDefualt:h,stopPropagation:f,onClick:E,type:I="button",transparent:g,hasShadow:k,hasIcon:y,disabled:b,animated:v=!1,className:C="",id:x,href:N,target:j,...q}=n;const B=`${i||c?.toString()}`,P=t.useCallback((e=>{h&&e.preventDefault(),f&&(e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()),E?.(e)}),[E,h,f]),R=t.useCallback((e=>{e.key===s.ENTER.key&&(h&&e.preventDefault(),f&&(e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()),E?.(e))}),[E,h,f]);return React.createElement("button",e.extends({type:I,tabIndex:-1,onClick:P,onKeyDown:R,className:r.classNames(a.default.button,u&&a.default.tiny,d&&a.default[d],p&&a.default.truncate,m&&a.default.fluid,v&&a.default.animated,g&&a.default.transparent,k&&a.default.hasShadow,y&&a.default.hasIcon,b&&a.default.disabled,C),id:`${x||B&&o.composeId(B)}`,"data-testid":`${q.dataTestId||q["data-testid"]||x||B&&o.composeId(B)}`},q),React.createElement(l,{variant:d,href:N,target:j},i&&i,c||c))}));c.displayName="Button";const d=["iconUrl","minWidth","minHeight","width","height","size","fontSize","color"],u=t.memo((t=>{const a={},n={};return Object.entries(t).forEach((e=>{let[t,r]=e;d.includes(t)?n[t]=r:a[t]=r})),n.children=t.children,React.createElement(c,e.extends({},a,{hasIcon:!0}),t.iconContent&&t.iconContent,!t.iconContent&&React.createElement(i.IconBase,n))}));u.displayName="IconButton",exports.Button=c,exports.IconButton=u,exports.keys=s;
|
|
2
2
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../../../../../../../src/core/ui/components/atoms/button/Button.tsx"],"sourcesContent":["import { memo, useCallback, MouseEvent, KeyboardEvent, createElement, FC, HTMLAttributes } from 'react'\n\nimport { classNames, composeId, noop } from '../../../../utils'\nimport { Alerts } from '../../../../constants'\nimport {
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../../../../../../../src/core/ui/components/atoms/button/Button.tsx"],"sourcesContent":["import { memo, useCallback, MouseEvent, KeyboardEvent, createElement, FC, HTMLAttributes } from 'react'\n\nimport { classNames, composeId, noop } from '../../../../utils'\nimport { Alerts } from '../../../../constants'\nimport { Link } from '../text'\nimport { IconBase, IconBaseProps } from '../../icon'\n\nimport type { ButtonProps, IconButtonProps } from './button.types'\nimport classes from './button.module.scss'\n\n\nexport const keys = {\n ENTER: {\n key: 'Enter',\n keyCode: 13,\n },\n}\n\ntype InnerElementsProps = Partial<ButtonProps> & Partial<HTMLAttributes<HTMLAnchorElement>>\n\nconst InnerElement: FC<InnerElementsProps> = memo(({\n variant, href, target, children, ...props\n}: Omit<InnerElementsProps, 'onClick'>) => {\n if (variant === 'link') {\n return createElement(Link, { width: '100%', href, target, ...props, onClick: noop }, children)\n }\n return createElement('span', {}, children)\n})\n\nInnerElement.displayName = 'InnerElement'\n\n/**\n * Button component for displaying buttons with optional features.\n * @component\n *\n * Generated component from Template\n * @param {object} props - The component props.\n * @param {string} props.label - The value to be displayed in the button.\n * @param {ReactNode} [props.children] - Additional content to be displayed inside the button.\n * @param {string} [props.variant] - The variant of the button (e.g., 'primary', 'secondary').\n * @param {boolean} [props.tiny] - Whether the button should be tiny.\n * @param {boolean} [props.truncate] - Whether the content inside the button should be truncated.\n * @param {boolean} [props.fluid] - Whether the button should have a fluid width.\n * @param {boolean} [props.animated=true] - Whether the button should have animation (default is true).\n * @param {string} [props.className] - Additional classes to be applied to the button.\n * @param {...object} props.props - Additional props to be spread to the underlying div element.\n *\n * @returns {JSX.Element} The rendered Button component.\n */\nexport const Button = memo(({\n label, children,\n variant, tiny, truncate, fluid,\n preventDefualt, stopPropagation,\n onClick,\n type = 'button',\n transparent,\n hasShadow,\n hasIcon,\n disabled,\n animated = false, className = '', id,\n href,\n target,\n ...props\n}: ButtonProps) => {\n const textFromChildren: string | undefined = `${label || children?.toString()}`\n\n const clickHandler = useCallback((event: MouseEvent) => {\n if (preventDefualt) {\n event.preventDefault()\n }\n if (stopPropagation) {\n event.stopPropagation()\n event.nativeEvent.stopImmediatePropagation()\n }\n onClick?.(event)\n }, [onClick, preventDefualt, stopPropagation])\n\n const keyDownHandler = useCallback((event: KeyboardEvent) => {\n if (event.key === keys.ENTER.key) {\n if (preventDefualt) {\n event.preventDefault()\n }\n if (stopPropagation) {\n event.stopPropagation()\n event.nativeEvent.stopImmediatePropagation()\n }\n onClick?.(event)\n }\n }, [onClick, preventDefualt, stopPropagation])\n\n return (\n <button\n // eslint-disable-next-line react/button-has-type\n type={type}\n tabIndex={-1}\n onClick={clickHandler}\n onKeyDown={keyDownHandler}\n className={classNames(\n classes.button,\n tiny && classes.tiny,\n variant && classes[variant as Alerts],\n truncate && classes.truncate,\n fluid && classes.fluid,\n animated && classes.animated,\n transparent && classes.transparent,\n hasShadow && classes.hasShadow,\n hasIcon && classes.hasIcon,\n disabled && classes.disabled,\n className,\n )}\n id={`${id || (textFromChildren && composeId(textFromChildren))}`}\n data-testid={`${(props as Record<string, string>).dataTestId || (props as Record<string, string>)['data-testid'] || id || (textFromChildren && composeId(textFromChildren))}`}\n {...props}\n >\n <InnerElement variant={variant} href={href} target={target}>\n {label && label}\n {children || children}\n </InnerElement>\n </button>\n )\n})\n\nexport type ButtonType = typeof Button\n\n// Set display name for the component.\nButton.displayName = 'Button'\n\nconst iconBaseProps = [\n 'iconUrl',\n 'minWidth',\n 'minHeight',\n 'width',\n 'height',\n 'size',\n 'fontSize',\n 'color',\n]\n\nexport const IconButton: FC<IconButtonProps> = memo<IconButtonProps>((props: IconButtonProps) => {\n const buttonProps: Record<string, unknown> = {}\n const iconProps: Record<string, unknown> = {}\n\n Object.entries(props).forEach(([name, value]: [string, unknown]) => {\n if (iconBaseProps.includes(name)) {\n // eslint-disable-next-line no-param-reassign\n iconProps[name] = value\n } else {\n buttonProps[name] = value\n }\n })\n\n iconProps.children = props.children\n\n return (\n <Button {...(buttonProps as ButtonProps)} hasIcon>\n {props.iconContent && props.iconContent}\n {!props.iconContent && (<IconBase {...(iconProps as IconBaseProps)} />)}\n </Button>\n )\n})\n\nIconButton.displayName = 'IconButton'\n"],"names":["keys","ENTER","key","keyCode","InnerElement","memo","_ref","variant","href","target","children","props","createElement","Link","width","onClick","noop","displayName","Button","_ref2","label","tiny","truncate","fluid","preventDefualt","stopPropagation","type","transparent","hasShadow","hasIcon","disabled","animated","className","id","textFromChildren","toString","clickHandler","useCallback","event","preventDefault","nativeEvent","stopImmediatePropagation","keyDownHandler","React","_extends","tabIndex","onKeyDown","classNames","classes","default","button","composeId","dataTestId","iconBaseProps","IconButton","buttonProps","iconProps","Object","entries","forEach","_ref3","name","value","includes","iconContent","IconBase"],"mappings":"2SAWO,MAAMA,EAAO,CAClBC,MAAO,CACLC,IAAK,QACLC,QAAS,KAMPC,EAAuCC,EAAIA,MAACC,IAEP,IAFQC,QACjDA,EAAOC,KAAEA,EAAIC,OAAEA,EAAMC,SAAEA,KAAaC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AaoB,EAAOC,QAACrB,UACrBC,GAAWmB,EAAOC,QAACpB,QACnBC,GAAYkB,EAAOC,QAACnB,SACpBE,GAEFC,GAAI,GAAGA,GAAOC,GAAoBiB,EAASA,UAACjB,KAC5C,cAAa,GAAIvB,EAAiCyC,YAAezC,EAAiC,gBAAkBsB,GAAOC,GAAoBiB,YAAUjB,MACrJvB,GAEJgC,MAAA/B,cAACR,EAAY,CAACG,QAASA,EAASC,KAAMA,EAAMC,OAAQA,GACjDW,GAASA,EACTV,GAAYA,GAER,IAObQ,EAAOD,YAAc,SAErB,MAAMoC,EAAgB,CACpB,UACA,WACA,YACA,QACA,SACA,OACA,WACA,SAGWC,EAAkCjD,EAAIA,MAAmBM,IACpE,MAAM4C,EAAuC,CAAA,EACvCC,EAAqC,CAAA,EAa3C,OAXAC,OAAOC,QAAQ/C,GAAOgD,SAAQC,IAAsC,IAApCC,EAAMC,GAAyBF,EACzDP,EAAcU,SAASF,GAEzBL,EAAUK,GAAQC,EAElBP,EAAYM,GAAQC,CACtB,IAGFN,EAAU9C,SAAWC,EAAMD,SAGzBiC,MAAA/B,cAACM,EAAM0B,EAAAA,WAAMW,EAAW,CAAkB1B,SAAO,IAC9ClB,EAAMqD,aAAerD,EAAMqD,aAC1BrD,EAAMqD,aAAgBrB,MAAA/B,cAACqD,WAAcT,GAChC,IAIbF,EAAWrC,YAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.default={"overflow-hidden":"button-module_overflow-hidden__Vc5AU","text-truncate":"button-module_text-truncate__a89Bp","text-nowrap":"button-module_text-nowrap__tR-VJ","text-ellipsis":"button-module_text-ellipsis__5MFA9",button:"button-module_button__NDMQS",info:"button-module_info__O6gEW",transparent:"button-module_transparent__zbeBu",success:"button-module_success__gM25y",error:"button-module_error__q9qqo",warning:"button-module_warning__MdmiZ",tiny:"button-module_tiny__pBNwo",fluid:"button-module_fluid__GXxID",truncate:"button-module_truncate__c-G9k",animated:"button-module_animated__gLwPl",hasShadow:"button-module_hasShadow__42BQv",hasIcon:"button-module_hasIcon__dXLlJ",disabled:"button-module_disabled__hEydO"};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.default={"overflow-hidden":"button-module_overflow-hidden__Vc5AU","text-truncate":"button-module_text-truncate__a89Bp","text-nowrap":"button-module_text-nowrap__tR-VJ","text-ellipsis":"button-module_text-ellipsis__5MFA9",button:"button-module_button__NDMQS",info:"button-module_info__O6gEW",transparent:"button-module_transparent__zbeBu",success:"button-module_success__gM25y",error:"button-module_error__q9qqo",warning:"button-module_warning__MdmiZ",link:"button-module_link__e-4Fu",tiny:"button-module_tiny__pBNwo",fluid:"button-module_fluid__GXxID",truncate:"button-module_truncate__c-G9k",animated:"button-module_animated__gLwPl",hasShadow:"button-module_hasShadow__42BQv",hasIcon:"button-module_hasIcon__dXLlJ",disabled:"button-module_disabled__hEydO"};
|
|
2
2
|
//# sourceMappingURL=button.module.scss.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../../../../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),a=require("../../../utils/helpers/ui.js"),l=require("./field.module.scss.js");let n=()=>"#000000";let o=t.memo((function(){return React.createElement("span",null)}));const s=t.memo((function(t){let{options:a,value:l,inputRef:n,...o}=t;return React.createElement("div",{className:"select"},React.createElement("select",e.extends({},o,{ref:n,defaultValue:l}),a?.map((e=>React.createElement("option",{key:`${JSON.stringify(e)}`,value:"object"==typeof e?e?.value:e},"object"==typeof e?e?.label:e)))))})),c=t.memo((e=>t.createElement("textarea",e)));c.displayName="TextAreaComponent";const r=t.memo((e=>t.createElement("input",e)));r.displayName="InputComponent";const i=t.memo((i=>{let{label:m,name:u,type:p="text",value:d,defaultValue:f,placeholder:h,inputRef:R,error:N,disabled:C,userDisabled:E,withoutComponent:g,helpTextInfo:v,helpText:b,children:y,iconLeft:x,iconRight:k,addon:I,className:F,onChange:j,onChangeInner:q,onBlur:B,onFocus:D,rightIconClick:w,leftIconClick:T,options:V,style:$,...K}=i,L=r;y||"textarea"!==p||(L=c);const S=t.useCallback((e=>{E?e?.preventDefault?.():D&&D(e)}),[E,D]),_=t.useCallback((e=>{E||(q&&e?.target?(e.target.value=q(e.target.value),j&&j(e)):j&&j(e))}),[q,j,E]),A=t.useMemo((()=>void 0===d?{defaultValue:f}:{value:d}),[d,f]);return React.createElement("div",{className:a.classNames(l.default.field,(C||E)&&l.default.
|
|
1
|
+
"use strict";var e=require("../../../../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),a=require("../../../utils/helpers/ui.js"),l=require("./field.module.scss.js");let n=()=>"#000000";let o=t.memo((function(){return React.createElement("span",null)}));const s=t.memo((function(t){let{options:a,value:l,inputRef:n,...o}=t;return React.createElement("div",{className:"select"},React.createElement("select",e.extends({},o,{ref:n,defaultValue:l}),a?.map((e=>React.createElement("option",{key:`${JSON.stringify(e)}`,value:"object"==typeof e?e?.value:e},"object"==typeof e?e?.label:e)))))})),c=t.memo((e=>t.createElement("textarea",e)));c.displayName="TextAreaComponent";const r=t.memo((e=>t.createElement("input",e)));r.displayName="InputComponent";const i=t.memo((i=>{let{label:m,name:u,type:p="text",value:d,defaultValue:f,placeholder:h,inputRef:R,error:N,disabled:C,userDisabled:E,withoutComponent:g,helpTextInfo:v,helpText:b,children:y,iconLeft:x,iconRight:k,addon:I,className:F,onChange:j,onChangeInner:q,onBlur:B,onFocus:D,rightIconClick:w,leftIconClick:T,options:V,style:$,...K}=i,L=r;y||"textarea"!==p||(L=c);const S=t.useCallback((e=>{E?e?.preventDefault?.():D&&D(e)}),[E,D]),_=t.useCallback((e=>{E||(q&&e?.target?(e.target.value=q(e.target.value),j&&j(e)):j&&j(e))}),[q,j,E]),A=t.useMemo((()=>void 0===d?{defaultValue:f}:{value:d}),[d,f]);return React.createElement("div",{className:a.classNames(l.default.field,(C||E)&&l.default.disabled,F),style:$},React.createElement("label",{htmlFor:u,className:"label"},m),React.createElement("div",{className:"field "+(I?"has-addons":"")},React.createElement("div",{className:`control mainControl ${x&&!g?"has-icons-left":""} ${k?"has-icons-right":""}`},!g&&(y||"select"!==p&&!V?!y&&React.createElement(L,e.extends({name:u,id:u,ref:R,className:"input "+(N?"is-danger":""),type:p,placeholder:h},A,{onChange:_,onBlur:B,onFocus:S,onKeyDown:S,autoComplete:"off",disabled:C},K)):React.createElement(s,e.extends({name:u,id:u,inputRef:R,className:"input "+(N?"is-danger":""),type:"select",placeholder:h,value:d,options:V,onChange:j,onBlur:B,onFocus:S,onKeyDown:S,autoComplete:"off",disabled:C},K))),x&&!g&&React.createElement("span",{className:"iconLeft icon is-small is-left "+(T?"is-action":""),onClick:T},React.createElement(o,{iconName:x,color:n})),k&&React.createElement("span",{className:"iconRight icon is-small is-right "+(w?"is-action":""),onClick:w},React.createElement(o,{iconName:k,color:n})),y&&y),I&&I),v&&React.createElement("p",{className:"help"},v),b&&React.createElement("p",{className:"help "+(N?"is-danger":"")},b))}));i.displayName="Field",exports.Field=i,exports.Select=s,exports.setIconColor=e=>{n=e},exports.setIconComponent=e=>{o=e};
|
|
2
2
|
//# sourceMappingURL=Field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sources":["../../../../../../../../src/core/ui/components/field/Field.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport { FC, ReactNode, memo, useMemo, useCallback, PropsWithChildren, CSSProperties, createElement } from 'react'\n\nimport { classNames } from '../../../utils/helpers/ui'\n\nimport classes from './field.module.scss'\nimport type { FieldError, IconComponentType } from './types'\n\nlet iconColor: string | (() => string) = () => '#000000'\n\nexport const setIconColor = (color: string | (() => string)): void => {\n iconColor = color\n}\n\nlet IconComponent: IconComponentType = memo(function IconComponent() { return <span /> })\n\nexport const setIconComponent = (component: IconComponentType): void => {\n IconComponent = component\n}\n\nexport type FileWrapperProps = PropsWithChildren<unknown> & {\n className?: string\n error?: boolean\n disabled?: boolean\n userDisabled?: boolean\n css?: string\n}\n\ntype EventType = { target: any; type?: any } & Partial<Event>\nexport interface FieldProps {\n label?: string\n name?: string\n type?: string\n min?: number | string | Date | any\n max?: number | string | Date | any\n value?: string | number | readonly string[] | undefined\n defaultValue?: string | number | readonly string[] | undefined\n placeholder?: string\n inputRef?: ReactHookFormRef\n error?: boolean\n errors?: FieldError\n disabled?: boolean\n userDisabled?: boolean\n checked?: boolean\n helpTextInfo?: string\n helpText?: string\n iconLeft?: string\n iconRight?: string\n withoutComponent?: boolean\n addon?: ReactNode\n children?: ReactNode\n className?: string\n onChange?: (event?: EventType) => unknown\n // TODO, rename... something like changeHandler or valueDecorator\n onChangeInner?: (value: string | number) => string | number\n onBlur?: (event?: EventType) => void\n onFocus?: (event?: EventType | undefined) => void\n rightIconClick?: (event?: EventType) => void\n leftIconClick?: (event?: EventType) => void\n options?: any[] | null\n creatable?: boolean\n async?: boolean\n style?: CSSProperties\n [key: string]: any\n}\n\ninterface SelectProps extends FieldProps {\n id?: string\n}\n\ntype OptionObj = { label: string | number | undefined; value: string | number | undefined }\ntype Option = OptionObj | string | number\n\nexport const Select: FC<SelectProps>\n= memo<SelectProps>(\n function Select({ options, value, inputRef, ...props }: SelectProps) {\n return (\n <div className='select'>\n <select {...props} ref={inputRef} defaultValue={value}>\n {options?.map((option: Option) => (\n <option\n key={`${JSON.stringify(option)}`}\n value={typeof option === 'object' ? (option as OptionObj)?.value : option}\n >\n {typeof option === 'object' ? (option as OptionObj)?.label : option}\n </option>\n ))}\n </select>\n </div>\n )\n },\n)\nconst TextAreaComponent = memo((props) => createElement('textarea', props))\n\nTextAreaComponent.displayName = 'TextAreaComponent'\n\nconst InputComponent = memo((props) => createElement('input', props))\n\nInputComponent.displayName = 'InputComponent'\n\nexport const Field: FC<FieldProps> = memo<FieldProps>(({\n label,\n name,\n type = 'text',\n value,\n defaultValue,\n placeholder,\n inputRef,\n error,\n disabled,\n userDisabled,\n withoutComponent,\n helpTextInfo,\n helpText,\n children,\n iconLeft,\n iconRight,\n addon,\n className,\n onChange,\n onChangeInner,\n onBlur,\n onFocus,\n rightIconClick,\n leftIconClick,\n options,\n style,\n ...props\n}: FieldProps) => {\n let Component: FC<any> = InputComponent\n\n if (!children && type === 'textarea') {\n Component = TextAreaComponent\n }\n const handleFocus = useCallback((event: Event | EventType | undefined) => {\n if (userDisabled) {\n event?.preventDefault?.()\n } else {\n onFocus && onFocus(event)\n }\n }, [userDisabled, onFocus])\n\n const handleChange = useCallback((event: { target: { value: string } }) => {\n if (userDisabled) {\n return\n }\n if (onChangeInner && event?.target) {\n // eslint-disable-next-line no-param-reassign\n event.target.value = onChangeInner((event.target.value as string)) as string\n onChange && onChange(event as EventType)\n } else {\n onChange && onChange(event as EventType)\n }\n }, [onChangeInner, onChange, userDisabled])\n\n const valueProps = useMemo(() => {\n if (value === undefined) {\n return { defaultValue }\n }\n return { value }\n }, [value, defaultValue])\n\n return (\n <div\n className={classNames(\n classes.field,\n (disabled || userDisabled) && classes.disable,\n className,\n )}\n // TODO fix\n // error={error}\n style={style}\n >\n <label htmlFor={name} className='label'>{label}</label>\n <div className={`field ${addon ? 'has-addons' : ''}`}>\n <div\n className={`control mainControl ${iconLeft && !withoutComponent\n ? 'has-icons-left' : ''} ${iconRight ? 'has-icons-right' : ''}`}\n >\n {!withoutComponent && ((!children && (type === 'select' || options))\n ? (\n <Select\n name={name}\n id={name}\n inputRef={inputRef}\n className={`input ${error ? 'is-danger' : ''}`}\n type='select'\n placeholder={placeholder}\n value={value}\n options={options}\n // TODO also handle change but value versus event.target.value issue\n onChange={onChange}\n onBlur={onBlur}\n onFocus={handleFocus}\n onKeyDown={handleFocus}\n autoComplete='off'\n disabled={disabled}\n {...props}\n />\n )\n : (\n !children && (\n <Component\n name={name}\n id={name}\n ref={inputRef}\n className={`input ${error ? 'is-danger' : ''}`}\n type={type}\n placeholder={placeholder}\n {...valueProps}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={handleFocus}\n onKeyDown={handleFocus}\n autoComplete='off'\n disabled={disabled}\n {...props}\n />\n )))}\n\n {iconLeft && !withoutComponent && (\n <span\n className={`iconLeft icon is-small is-left ${leftIconClick ? 'is-action' : ''}`}\n onClick={leftIconClick}\n >\n <IconComponent\n iconName={iconLeft}\n color={iconColor}\n />\n </span>\n )}\n {iconRight && (\n <span\n className={`iconRight icon is-small is-right ${rightIconClick ? 'is-action' : ''}`}\n onClick={rightIconClick}\n >\n <IconComponent\n iconName={iconRight}\n color={iconColor}\n />\n </span>\n )}\n {children && children}\n </div>\n {addon && addon}\n </div>\n {helpTextInfo && <p className='help'>{helpTextInfo}</p>}\n {helpText && <p className={`help ${error ? 'is-danger' : ''}`}>{helpText}</p>}\n </div>\n )\n})\n\nField.displayName = 'Field'\n"],"names":["iconColor","IconComponent","memo","React","createElement","setIconComponent","Select","_ref","options","value","inputRef","props","className","_extends","ref","defaultValue","map","option","key","JSON","stringify","label","TextAreaComponent","displayName","InputComponent","Field","_ref2","name","type","placeholder","error","disabled","userDisabled","withoutComponent","helpTextInfo","helpText","children","iconLeft","iconRight","addon","onChange","onChangeInner","onBlur","onFocus","rightIconClick","leftIconClick","style","Component","handleFocus","useCallback","event","preventDefault","handleChange","target","valueProps","useMemo","undefined","classNames","classes","default","field","disable","htmlFor","id","onKeyDown","autoComplete","onClick","iconName","color","component"],"mappings":"oLAUA,IAAIA,EAAqCA,IAAM,UAM/C,IAAIC,EAAmCC,EAAAA,MAAK,WAA2B,OAAOC,MAAAC,cAAA,OAAA,KAAS,IAE1EC,MAyDAC,EACXJ,EAAIA,MACJ,SAAeK,GAAsD,IAArDC,QAAEA,EAAOC,MAAEA,EAAKC,SAAEA,KAAaC,GAAoBJ,EACjE,OACEJ,MAAAC,cAAA,MAAA,CAAKQ,UAAU,UACbT,MAAAC,cAAAS,SAAAA,EAAAA,WAAYF,EAAK,CAAEG,IAAKJ,EA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ASA,GAEXL,GAAgB/B,MAAAC,cAAA,IAAA,CAAGQ,UAAU,QAAQsB,GACrCC,GAAYhC,MAAAC,cAAA,IAAA,CAAGQ,UAAW,SAAQkB,EAAQ,YAAc,KAAOK,GAC5D,IAIVV,EAAMF,YAAc,8DAlPS6C,IAC3BpE,EAAYoE,CAAK,2BAKcC,IAC/BpE,EAAgBoE,CAAS"}
|
|
1
|
+
{"version":3,"file":"Field.js","sources":["../../../../../../../../src/core/ui/components/field/Field.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport { FC, ReactNode, memo, useMemo, useCallback, PropsWithChildren, CSSProperties, createElement } from 'react'\n\nimport { classNames } from '../../../utils/helpers/ui'\n\nimport classes from './field.module.scss'\nimport type { FieldError, IconComponentType } from './types'\n\nlet iconColor: string | (() => string) = () => '#000000'\n\nexport const setIconColor = (color: string | (() => string)): void => {\n iconColor = color\n}\n\nlet IconComponent: IconComponentType = memo(function IconComponent() { return <span /> })\n\nexport const setIconComponent = (component: IconComponentType): void => {\n IconComponent = component\n}\n\nexport type FileWrapperProps = PropsWithChildren<unknown> & {\n className?: string\n error?: boolean\n disabled?: boolean\n userDisabled?: boolean\n css?: string\n}\n\ntype EventType = { target: any; type?: any } & Partial<Event>\nexport interface FieldProps {\n label?: string\n name?: string\n type?: string\n min?: number | string | Date | any\n max?: number | string | Date | any\n value?: string | number | readonly string[] | undefined\n defaultValue?: string | number | readonly string[] | undefined\n placeholder?: string\n inputRef?: ReactHookFormRef\n error?: boolean\n errors?: FieldError\n disabled?: boolean\n userDisabled?: boolean\n checked?: boolean\n helpTextInfo?: string\n helpText?: string\n iconLeft?: string\n iconRight?: string\n withoutComponent?: boolean\n addon?: ReactNode\n children?: ReactNode\n className?: string\n onChange?: (event?: EventType) => unknown\n // TODO, rename... something like changeHandler or valueDecorator\n onChangeInner?: (value: string | number) => string | number\n onBlur?: (event?: EventType) => void\n onFocus?: (event?: EventType | undefined) => void\n rightIconClick?: (event?: EventType) => void\n leftIconClick?: (event?: EventType) => void\n options?: any[] | null\n creatable?: boolean\n async?: boolean\n style?: CSSProperties\n [key: string]: any\n}\n\ninterface SelectProps extends FieldProps {\n id?: string\n}\n\ntype OptionObj = { label: string | number | undefined; value: string | number | undefined }\ntype Option = OptionObj | string | number\n\nexport const Select: FC<SelectProps>\n= memo<SelectProps>(\n function Select({ options, value, inputRef, ...props }: SelectProps) {\n return (\n <div className='select'>\n <select {...props} ref={inputRef} defaultValue={value}>\n {options?.map((option: Option) => (\n <option\n key={`${JSON.stringify(option)}`}\n value={typeof option === 'object' ? (option as OptionObj)?.value : option}\n >\n {typeof option === 'object' ? (option as OptionObj)?.label : option}\n </option>\n ))}\n </select>\n </div>\n )\n },\n)\nconst TextAreaComponent = memo((props) => createElement('textarea', props))\n\nTextAreaComponent.displayName = 'TextAreaComponent'\n\nconst InputComponent = memo((props) => createElement('input', props))\n\nInputComponent.displayName = 'InputComponent'\n\nexport const Field: FC<FieldProps> = memo<FieldProps>(({\n label,\n name,\n type = 'text',\n value,\n defaultValue,\n placeholder,\n inputRef,\n error,\n disabled,\n userDisabled,\n withoutComponent,\n helpTextInfo,\n helpText,\n children,\n iconLeft,\n iconRight,\n addon,\n className,\n onChange,\n onChangeInner,\n onBlur,\n onFocus,\n rightIconClick,\n leftIconClick,\n options,\n style,\n ...props\n}: FieldProps) => {\n let Component: FC<any> = InputComponent\n\n if (!children && type === 'textarea') {\n Component = TextAreaComponent\n }\n const handleFocus = useCallback((event: Event | EventType | undefined) => {\n if (userDisabled) {\n event?.preventDefault?.()\n } else {\n onFocus && onFocus(event)\n }\n }, [userDisabled, onFocus])\n\n const handleChange = useCallback((event: { target: { value: string } }) => {\n if (userDisabled) {\n return\n }\n if (onChangeInner && event?.target) {\n // eslint-disable-next-line no-param-reassign\n event.target.value = onChangeInner((event.target.value as string)) as string\n onChange && onChange(event as EventType)\n } else {\n onChange && onChange(event as EventType)\n }\n }, [onChangeInner, onChange, userDisabled])\n\n const valueProps = useMemo(() => {\n if (value === undefined) {\n return { defaultValue }\n }\n return { value }\n }, [value, defaultValue])\n\n return (\n <div\n className={classNames(\n classes.field,\n (disabled || userDisabled) && classes.disabled,\n className,\n )}\n // TODO fix\n // error={error}\n style={style}\n >\n <label htmlFor={name} className='label'>{label}</label>\n <div className={`field ${addon ? 'has-addons' : ''}`}>\n <div\n className={`control mainControl ${iconLeft && !withoutComponent\n ? 'has-icons-left' : ''} ${iconRight ? 'has-icons-right' : ''}`}\n >\n {!withoutComponent && ((!children && (type === 'select' || options))\n ? (\n <Select\n name={name}\n id={name}\n inputRef={inputRef}\n className={`input ${error ? 'is-danger' : ''}`}\n type='select'\n placeholder={placeholder}\n value={value}\n options={options}\n // TODO also handle change but value versus event.target.value issue\n onChange={onChange}\n onBlur={onBlur}\n onFocus={handleFocus}\n onKeyDown={handleFocus}\n autoComplete='off'\n disabled={disabled}\n {...props}\n />\n )\n : (\n !children && (\n <Component\n name={name}\n id={name}\n ref={inputRef}\n className={`input ${error ? 'is-danger' : ''}`}\n type={type}\n placeholder={placeholder}\n {...valueProps}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={handleFocus}\n onKeyDown={handleFocus}\n autoComplete='off'\n disabled={disabled}\n {...props}\n />\n )))}\n\n {iconLeft && !withoutComponent && (\n <span\n className={`iconLeft icon is-small is-left ${leftIconClick ? 'is-action' : ''}`}\n onClick={leftIconClick}\n >\n <IconComponent\n iconName={iconLeft}\n color={iconColor}\n />\n </span>\n )}\n {iconRight && (\n <span\n className={`iconRight icon is-small is-right ${rightIconClick ? 'is-action' : ''}`}\n onClick={rightIconClick}\n >\n <IconComponent\n iconName={iconRight}\n color={iconColor}\n />\n </span>\n )}\n {children && children}\n </div>\n {addon && addon}\n </div>\n {helpTextInfo && <p className='help'>{helpTextInfo}</p>}\n {helpText && <p className={`help ${error ? 'is-danger' : ''}`}>{helpText}</p>}\n </div>\n )\n})\n\nField.displayName = 'Field'\n"],"names":["iconColor","IconComponent","memo","React","createElement","setIconComponent","Select","_ref","options","value","inputRef","props","className","_extends","ref","defaultValue","map","option","key","JSON","stringify","label","TextAreaComponent","displayName","InputComponent","Field","_ref2","name","type","placeholder","error","disabled","userDisabled","withoutComponent","helpTextInfo","helpText","children","iconLeft","iconRight","addon","onChange","onChangeInner","onBlur","onFocus","rightIconClick","leftIconClick","style","Component","handleFocus","useCallback","event","preventDefault","handleChange","target","valueProps","useMemo","undefined","classNames","classes","default","field","htmlFor","id","onKeyDown","autoComplete","onClick","iconName","color","component"],"mappings":"oLAUA,IAAIA,EAAqCA,IAAM,UAM/C,IAAIC,EAAmCC,EAAAA,MAAK,WAA2B,OAAOC,MAAAC,cAAA,OAAA,KAAS,IAE1EC,MAyDAC,EACXJ,EAAIA,MACJ,SAAeK,GAAsD,IAArDC,QAAEA,EAAOC,MAAEA,EAAKC,SAAEA,KAAaC,GAAoBJ,EACjE,OACEJ,MAAAC,cAAA,MAAA,CAAKQ,UAAU,UACbT,MAAAC,cAAAS,SAAAA,EAAAA,WAAYF,EAAK,CAAEG,IAAKJ,EAAUK,aAAcN,IAC7CD,GAASQ,KAAKC,GACbd,MAAAC,cAAA,SAAA,CACEc,IAAK,GAAGC,KAAKC,UAAUH,KACvBR,MAAyB,iBAAXQ,EAAuBA,GAAsBR,MAAQQ,GAEhD,iBAAXA,EAAuBA,GAAsBI,MAAQJ,MAMzE,IAEIK,EAAoBpB,EAAIA,MAAES,GAAUP,EAAaA,cAAC,WAAYO,KAEpEW,EAAkBC,YAAc,oBAEhC,MAAMC,EAAiBtB,EAAIA,MAAES,GAAUP,EAAaA,cAAC,QAASO,KAE9Da,EAAeD,YAAc,uBAEhBE,EAAwBvB,EAAIA,MAAawB,IA4BpC,IA5BqCL,MACrDA,EAAKM,KACLA,EAAIC,KACJA,EAAO,OAAMnB,MACbA,EAAKM,aACLA,EAAYc,YACZA,EAAWnB,SACXA,EAAQoB,MACRA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F,KAAMA,EACNC,YAAaA,GACTyB,EAAU,CACdd,SAAUY,EACVV,OAAQA,EACRC,QAASK,EACTe,UAAWf,EACXgB,aAAa,MACbjC,SAAUA,GACNpB,IAnCNR,MAAAC,cAACE,EAAMO,EAAAA,QAAA,CACLc,KAAMA,EACNmC,GAAInC,EACJjB,SAAUA,EACVE,UAAW,UAASkB,EAAQ,YAAc,IAC1CF,KAAK,SACLC,YAAaA,EACbpB,MAAOA,EACPD,QAASA,EAETgC,SAAUA,EACVE,OAAQA,EACRC,QAASK,EACTe,UAAWf,EACXgB,aAAa,MACbjC,SAAUA,GACNpB,KAuBT0B,IAAaJ,GACZ9B,MAAAC,cAAA,OAAA,CACEQ,UAAW,mCAAkCiC,EAAgB,YAAc,IAC3EoB,QAASpB,GAET1C,MAAAC,cAACH,EAAa,CACZiE,SAAU7B,EACV8B,MAAOnE,KAIZsC,GACCnC,MAAAC,cAAA,OAAA,CACEQ,UAAW,qCAAoCgC,EAAiB,YAAc,IAC9EqB,QAASrB,GAETzC,MAAAC,cAACH,EAAa,CACZiE,SAAU5B,EACV6B,MAAOnE,KAIZoC,GAAYA,GAEdG,GAASA,GAEXL,GAAgB/B,MAAAC,cAAA,IAAA,CAAGQ,UAAU,QAAQsB,GACrCC,GAAYhC,MAAAC,cAAA,IAAA,CAAGQ,UAAW,SAAQkB,EAAQ,YAAc,KAAOK,GAC5D,IAIVV,EAAMF,YAAc,8DAlPS4C,IAC3BnE,EAAYmE,CAAK,2BAKcC,IAC/BnE,EAAgBmE,CAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peregrineMQ.js","sources":["../../../../../../../../src/core/utils/appState/peregrineMQ/peregrineMQ.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid'\n\nimport {\n Callback, Config, PeregrineMQApi, PublishToChannelReturnType,\n PublishReturnType, SubscribersSet,\n UnsubscribeOptions, NON_EXISTENT_CHANNEL_TYPE,\n NON_EXISTENT_CHANNEL,\n} from './peregrineMQ.types'\n\n\nexport class PeregrineMQClearError extends Error {\n constructor() {\n super('Clearing PeregrineMQ is not allowed. Please read the documentation for more information.')\n this.name = 'PeregrineMQClearError'\n }\n}\n\n/**\n * Represents a message queue with publish/subscribe functionality.\n */\nexport class PeregrineMQ implements PeregrineMQApi {\n private id: string\n\n private config: Config = {\n allowAutoPrune: false,\n pruneInterval: 10000,\n allowClear: false,\n }\n\n /**\n * The map of channels and their subscribers sets.\n */\n private channels: Map<string, SubscribersSet> = new Map()\n\n /**\n * The map of listeners and their subscribed channels.\n */\n private listeners: Map<Callback, SubscribersSet[]> = new Map()\n\n /**\n * Adds a callback as a listener to a channel.\n * @param callback The callback function to add as a listener.\n * @param channel The channel to add the listener to.\n */\n private addListener = (callback: Callback, channel: string): void => {\n const listener = this.listeners.get(callback)\n const subscribersSet = this.channels.get(channel)\n\n if (subscribersSet) {\n if (listener) {\n listener.push(subscribersSet)\n } else {\n this.listeners.set(callback, [subscribersSet])\n }\n }\n }\n\n /**\n * Removes the callback from the listeners collection if it is not subscribed to any channels.\n * @description Removes the callback only when it is not present in any other subscriberSet\n * (Ref to Map<string, SubscribersSet>).\n * @param callback The callback to remove from listeners.\n */\n private removeListener = (callback: Callback): void => {\n const channelSubscriberSets = this.listeners.get(callback)\n let isEmpty = true\n\n // eslint-disable-next-line no-restricted-syntax\n for (const channelSubscriberSet of channelSubscriberSets || []) {\n isEmpty = !channelSubscriberSet.has(callback)\n if (!isEmpty) {\n break\n }\n }\n\n if (isEmpty) {\n this.listeners.delete(callback)\n }\n }\n\n /**\n * Publishes data to a channel.\n * @param channel The channel to publish the data to.\n * @param isParent Indicates if the channel is a parent channel.\n * @param data The data to publish.\n * @returns A boolean indicating if the publication was successful.\n */\n private publishToChannel = (\n channel: string, isParent: boolean, data?: unknown,\n ): PublishToChannelReturnType => {\n const subscribersSet = this.channels.get(channel)\n\n if (!subscribersSet) {\n return NON_EXISTENT_CHANNEL as NON_EXISTENT_CHANNEL_TYPE\n }\n\n const iterator = subscribersSet[Symbol.iterator]()\n let subscriberFunc = iterator.next().value\n\n const results = []\n\n // eslint-disable-next-line no-plusplus\n while (subscriberFunc) {\n // eslint-disable-next-line no-await-in-loop\n results.push(subscriberFunc(channel, data))\n subscriberFunc = iterator.next().value\n }\n return results?.length === 1 ? results[0] : results\n }\n\n /**\n * Creates a new instance of PeregrineMQ.\n * @param id Specific instance of PeregrineMQ identifier\n * @param config The configuration options for PeregrineMQ.\n */\n constructor(id?: string, config?: Config) {\n this.id = id || uuidv4()\n this.configure(config || {})\n }\n\n /**\n * Gets the total number of subscribers across all channels.\n */\n get length(): number {\n return [...this.channels.values()].reduce((acc, subscribersList) => acc + subscribersList.size, 0)\n }\n\n /**\n * Configures PeregrineMQ with the specified options.\n * @param config The configuration options for PeregrineMQ.\n * @returns An object containing the prune interval handler (if auto prune is enabled).\n */\n configure = (config: Config): {\n clearPruneInterval?: () => void\n restartPruneInterval?: () => void\n } => {\n this.config = config\n const { allowAutoPrune, pruneInterval } = config\n\n let pruneIntervalHandler: ReturnType<typeof setInterval>\n\n if (allowAutoPrune) {\n pruneIntervalHandler = setInterval(() => {\n this.prune()\n }, pruneInterval)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instance: PeregrineMQ = this\n\n return {\n ...(allowAutoPrune\n ? {\n clearPruneInterval: (): void => {\n clearInterval(pruneIntervalHandler)\n },\n restartPruneInterval: (): void => {\n clearInterval(pruneIntervalHandler)\n pruneIntervalHandler = setInterval(() => {\n instance.prune()\n }, pruneInterval)\n },\n }\n : {}),\n }\n }\n\n /**\n * Gets an array of all channels.\n * @returns An array of channel names.\n */\n getChannels = (): string[] => [...this.channels.keys()]\n\n /**\n * Prunes the channels with no subscribers.\n * @returns An array of pruned channel names.\n */\n prune = (): string[] => {\n const iterator = this.channels[Symbol.iterator]()\n let subscribersSet = iterator.next().value\n const prunedChannels: string[] = []\n\n // eslint-disable-next-line no-plusplus\n while (subscribersSet) {\n if (subscribersSet[1]?.size === 0) {\n prunedChannels.push(subscribersSet[0])\n this.channels.delete(subscribersSet[0])\n }\n subscribersSet = iterator.next().value\n }\n\n return prunedChannels\n }\n\n /**\n * Removes a channel and its subscribers.\n * @param channel The channel to remove.\n * @returns A boolean indicating if the channel was successfully removed.\n */\n removeChannel = (channel: string): boolean => {\n const subscribersSet = this.channels.get(channel)\n\n if (subscribersSet && subscribersSet.size > 0) {\n const channelListeners = [...subscribersSet || []]\n\n subscribersSet.clear()\n\n let index = channelListeners.length\n\n // eslint-disable-next-line no-plusplus\n while (index--) {\n this.removeListener(channelListeners[index])\n }\n }\n\n return this.channels.delete(channel)\n }\n\n /**\n * Publishes data to a channel.\n * @param channel The channel to publish the data to.\n * @param data The data to publish.\n * @returns A boolean indicating if the publication was successful.\n */\n publish = <T>(channel: string, data?: T): PublishReturnType => {\n if (channel.includes('.')) {\n const nestedChannels = channel.split('.')\n\n let { length } = nestedChannels\n let it = 0\n const results = []\n\n // eslint-disable-next-line no-plusplus\n while (length--) {\n // eslint-disable-next-line no-await-in-loop\n const result = this.publishToChannel(\n nestedChannels.slice(0, it + 1).join('.'),\n length !== nestedChannels.length - 1,\n data,\n )\n\n it += 1\n results.push(result)\n }\n return results\n }\n\n return this.publishToChannel(channel, false, data)\n }\n\n /**\n * Subscribes a callback to a channel.\n * @param channel The channel to subscribe to.\n * @param callback The callback function to subscribe.\n * @returns A function to unsubscribe the callback.\n */\n subscribe = (channel: string, callback: Callback): () => boolean => {\n const subscribersList = this.channels.get(channel)\n\n if (subscribersList) {\n subscribersList.add(callback)\n } else {\n this.channels.set(channel, new Set([callback]))\n }\n\n this.addListener(callback, channel)\n\n return () => this.unsubscribe(callback, { channel, prune: true })\n }\n\n /**\n * Unsubscribes a callback from a channel or all channels.\n * @param callback The callback function to unsubscribe.\n * @param options Optional unsubscribe options.\n * @returns A boolean indicating if the callback was successfully unsubscribed.\n */\n unsubscribe = (callback: Callback, options?: UnsubscribeOptions): boolean => {\n const { channel, prune } = options || {}\n\n let unsubscribed = false\n\n if (channel) {\n const subscriberSet = this.channels.get(channel)\n\n unsubscribed = subscriberSet ? subscriberSet.delete(callback) : false\n if (prune && subscriberSet?.size === 0) {\n this.channels.delete(channel)\n }\n\n this.removeListener(callback)\n\n return unsubscribed\n }\n\n const subscriberSetArray = this.listeners.get(callback) || []\n\n // remove callback form listeners and all channels\n // TODO remove only if has\n // eslint-disable-next-line no-restricted-syntax\n for (const subscriberSet of subscriberSetArray) {\n unsubscribed = subscriberSet.delete(callback) as boolean\n\n if (prune && subscriberSet.size === 0) {\n this.prune()\n }\n }\n\n this.listeners.delete(callback)\n\n return unsubscribed\n }\n\n /**\n * Checks if a callback is subscribed to a specific channel or any channel.\n * @param callback The callback function to check.\n * @param channel Optional channel name to check subscription for.\n * @returns A boolean indicating if the callback is subscribed.\n */\n isSubscribed = (callback: Callback, channel?: string): boolean => {\n if (channel) {\n const subscribersList = this.channels.get(channel)\n\n return subscribersList ? subscribersList.has(callback) : false\n }\n\n return this.listeners.has(callback)\n }\n\n /**\n * Clears all channels and listeners.\n * @throws {Error} If clearing PeregrineMQ is not allowed.\n */\n clear = (): void => {\n if (this.config.allowClear) {\n this.channels.clear()\n this.listeners.clear()\n } else {\n throw new PeregrineMQClearError()\n }\n }\n\n /**\n * Returns the specific instance of PeregrineMQ.\n * @returns A string identifier of the specific instance of PeregrineMQ.\n */\n getId = (): string => this.id\n}\n"],"names":["PeregrineMQClearError","Error","constructor","super","this","name","id","config","allowAutoPrune","pruneInterval","allowClear","channels","Map","listeners","addListener","callback","channel","listener","get","subscribersSet","push","set","removeListener","channelSubscriberSets","isEmpty","channelSubscriberSet","has","delete","publishToChannel","isParent","data","NON_EXISTENT_CHANNEL","iterator","Symbol","subscriberFunc","next","value","results","length","configure","pruneIntervalHandler","setInterval","prune","instance","clearPruneInterval","clearInterval","restartPruneInterval","getChannels","keys","prunedChannels","size","removeChannel","channelListeners","clear","index","publish","includes","nestedChannels","split","it","result","slice","join","subscribe","subscribersList","add","Set","unsubscribe","options","unsubscribed","subscriberSet","subscriberSetArray","isSubscribed","getId","uuidv4","values","reduce","acc"],"mappings":"0HAUO,MAAMA,UAA8BC,MACzCC,WAAAA,GACEC,MAAM,4FACNC,KAAKC,KAAO,uBACd,sBAMK,MA+FLH,WAAAA,CAAYI,EAAaC,GAAiBH,KA9FlCE,QAAE,EAAAF,KAEFG,OAAiB,CACvBC,gBAAgB,EAChBC,cAAe,IACfC,YAAY,GAGdN,KAGQO,SAAwC,IAAIC,IAEpDR,KAGQS,UAA6C,IAAID,IAEzDR,KAKQU,YAAc,CAACC,EAAoBC,KACzC,MAAMC,EAAWb,KAAKS,UAAUK,IAAIH,GAC9BI,EAAiBf,KAAKO,SAASO,IAAIF,GAErCG,IACEF,EACFA,EAASG,KAAKD,GAEdf,KAAKS,UAAUQ,IAAIN,EAAU,CAACI,IAElC,EAGFf,KAMQkB,eAAkBP,IACxB,MAAMQ,EAAwBnB,KAAKS,UAAUK,IAAIH,GACjD,IAAIS,GAAU,EAGd,IAAK,MAAMC,KAAwBF,GAAyB,GAE1D,GADAC,GAAWC,EAAqBC,IAAIX,IAC/BS,EACH,MAIAA,GACFpB,KAAKS,UAAUc,OAAOZ,EACxB,EAGFX,KAOQwB,iBAAmB,CACzBZ,EAAiBa,EAAmBC,KAEpC,MAAMX,EAAiBf,KAAKO,SAASO,IAAIF,GAEzC,IAAKG,EACH,OAAOY,uBAGT,MAAMC,EAAWb,EAAec,OAAOD,YACvC,IAAIE,EAAiBF,EAASG,OAAOC,MAErC,MAAMC,EAAU,GAGhB,KAAOH,GAELG,EAAQjB,KAAKc,EAAelB,EAASc,IACrCI,EAAiBF,EAASG,OAAOC,MAEnC,OAA2B,IAApBC,GAASC,OAAeD,EAAQ,GAAKA,CAAO,EAoBrDjC,KAKAmC,UAAahC,IAIXH,KAAKG,OAASA,EACd,MAAMC,eAAEA,EAAcC,cAAEA,GAAkBF,EAE1C,IAAIiC,EAEAhC,IACFgC,EAAuBC,aAAY,KACjCrC,KA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EAAAA,UAChBtE,KAAKmC,UAAUhC,GAAU,CAAA,EAC3B,CAKA,UAAI+B,GACF,MAAO,IAAIlC,KAAKO,SAASgE,UAAUC,QAAO,CAACC,EAAKb,IAAoBa,EAAMb,EAAgBd,MAAM,EAClG"}
|
|
1
|
+
{"version":3,"file":"peregrineMQ.js","sources":["../../../../../../../../src/core/utils/appState/peregrineMQ/peregrineMQ.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid'\n\nimport {\n Callback, Config, PeregrineMQApi, PublishToChannelReturnType,\n PublishReturnType, SubscribersSet,\n UnsubscribeOptions, NON_EXISTENT_CHANNEL_TYPE,\n NON_EXISTENT_CHANNEL,\n CallbackPayload,\n} from './peregrineMQ.types'\n\n\nexport class PeregrineMQClearError extends Error {\n constructor() {\n super('Clearing PeregrineMQ is not allowed. Please read the documentation for more information.')\n this.name = 'PeregrineMQClearError'\n }\n}\n\n/**\n * Represents a message queue with publish/subscribe functionality.\n */\nexport class PeregrineMQ implements PeregrineMQApi {\n private id: string\n\n private config: Config = {\n allowAutoPrune: false,\n pruneInterval: 10000,\n allowClear: false,\n }\n\n /**\n * The map of channels and their subscribers sets.\n */\n private channels: Map<string, SubscribersSet> = new Map()\n\n /**\n * The map of listeners and their subscribed channels.\n */\n private listeners: Map<Callback, SubscribersSet[]> = new Map()\n\n /**\n * Adds a callback as a listener to a channel.\n * @param callback The callback function to add as a listener.\n * @param channel The channel to add the listener to.\n */\n private addListener = (callback: Callback, channel: string): void => {\n const listener = this.listeners.get(callback)\n const subscribersSet = this.channels.get(channel)\n\n if (subscribersSet) {\n if (listener) {\n listener.push(subscribersSet)\n } else {\n this.listeners.set(callback, [subscribersSet])\n }\n }\n }\n\n /**\n * Removes the callback from the listeners collection if it is not subscribed to any channels.\n * @description Removes the callback only when it is not present in any other subscriberSet\n * (Ref to Map<string, SubscribersSet>).\n * @param callback The callback to remove from listeners.\n */\n private removeListener = (callback: Callback): void => {\n const channelSubscriberSets = this.listeners.get(callback)\n let isEmpty = true\n\n // eslint-disable-next-line no-restricted-syntax\n for (const channelSubscriberSet of channelSubscriberSets || []) {\n isEmpty = !channelSubscriberSet.has(callback)\n if (!isEmpty) {\n break\n }\n }\n\n if (isEmpty) {\n this.listeners.delete(callback)\n }\n }\n\n /**\n * Publishes data to a channel.\n * @param channel The channel to publish the data to.\n * @param isParent Indicates if the channel is a parent channel.\n * @param data The data to publish.\n * @returns A boolean indicating if the publication was successful.\n */\n private publishToChannel = (\n channel: string, isParent: boolean, data?: unknown,\n ): PublishToChannelReturnType => {\n const subscribersSet = this.channels.get(channel)\n\n if (!subscribersSet) {\n return NON_EXISTENT_CHANNEL as NON_EXISTENT_CHANNEL_TYPE\n }\n\n const iterator = subscribersSet[Symbol.iterator]()\n let subscriberFunc = iterator.next().value\n\n const results = []\n\n // eslint-disable-next-line no-plusplus\n while (subscriberFunc) {\n // eslint-disable-next-line no-await-in-loop\n results.push(subscriberFunc(channel, data as CallbackPayload))\n subscriberFunc = iterator.next().value\n }\n return results?.length === 1 ? results[0] : results\n }\n\n /**\n * Creates a new instance of PeregrineMQ.\n * @param id Specific instance of PeregrineMQ identifier\n * @param config The configuration options for PeregrineMQ.\n */\n constructor(id?: string, config?: Config) {\n this.id = id || uuidv4()\n this.configure(config || {})\n }\n\n /**\n * Gets the total number of subscribers across all channels.\n */\n get length(): number {\n return [...this.channels.values()].reduce((acc, subscribersList) => acc + subscribersList.size, 0)\n }\n\n /**\n * Configures PeregrineMQ with the specified options.\n * @param config The configuration options for PeregrineMQ.\n * @returns An object containing the prune interval handler (if auto prune is enabled).\n */\n configure = (config: Config): {\n clearPruneInterval?: () => void\n restartPruneInterval?: () => void\n } => {\n this.config = config\n const { allowAutoPrune, pruneInterval } = config\n\n let pruneIntervalHandler: ReturnType<typeof setInterval>\n\n if (allowAutoPrune) {\n pruneIntervalHandler = setInterval(() => {\n this.prune()\n }, pruneInterval)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instance: PeregrineMQ = this\n\n return {\n ...(allowAutoPrune\n ? {\n clearPruneInterval: (): void => {\n clearInterval(pruneIntervalHandler)\n },\n restartPruneInterval: (): void => {\n clearInterval(pruneIntervalHandler)\n pruneIntervalHandler = setInterval(() => {\n instance.prune()\n }, pruneInterval)\n },\n }\n : {}),\n }\n }\n\n /**\n * Gets an array of all channels.\n * @returns An array of channel names.\n */\n getChannels = (): string[] => [...this.channels.keys()]\n\n /**\n * Prunes the channels with no subscribers.\n * @returns An array of pruned channel names.\n */\n prune = (): string[] => {\n const iterator = this.channels[Symbol.iterator]()\n let subscribersSet = iterator.next().value\n const prunedChannels: string[] = []\n\n // eslint-disable-next-line no-plusplus\n while (subscribersSet) {\n if (subscribersSet[1]?.size === 0) {\n prunedChannels.push(subscribersSet[0])\n this.channels.delete(subscribersSet[0])\n }\n subscribersSet = iterator.next().value\n }\n\n return prunedChannels\n }\n\n /**\n * Removes a channel and its subscribers.\n * @param channel The channel to remove.\n * @returns A boolean indicating if the channel was successfully removed.\n */\n removeChannel = (channel: string): boolean => {\n const subscribersSet = this.channels.get(channel)\n\n if (subscribersSet && subscribersSet.size > 0) {\n const channelListeners = [...subscribersSet || []]\n\n subscribersSet.clear()\n\n let index = channelListeners.length\n\n // eslint-disable-next-line no-plusplus\n while (index--) {\n this.removeListener(channelListeners[index])\n }\n }\n\n return this.channels.delete(channel)\n }\n\n /**\n * Publishes data to a channel.\n * @param channel The channel to publish the data to.\n * @param data The data to publish.\n * @returns A boolean indicating if the publication was successful.\n */\n publish = <T>(channel: string, data?: T): PublishReturnType => {\n if (channel.includes('.')) {\n const nestedChannels = channel.split('.')\n\n let { length } = nestedChannels\n let it = 0\n const results = []\n\n // eslint-disable-next-line no-plusplus\n while (length--) {\n // eslint-disable-next-line no-await-in-loop\n const result = this.publishToChannel(\n nestedChannels.slice(0, it + 1).join('.'),\n length !== nestedChannels.length - 1,\n data,\n )\n\n it += 1\n results.push(result)\n }\n return results\n }\n\n return this.publishToChannel(channel, false, data)\n }\n\n /**\n * Subscribes a callback to a channel.\n * @param channel The channel to subscribe to.\n * @param callback The callback function to subscribe.\n * @returns A function to unsubscribe the callback.\n */\n subscribe = (channel: string, callback: Callback): () => boolean => {\n const subscribersList = this.channels.get(channel)\n\n if (subscribersList) {\n subscribersList.add(callback)\n } else {\n this.channels.set(channel, new Set([callback]))\n }\n\n this.addListener(callback, channel)\n\n return () => this.unsubscribe(callback, { channel, prune: true })\n }\n\n /**\n * Unsubscribes a callback from a channel or all channels.\n * @param callback The callback function to unsubscribe.\n * @param options Optional unsubscribe options.\n * @returns A boolean indicating if the callback was successfully unsubscribed.\n */\n unsubscribe = (callback: Callback, options?: UnsubscribeOptions): boolean => {\n const { channel, prune } = options || {}\n\n let unsubscribed = false\n\n if (channel) {\n const subscriberSet = this.channels.get(channel)\n\n unsubscribed = subscriberSet ? subscriberSet.delete(callback) : false\n if (prune && subscriberSet?.size === 0) {\n this.channels.delete(channel)\n }\n\n this.removeListener(callback)\n\n return unsubscribed\n }\n\n const subscriberSetArray = this.listeners.get(callback) || []\n\n // remove callback form listeners and all channels\n // TODO remove only if has\n // eslint-disable-next-line no-restricted-syntax\n for (const subscriberSet of subscriberSetArray) {\n unsubscribed = subscriberSet.delete(callback) as boolean\n\n if (prune && subscriberSet.size === 0) {\n this.prune()\n }\n }\n\n this.listeners.delete(callback)\n\n return unsubscribed\n }\n\n /**\n * Checks if a callback is subscribed to a specific channel or any channel.\n * @param callback The callback function to check.\n * @param channel Optional channel name to check subscription for.\n * @returns A boolean indicating if the callback is subscribed.\n */\n isSubscribed = (callback: Callback, channel?: string): boolean => {\n if (channel) {\n const subscribersList = this.channels.get(channel)\n\n return subscribersList ? subscribersList.has(callback) : false\n }\n\n return this.listeners.has(callback)\n }\n\n /**\n * Clears all channels and listeners.\n * @throws {Error} If clearing PeregrineMQ is not allowed.\n */\n clear = (): void => {\n if (this.config.allowClear) {\n this.channels.clear()\n this.listeners.clear()\n } else {\n throw new PeregrineMQClearError()\n }\n }\n\n /**\n * Returns the specific instance of PeregrineMQ.\n * @returns A string identifier of the specific instance of PeregrineMQ.\n */\n getId = (): string => this.id\n}\n"],"names":["PeregrineMQClearError","Error","constructor","super","this","name","id","config","allowAutoPrune","pruneInterval","allowClear","channels","Map","listeners","addListener","callback","channel","listener","get","subscribersSet","push","set","removeListener","channelSubscriberSets","isEmpty","channelSubscriberSet","has","delete","publishToChannel","isParent","data","NON_EXISTENT_CHANNEL","iterator","Symbol","subscriberFunc","next","value","results","length","configure","pruneIntervalHandler","setInterval","prune","instance","clearPruneInterval","clearInterval","restartPruneInterval","getChannels","keys","prunedChannels","size","removeChannel","channelListeners","clear","index","publish","includes","nestedChannels","split","it","result","slice","join","subscribe","subscribersList","add","Set","unsubscribe","options","unsubscribed","subscriberSet","subscriberSetArray","isSubscribed","getId","uuidv4","values","reduce","acc"],"mappings":"0HAWO,MAAMA,UAA8BC,MACzCC,WAAAA,GACEC,MAAM,4FACNC,KAAKC,KAAO,uBACd,sBAMK,MA+FLH,WAAAA,CAAYI,EAAaC,GAAiBH,KA9FlCE,QAAE,EAAAF,KAEFG,OAAiB,CACvBC,gBAAgB,EAChBC,cAAe,IACfC,YAAY,GAGdN,KAGQO,SAAwC,IAAIC,IAEpDR,KAGQS,UAA6C,IAAID,IAEzDR,KAKQU,YAAc,CAACC,EAAoBC,KACzC,MAAMC,EAAWb,KAAKS,UAAUK,IAAIH,GAC9BI,EAAiBf,KAAKO,SAASO,IAAIF,GAErCG,IACEF,EACFA,EAASG,KAAKD,GAEdf,KAAKS,UAAUQ,IAAIN,EAAU,CAACI,IAElC,EAGFf,KAMQkB,eAAkBP,IACxB,MAAMQ,EAAwBnB,KAAKS,UAAUK,IAAIH,GACjD,IAAIS,GAAU,EAGd,IAAK,MAAMC,KAAwBF,GAAyB,GAE1D,GADAC,GAAWC,EAAqBC,IAAIX,IAC/BS,EACH,MAIAA,GACFpB,KAAKS,UAAUc,OAAOZ,EACxB,EAGFX,KAOQwB,iBAAmB,CACzBZ,EAAiBa,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,KAAKsC,QAMT,OAFAtC,KAAKS,UAAUc,OAAOZ,GAEfsD,CAAY,EAGrBjE,KAMAoE,aAAe,CAACzD,EAAoBC,KAClC,GAAIA,EAAS,CACX,MAAMgD,EAAkB5D,KAAKO,SAASO,IAAIF,GAE1C,QAAOgD,GAAkBA,EAAgBtC,IAAIX,EAC/C,CAEA,OAAOX,KAAKS,UAAUa,IAAIX,EAAS,EAGrCX,KAIAiD,MAAQ,KACN,IAAIjD,KAAKG,OAAOG,WAId,MAAM,IAAIV,EAHVI,KAAKO,SAAS0C,QACdjD,KAAKS,UAAUwC,OAGjB,EAGFjD,KAIAqE,MAAQ,IAAcrE,KAAKE,GArOzBF,KAAKE,GAAKA,GAAMoE,EAAAA,UAChBtE,KAAKmC,UAAUhC,GAAU,CAAA,EAC3B,CAKA,UAAI+B,GACF,MAAO,IAAIlC,KAAKO,SAASgE,UAAUC,QAAO,CAACC,EAAKb,IAAoBa,EAAMb,EAAgBd,MAAM,EAClG"}
|
package/dist/lib/esm/index.css
CHANGED
|
@@ -392,6 +392,19 @@
|
|
|
392
392
|
.button-module_button__NDMQS.button-module_warning__MdmiZ.button-module_transparent__zbeBu {
|
|
393
393
|
border: 1px solid #FFCC3D !important;
|
|
394
394
|
}
|
|
395
|
+
.button-module_button__NDMQS.button-module_link__e-4Fu {
|
|
396
|
+
border: none !important;
|
|
397
|
+
background-color: transparent !important;
|
|
398
|
+
background: transparent !important;
|
|
399
|
+
}
|
|
400
|
+
.button-module_button__NDMQS.button-module_link__e-4Fu:hover {
|
|
401
|
+
border: none !important;
|
|
402
|
+
background-color: transparent !important;
|
|
403
|
+
background: transparent !important;
|
|
404
|
+
}
|
|
405
|
+
.button-module_button__NDMQS.button-module_link__e-4Fu:hover * {
|
|
406
|
+
text-decoration: underline !important;
|
|
407
|
+
}
|
|
395
408
|
.button-module_button__NDMQS.button-module_transparent__zbeBu {
|
|
396
409
|
border: none !important;
|
|
397
410
|
background-color: transparent !important;
|
|
@@ -432,6 +445,9 @@
|
|
|
432
445
|
.button-module_button__NDMQS:hover.button-module_animated__gLwPl {
|
|
433
446
|
transform: scale(1.2);
|
|
434
447
|
}
|
|
448
|
+
.button-module_button__NDMQS:hover.button-module_transparent__zbeBu {
|
|
449
|
+
background-color: rgba(197, 197, 197, 0.1254901961) !important;
|
|
450
|
+
}
|
|
435
451
|
.button-module_button__NDMQS.button-module_disabled__hEydO {
|
|
436
452
|
user-select: none;
|
|
437
453
|
pointer-events: none;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{gsap as
|
|
1
|
+
import{gsap as e}from"../../../node_modules/gsap/index.js";import{useState as r,useRef as t,useEffect as o,useLayoutEffect as n}from"react";const a=a=>{let{start:s=0,end:d,duration:u=2,ease:l="expo.inOut",rounded:p,roundingFn:v}=a;const[c,i]=r(d),m=t(s);return o((()=>{m.current=c}),[c]),n((()=>{const r={val:m.current},t=e.context((()=>{e.to(r,u,{val:d,ease:l,duration:u,...p?{roundProps:"val"}:{},onUpdate(){i(v?v(r.val):r.val)},onComplete(){i(v?v(r.val):r.val)}})}));return()=>t.revert()}),[u,l,d,p,v,s]),c};export{a as useAnimation};
|
|
2
2
|
//# sourceMappingURL=useAnimation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnimation.js","sources":["../../../../../../src/core/hooks/useAnimation.ts"],"sourcesContent":["import gsap from 'gsap'\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\n\n/**\n * Type definition for the parameters used in the `useAnimation` hook.\n * @typedef {Object} UseAnimationType\n * @property {number} start - The starting value of the animation.\n * @property {number} end - The ending value of the animation.\n * @property {number} duration - The duration of the animation in seconds.\n * @property {string} [ease='expo.inOut'] - The easing function for the animation.\n * @property {boolean} [rounded] - Flag to determine if the value should be rounded during the animation.\n */\nexport type UseAnimationType = {\n start
|
|
1
|
+
{"version":3,"file":"useAnimation.js","sources":["../../../../../../src/core/hooks/useAnimation.ts"],"sourcesContent":["import gsap from 'gsap'\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\n\n/**\n * Type definition for the parameters used in the `useAnimation` hook.\n * @typedef {Object} UseAnimationType\n * @property {number} start - The starting value of the animation.\n * @property {number} end - The ending value of the animation.\n * @property {number} duration - The duration of the animation in seconds.\n * @property {string} [ease='expo.inOut'] - The easing function for the animation.\n * @property {boolean} [rounded] - Flag to determine if the value should be rounded during the animation.\n */\nexport type UseAnimationType = {\n start?: number\n end: number\n duration?: number\n ease?: string\n rounded?: boolean\n roundingFn?: (value: number | string) => number | string\n}\n\n/**\n * Custom hook to create an animation using GSAP.\n * @param {UseAnimationType} params - The parameters for the animation.\n * @returns {number} The current value of the animation.\n */\nexport const useAnimation = ({\n start = 0,\n end,\n duration = 2,\n ease = 'expo.inOut',\n rounded,\n roundingFn,\n}: UseAnimationType): number | string => {\n const [val, setVal] = useState<number | string>(end)\n\n const startValueRef = useRef<number | string>(start)\n\n useEffect(() => {\n startValueRef.current = val\n }, [val])\n\n useLayoutEffect(() => {\n const valObj = { val: startValueRef.current }\n\n const gsapCtx = gsap.context(() => {\n gsap.to(valObj, duration, {\n val: end,\n ease,\n duration,\n ...(rounded ? { roundProps: 'val' } : {}),\n onUpdate () {\n setVal(roundingFn ? roundingFn(valObj.val) : valObj.val)\n },\n onComplete () {\n setVal(roundingFn ? roundingFn(valObj.val) : valObj.val)\n },\n })\n })\n\n return (): void => gsapCtx.revert()\n }, [duration, ease, end, rounded, roundingFn, start])\n\n return val\n}\n"],"names":["useAnimation","_ref","start","end","duration","ease","rounded","roundingFn","val","setVal","useState","startValueRef","useRef","useEffect","current","useLayoutEffect","valObj","gsapCtx","gsap","context","to","roundProps","onUpdate","onComplete","revert"],"mappings":"4IA0BaA,MAAAA,EAAeC,IAOa,IAPZC,MAC3BA,EAAQ,EAACC,IACTA,EAAGC,SACHA,EAAW,EAACC,KACZA,EAAO,aAAYC,QACnBA,EAAOC,WACPA,GACiBN,EACjB,MAAOO,EAAKC,GAAUC,EAA0BP,GAE1CQ,EAAgBC,EAAwBV,GA2B9C,OAzBAW,GAAU,KACRF,EAAcG,QAAUN,CAAG,GAC1B,CAACA,IAEJO,GAAgB,KACd,MAAMC,EAAS,CAAER,IAAKG,EAAcG,SAE9BG,EAAUC,EAAKC,SAAQ,KAC3BD,EAAKE,GAAGJ,EAAQZ,EAAU,CACxBI,IAAKL,EACLE,OACAD,cACIE,EAAU,CAAEe,WAAY,OAAU,GACtCC,QAAAA,GACEb,EAAOF,EAAaA,EAAWS,EAAOR,KAAOQ,EAAOR,IACrD,EACDe,UAAAA,GACEd,EAAOF,EAAaA,EAAWS,EAAOR,KAAOQ,EAAOR,IACtD,GACA,IAGJ,MAAO,IAAYS,EAAQO,QAAQ,GAClC,CAACpB,EAAUC,EAAMF,EAAKG,EAASC,EAAYL,IAEvCM,CAAG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{extends as t}from"../../../../../../_virtual/_rollupPluginBabelHelpers.js";import{memo as e,useCallback as n,createElement as a}from"react";import
|
|
1
|
+
import{extends as t}from"../../../../../../_virtual/_rollupPluginBabelHelpers.js";import{memo as e,useCallback as n,createElement as a}from"react";import o from"./button.module.scss.js";import{Link as r}from"../text/Link.js";import{classNames as i,noop as s}from"../../../../utils/helpers/ui.js";import{composeId as l}from"../../../../utils/helpers/text.js";import{IconBase as c}from"../../icon/IconBase.js";const d={ENTER:{key:"Enter",keyCode:13}},m=e((t=>{let{variant:e,href:n,target:o,children:i,...l}=t;return"link"===e?a(r,{width:"100%",href:n,target:o,...l,onClick:s},i):a("span",{},i)}));m.displayName="InnerElement";const p=e((e=>{let{label:a,children:r,variant:s,tiny:c,truncate:p,fluid:h,preventDefualt:u,stopPropagation:f,onClick:g,type:E="button",transparent:y,hasShadow:v,hasIcon:b,disabled:I,animated:k=!1,className:j="",id:C,href:N,target:P,...R}=e;const w=`${a||r?.toString()}`,x=n((t=>{u&&t.preventDefault(),f&&(t.stopPropagation(),t.nativeEvent.stopImmediatePropagation()),g?.(t)}),[g,u,f]),B=n((t=>{t.key===d.ENTER.key&&(u&&t.preventDefault(),f&&(t.stopPropagation(),t.nativeEvent.stopImmediatePropagation()),g?.(t))}),[g,u,f]);return React.createElement("button",t({type:E,tabIndex:-1,onClick:x,onKeyDown:B,className:i(o.button,c&&o.tiny,s&&o[s],p&&o.truncate,h&&o.fluid,k&&o.animated,y&&o.transparent,v&&o.hasShadow,b&&o.hasIcon,I&&o.disabled,j),id:`${C||w&&l(w)}`,"data-testid":`${R.dataTestId||R["data-testid"]||C||w&&l(w)}`},R),React.createElement(m,{variant:s,href:N,target:P},a&&a,r||r))}));p.displayName="Button";const h=["iconUrl","minWidth","minHeight","width","height","size","fontSize","color"],u=e((e=>{const n={},a={};return Object.entries(e).forEach((t=>{let[e,o]=t;h.includes(e)?a[e]=o:n[e]=o})),a.children=e.children,React.createElement(p,t({},n,{hasIcon:!0}),e.iconContent&&e.iconContent,!e.iconContent&&React.createElement(c,a))}));u.displayName="IconButton";export{p as Button,u as IconButton,d as keys};
|
|
2
2
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../../../../../../../src/core/ui/components/atoms/button/Button.tsx"],"sourcesContent":["import { memo, useCallback, MouseEvent, KeyboardEvent, createElement, FC, HTMLAttributes } from 'react'\n\nimport { classNames, composeId, noop } from '../../../../utils'\nimport { Alerts } from '../../../../constants'\nimport {
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../../../../../../../src/core/ui/components/atoms/button/Button.tsx"],"sourcesContent":["import { memo, useCallback, MouseEvent, KeyboardEvent, createElement, FC, HTMLAttributes } from 'react'\n\nimport { classNames, composeId, noop } from '../../../../utils'\nimport { Alerts } from '../../../../constants'\nimport { Link } from '../text'\nimport { IconBase, IconBaseProps } from '../../icon'\n\nimport type { ButtonProps, IconButtonProps } from './button.types'\nimport classes from './button.module.scss'\n\n\nexport const keys = {\n ENTER: {\n key: 'Enter',\n keyCode: 13,\n },\n}\n\ntype InnerElementsProps = Partial<ButtonProps> & Partial<HTMLAttributes<HTMLAnchorElement>>\n\nconst InnerElement: FC<InnerElementsProps> = memo(({\n variant, href, target, children, ...props\n}: Omit<InnerElementsProps, 'onClick'>) => {\n if (variant === 'link') {\n return createElement(Link, { width: '100%', href, target, ...props, onClick: noop }, children)\n }\n return createElement('span', {}, children)\n})\n\nInnerElement.displayName = 'InnerElement'\n\n/**\n * Button component for displaying buttons with optional features.\n * @component\n *\n * Generated component from Template\n * @param {object} props - The component props.\n * @param {string} props.label - The value to be displayed in the button.\n * @param {ReactNode} [props.children] - Additional content to be displayed inside the button.\n * @param {string} [props.variant] - The variant of the button (e.g., 'primary', 'secondary').\n * @param {boolean} [props.tiny] - Whether the button should be tiny.\n * @param {boolean} [props.truncate] - Whether the content inside the button should be truncated.\n * @param {boolean} [props.fluid] - Whether the button should have a fluid width.\n * @param {boolean} [props.animated=true] - Whether the button should have animation (default is true).\n * @param {string} [props.className] - Additional classes to be applied to the button.\n * @param {...object} props.props - Additional props to be spread to the underlying div element.\n *\n * @returns {JSX.Element} The rendered Button component.\n */\nexport const Button = memo(({\n label, children,\n variant, tiny, truncate, fluid,\n preventDefualt, stopPropagation,\n onClick,\n type = 'button',\n transparent,\n hasShadow,\n hasIcon,\n disabled,\n animated = false, className = '', id,\n href,\n target,\n ...props\n}: ButtonProps) => {\n const textFromChildren: string | undefined = `${label || children?.toString()}`\n\n const clickHandler = useCallback((event: MouseEvent) => {\n if (preventDefualt) {\n event.preventDefault()\n }\n if (stopPropagation) {\n event.stopPropagation()\n event.nativeEvent.stopImmediatePropagation()\n }\n onClick?.(event)\n }, [onClick, preventDefualt, stopPropagation])\n\n const keyDownHandler = useCallback((event: KeyboardEvent) => {\n if (event.key === keys.ENTER.key) {\n if (preventDefualt) {\n event.preventDefault()\n }\n if (stopPropagation) {\n event.stopPropagation()\n event.nativeEvent.stopImmediatePropagation()\n }\n onClick?.(event)\n }\n }, [onClick, preventDefualt, stopPropagation])\n\n return (\n <button\n // eslint-disable-next-line react/button-has-type\n type={type}\n tabIndex={-1}\n onClick={clickHandler}\n onKeyDown={keyDownHandler}\n className={classNames(\n classes.button,\n tiny && classes.tiny,\n variant && classes[variant as Alerts],\n truncate && classes.truncate,\n fluid && classes.fluid,\n animated && classes.animated,\n transparent && classes.transparent,\n hasShadow && classes.hasShadow,\n hasIcon && classes.hasIcon,\n disabled && classes.disabled,\n className,\n )}\n id={`${id || (textFromChildren && composeId(textFromChildren))}`}\n data-testid={`${(props as Record<string, string>).dataTestId || (props as Record<string, string>)['data-testid'] || id || (textFromChildren && composeId(textFromChildren))}`}\n {...props}\n >\n <InnerElement variant={variant} href={href} target={target}>\n {label && label}\n {children || children}\n </InnerElement>\n </button>\n )\n})\n\nexport type ButtonType = typeof Button\n\n// Set display name for the component.\nButton.displayName = 'Button'\n\nconst iconBaseProps = [\n 'iconUrl',\n 'minWidth',\n 'minHeight',\n 'width',\n 'height',\n 'size',\n 'fontSize',\n 'color',\n]\n\nexport const IconButton: FC<IconButtonProps> = memo<IconButtonProps>((props: IconButtonProps) => {\n const buttonProps: Record<string, unknown> = {}\n const iconProps: Record<string, unknown> = {}\n\n Object.entries(props).forEach(([name, value]: [string, unknown]) => {\n if (iconBaseProps.includes(name)) {\n // eslint-disable-next-line no-param-reassign\n iconProps[name] = value\n } else {\n buttonProps[name] = value\n }\n })\n\n iconProps.children = props.children\n\n return (\n <Button {...(buttonProps as ButtonProps)} hasIcon>\n {props.iconContent && props.iconContent}\n {!props.iconContent && (<IconBase {...(iconProps as IconBaseProps)} />)}\n </Button>\n )\n})\n\nIconButton.displayName = 'IconButton'\n"],"names":["keys","ENTER","key","keyCode","InnerElement","memo","_ref","variant","href","target","children","props","createElement","Link","width","onClick","noop","displayName","Button","_ref2","label","tiny","truncate","fluid","preventDefualt","stopPropagation","type","transparent","hasShadow","hasIcon","disabled","animated","className","id","textFromChildren","toString","clickHandler","useCallback","event","preventDefault","nativeEvent","stopImmediatePropagation","keyDownHandler","React","_extends","tabIndex","onKeyDown","classNames","classes","button","composeId","dataTestId","iconBaseProps","IconButton","buttonProps","iconProps","Object","entries","forEach","_ref3","name","value","includes","iconContent","IconBase"],"mappings":"wZAWO,MAAMA,EAAO,CAClBC,MAAO,CACLC,IAAK,QACLC,QAAS,KAMPC,EAAuCC,GAAKC,IAEP,IAFQC,QACjDA,EAAOC,KAAEA,EAAIC,OAAEA,EAAMC,SAAEA,KAAaC,GACAL,EACpC,MAAgB,SAAZC,EACKK,EAAcC,EAAM,CAAEC,MAAO,OAAQN,OAAMC,YAAWE,EAAOI,QAASC,GAAQN,GAEhFE,EAAc,OAAQ,CAAE,EAAEF,EAAS,IAG5CN,EAAaa,YAAc,qBAoBdC,EAASb,GAAKc,IAcR,IAdSC,MAC1BA,EAAKV,SAAEA,EAAQH,QACfA,EAAOc,KAAEA,EAAIC,SAAEA,EAAQC,MAAEA,EAAKC,eAC9BA,EAAcC,gBAAEA,EAAeV,QAC/BA,EAAOW,KACPA,EAAO,SAAQC,YACfA,EAAWC,UACXA,EAASC,QACTA,EAAOC,SACPA,EAAQC,SACRA,GAAW,EAAKC,UAAEA,EAAY,GAAEC,GAAEA,EAAEzB,KACpCA,EAAIC,OACJA,KACGE,GACSQ,EACZ,MAAMe,EAAuC,GAAGd,GAASV,GAAUyB,aAE7DC,EAAeC,GAAaC,IAC5Bd,GACFc,EAAMC,iBAEJd,IACFa,EAAMb,kBACNa,EAAME,YAAYC,4BAEpB1B,IAAUuB,EAAM,GACf,CAACvB,EAASS,EAAgBC,IAEvBiB,EAAiBL,GAAaC,IAC9BA,EAAMpC,MAAQF,EAAKC,MAAMC,MACvBsB,GACFc,EAAMC,iBAEJd,IACFa,EAAMb,kBACNa,EAAME,YAAYC,4BAEpB1B,IAAUuB,GACZ,GACC,CAACvB,EAASS,EAAgBC,IAE7B,OACEkB,MAAA/B,cAAA,SAAAgC,EAAA,CAEElB,KAAMA,EACNmB,UAAW,EACX9B,QAASqB,EACTU,UAAWJ,EACXV,UAAWe,EACTC,EAAQC,OACR5B,GAAQ2B,EAAQ3B,KAChBd,GAAWyC,EAAQzC,GACnBe,GAAY0B,EAAQ1B,SACpBC,GAASyB,EAAQzB,MACjBQ,GAAYiB,EAAQjB,SACpBJ,GAAeqB,EAAQrB,YACvBC,GAAaoB,EAAQpB,UACrBC,GAAWmB,EAAQnB,QACnBC,GAAYkB,EAAQlB,SACpBE,GAEFC,GAAI,GAAGA,GAAOC,GAAoBgB,EAAUhB,KAC5C,cAAa,GAAIvB,EAAiCwC,YAAexC,EAAiC,gBAAkBsB,GAAOC,GAAoBgB,EAAUhB,MACrJvB,GAEJgC,MAAA/B,cAACR,EAAY,CAACG,QAASA,EAASC,KAAMA,EAAMC,OAAQA,GACjDW,GAASA,EACTV,GAAYA,GAER,IAObQ,EAAOD,YAAc,SAErB,MAAMmC,EAAgB,CACpB,UACA,WACA,YACA,QACA,SACA,OACA,WACA,SAGWC,EAAkChD,GAAuBM,IACpE,MAAM2C,EAAuC,CAAA,EACvCC,EAAqC,CAAA,EAa3C,OAXAC,OAAOC,QAAQ9C,GAAO+C,SAAQC,IAAsC,IAApCC,EAAMC,GAAyBF,EACzDP,EAAcU,SAASF,GAEzBL,EAAUK,GAAQC,EAElBP,EAAYM,GAAQC,CACtB,IAGFN,EAAU7C,SAAWC,EAAMD,SAGzBiC,MAAA/B,cAACM,EAAM0B,KAAMU,EAAW,CAAkBzB,SAAO,IAC9ClB,EAAMoD,aAAepD,EAAMoD,aAC1BpD,EAAMoD,aAAgBpB,MAAA/B,cAACoD,EAAcT,GAChC,IAIbF,EAAWpC,YAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t={"overflow-hidden":"button-module_overflow-hidden__Vc5AU","text-truncate":"button-module_text-truncate__a89Bp","text-nowrap":"button-module_text-nowrap__tR-VJ","text-ellipsis":"button-module_text-ellipsis__5MFA9",button:"button-module_button__NDMQS",info:"button-module_info__O6gEW",transparent:"button-module_transparent__zbeBu",success:"button-module_success__gM25y",error:"button-module_error__q9qqo",warning:"button-module_warning__MdmiZ",tiny:"button-module_tiny__pBNwo",fluid:"button-module_fluid__GXxID",truncate:"button-module_truncate__c-G9k",animated:"button-module_animated__gLwPl",hasShadow:"button-module_hasShadow__42BQv",hasIcon:"button-module_hasIcon__dXLlJ",disabled:"button-module_disabled__hEydO"};export{t as default};
|
|
1
|
+
var t={"overflow-hidden":"button-module_overflow-hidden__Vc5AU","text-truncate":"button-module_text-truncate__a89Bp","text-nowrap":"button-module_text-nowrap__tR-VJ","text-ellipsis":"button-module_text-ellipsis__5MFA9",button:"button-module_button__NDMQS",info:"button-module_info__O6gEW",transparent:"button-module_transparent__zbeBu",success:"button-module_success__gM25y",error:"button-module_error__q9qqo",warning:"button-module_warning__MdmiZ",link:"button-module_link__e-4Fu",tiny:"button-module_tiny__pBNwo",fluid:"button-module_fluid__GXxID",truncate:"button-module_truncate__c-G9k",animated:"button-module_animated__gLwPl",hasShadow:"button-module_hasShadow__42BQv",hasIcon:"button-module_hasIcon__dXLlJ",disabled:"button-module_disabled__hEydO"};export{t as default};
|
|
2
2
|
//# sourceMappingURL=button.module.scss.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{extends as e}from"../../../../../_virtual/_rollupPluginBabelHelpers.js";import{memo as t,useCallback as a,useMemo as l,createElement as n}from"react";import{classNames as o}from"../../../utils/helpers/ui.js";import c from"./field.module.scss.js";let s=()=>"#000000";const i=e=>{s=e};let r=t((function(){return React.createElement("span",null)}));const m=e=>{r=e},p=t((function(t){let{options:a,value:l,inputRef:n,...o}=t;return React.createElement("div",{className:"select"},React.createElement("select",e({},o,{ref:n,defaultValue:l}),a?.map((e=>React.createElement("option",{key:`${JSON.stringify(e)}`,value:"object"==typeof e?e?.value:e},"object"==typeof e?e?.label:e)))))})),u=t((e=>n("textarea",e)));u.displayName="TextAreaComponent";const d=t((e=>n("input",e)));d.displayName="InputComponent";const f=t((t=>{let{label:n,name:i,type:m="text",value:f,defaultValue:h,placeholder:R,inputRef:N,error:g,disabled:E,userDisabled:v,withoutComponent:y,helpTextInfo:C,helpText:b,children:x,iconLeft:j,iconRight:k,addon:F,className:I,onChange:B,onChangeInner:D,onBlur:w,onFocus:T,rightIconClick:V,leftIconClick:$,options:K,style:L,..._}=t,A=d;x||"textarea"!==m||(A=u);const H=a((e=>{v?e?.preventDefault?.():T&&T(e)}),[v,T]),J=a((e=>{v||(D&&e?.target?(e.target.value=D(e.target.value),B&&B(e)):B&&B(e))}),[D,B,v]),O=l((()=>void 0===f?{defaultValue:h}:{value:f}),[f,h]);return React.createElement("div",{className:o(c.field,(E||v)&&c.
|
|
1
|
+
import{extends as e}from"../../../../../_virtual/_rollupPluginBabelHelpers.js";import{memo as t,useCallback as a,useMemo as l,createElement as n}from"react";import{classNames as o}from"../../../utils/helpers/ui.js";import c from"./field.module.scss.js";let s=()=>"#000000";const i=e=>{s=e};let r=t((function(){return React.createElement("span",null)}));const m=e=>{r=e},p=t((function(t){let{options:a,value:l,inputRef:n,...o}=t;return React.createElement("div",{className:"select"},React.createElement("select",e({},o,{ref:n,defaultValue:l}),a?.map((e=>React.createElement("option",{key:`${JSON.stringify(e)}`,value:"object"==typeof e?e?.value:e},"object"==typeof e?e?.label:e)))))})),u=t((e=>n("textarea",e)));u.displayName="TextAreaComponent";const d=t((e=>n("input",e)));d.displayName="InputComponent";const f=t((t=>{let{label:n,name:i,type:m="text",value:f,defaultValue:h,placeholder:R,inputRef:N,error:g,disabled:E,userDisabled:v,withoutComponent:y,helpTextInfo:C,helpText:b,children:x,iconLeft:j,iconRight:k,addon:F,className:I,onChange:B,onChangeInner:D,onBlur:w,onFocus:T,rightIconClick:V,leftIconClick:$,options:K,style:L,..._}=t,A=d;x||"textarea"!==m||(A=u);const H=a((e=>{v?e?.preventDefault?.():T&&T(e)}),[v,T]),J=a((e=>{v||(D&&e?.target?(e.target.value=D(e.target.value),B&&B(e)):B&&B(e))}),[D,B,v]),O=l((()=>void 0===f?{defaultValue:h}:{value:f}),[f,h]);return React.createElement("div",{className:o(c.field,(E||v)&&c.disabled,I),style:L},React.createElement("label",{htmlFor:i,className:"label"},n),React.createElement("div",{className:"field "+(F?"has-addons":"")},React.createElement("div",{className:`control mainControl ${j&&!y?"has-icons-left":""} ${k?"has-icons-right":""}`},!y&&(x||"select"!==m&&!K?!x&&React.createElement(A,e({name:i,id:i,ref:N,className:"input "+(g?"is-danger":""),type:m,placeholder:R},O,{onChange:J,onBlur:w,onFocus:H,onKeyDown:H,autoComplete:"off",disabled:E},_)):React.createElement(p,e({name:i,id:i,inputRef:N,className:"input "+(g?"is-danger":""),type:"select",placeholder:R,value:f,options:K,onChange:B,onBlur:w,onFocus:H,onKeyDown:H,autoComplete:"off",disabled:E},_))),j&&!y&&React.createElement("span",{className:"iconLeft icon is-small is-left "+($?"is-action":""),onClick:$},React.createElement(r,{iconName:j,color:s})),k&&React.createElement("span",{className:"iconRight icon is-small is-right "+(V?"is-action":""),onClick:V},React.createElement(r,{iconName:k,color:s})),x&&x),F&&F),C&&React.createElement("p",{className:"help"},C),b&&React.createElement("p",{className:"help "+(g?"is-danger":"")},b))}));f.displayName="Field";export{f as Field,p as Select,i as setIconColor,m as setIconComponent};
|
|
2
2
|
//# sourceMappingURL=Field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sources":["../../../../../../../../src/core/ui/components/field/Field.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport { FC, ReactNode, memo, useMemo, useCallback, PropsWithChildren, CSSProperties, createElement } from 'react'\n\nimport { classNames } from '../../../utils/helpers/ui'\n\nimport classes from './field.module.scss'\nimport type { FieldError, IconComponentType } from './types'\n\nlet iconColor: string | (() => string) = () => '#000000'\n\nexport const setIconColor = (color: string | (() => string)): void => {\n iconColor = color\n}\n\nlet IconComponent: IconComponentType = memo(function IconComponent() { return <span /> })\n\nexport const setIconComponent = (component: IconComponentType): void => {\n IconComponent = component\n}\n\nexport type FileWrapperProps = PropsWithChildren<unknown> & {\n className?: string\n error?: boolean\n disabled?: boolean\n userDisabled?: boolean\n css?: string\n}\n\ntype EventType = { target: any; type?: any } & Partial<Event>\nexport interface FieldProps {\n label?: string\n name?: string\n type?: string\n min?: number | string | Date | any\n max?: number | string | Date | any\n value?: string | number | readonly string[] | undefined\n defaultValue?: string | number | readonly string[] | undefined\n placeholder?: string\n inputRef?: ReactHookFormRef\n error?: boolean\n errors?: FieldError\n disabled?: boolean\n userDisabled?: boolean\n checked?: boolean\n helpTextInfo?: string\n helpText?: string\n iconLeft?: string\n iconRight?: string\n withoutComponent?: boolean\n addon?: ReactNode\n children?: ReactNode\n className?: string\n onChange?: (event?: EventType) => unknown\n // TODO, rename... something like changeHandler or valueDecorator\n onChangeInner?: (value: string | number) => string | number\n onBlur?: (event?: EventType) => void\n onFocus?: (event?: EventType | undefined) => void\n rightIconClick?: (event?: EventType) => void\n leftIconClick?: (event?: EventType) => void\n options?: any[] | null\n creatable?: boolean\n async?: boolean\n style?: CSSProperties\n [key: string]: any\n}\n\ninterface SelectProps extends FieldProps {\n id?: string\n}\n\ntype OptionObj = { label: string | number | undefined; value: string | number | undefined }\ntype Option = OptionObj | string | number\n\nexport const Select: FC<SelectProps>\n= memo<SelectProps>(\n function Select({ options, value, inputRef, ...props }: SelectProps) {\n return (\n <div className='select'>\n <select {...props} ref={inputRef} defaultValue={value}>\n {options?.map((option: Option) => (\n <option\n key={`${JSON.stringify(option)}`}\n value={typeof option === 'object' ? (option as OptionObj)?.value : option}\n >\n {typeof option === 'object' ? (option as OptionObj)?.label : option}\n </option>\n ))}\n </select>\n </div>\n )\n },\n)\nconst TextAreaComponent = memo((props) => createElement('textarea', props))\n\nTextAreaComponent.displayName = 'TextAreaComponent'\n\nconst InputComponent = memo((props) => createElement('input', props))\n\nInputComponent.displayName = 'InputComponent'\n\nexport const Field: FC<FieldProps> = memo<FieldProps>(({\n label,\n name,\n type = 'text',\n value,\n defaultValue,\n placeholder,\n inputRef,\n error,\n disabled,\n userDisabled,\n withoutComponent,\n helpTextInfo,\n helpText,\n children,\n iconLeft,\n iconRight,\n addon,\n className,\n onChange,\n onChangeInner,\n onBlur,\n onFocus,\n rightIconClick,\n leftIconClick,\n options,\n style,\n ...props\n}: FieldProps) => {\n let Component: FC<any> = InputComponent\n\n if (!children && type === 'textarea') {\n Component = TextAreaComponent\n }\n const handleFocus = useCallback((event: Event | EventType | undefined) => {\n if (userDisabled) {\n event?.preventDefault?.()\n } else {\n onFocus && onFocus(event)\n }\n }, [userDisabled, onFocus])\n\n const handleChange = useCallback((event: { target: { value: string } }) => {\n if (userDisabled) {\n return\n }\n if (onChangeInner && event?.target) {\n // eslint-disable-next-line no-param-reassign\n event.target.value = onChangeInner((event.target.value as string)) as string\n onChange && onChange(event as EventType)\n } else {\n onChange && onChange(event as EventType)\n }\n }, [onChangeInner, onChange, userDisabled])\n\n const valueProps = useMemo(() => {\n if (value === undefined) {\n return { defaultValue }\n }\n return { value }\n }, [value, defaultValue])\n\n return (\n <div\n className={classNames(\n classes.field,\n (disabled || userDisabled) && classes.disable,\n className,\n )}\n // TODO fix\n // error={error}\n style={style}\n >\n <label htmlFor={name} className='label'>{label}</label>\n <div className={`field ${addon ? 'has-addons' : ''}`}>\n <div\n className={`control mainControl ${iconLeft && !withoutComponent\n ? 'has-icons-left' : ''} ${iconRight ? 'has-icons-right' : ''}`}\n >\n {!withoutComponent && ((!children && (type === 'select' || options))\n ? (\n <Select\n name={name}\n id={name}\n inputRef={inputRef}\n className={`input ${error ? 'is-danger' : ''}`}\n type='select'\n placeholder={placeholder}\n value={value}\n options={options}\n // TODO also handle change but value versus event.target.value issue\n onChange={onChange}\n onBlur={onBlur}\n onFocus={handleFocus}\n onKeyDown={handleFocus}\n autoComplete='off'\n disabled={disabled}\n {...props}\n />\n )\n : (\n !children && (\n <Component\n name={name}\n id={name}\n ref={inputRef}\n className={`input ${error ? 'is-danger' : ''}`}\n type={type}\n placeholder={placeholder}\n {...valueProps}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={handleFocus}\n onKeyDown={handleFocus}\n autoComplete='off'\n disabled={disabled}\n {...props}\n />\n )))}\n\n {iconLeft && !withoutComponent && (\n <span\n className={`iconLeft icon is-small is-left ${leftIconClick ? 'is-action' : ''}`}\n onClick={leftIconClick}\n >\n <IconComponent\n iconName={iconLeft}\n color={iconColor}\n />\n </span>\n )}\n {iconRight && (\n <span\n className={`iconRight icon is-small is-right ${rightIconClick ? 'is-action' : ''}`}\n onClick={rightIconClick}\n >\n <IconComponent\n iconName={iconRight}\n color={iconColor}\n />\n </span>\n )}\n {children && children}\n </div>\n {addon && addon}\n </div>\n {helpTextInfo && <p className='help'>{helpTextInfo}</p>}\n {helpText && <p className={`help ${error ? 'is-danger' : ''}`}>{helpText}</p>}\n </div>\n )\n})\n\nField.displayName = 'Field'\n"],"names":["iconColor","setIconColor","color","IconComponent","memo","React","createElement","setIconComponent","component","Select","_ref","options","value","inputRef","props","className","_extends","ref","defaultValue","map","option","key","JSON","stringify","label","TextAreaComponent","displayName","InputComponent","Field","_ref2","name","type","placeholder","error","disabled","userDisabled","withoutComponent","helpTextInfo","helpText","children","iconLeft","iconRight","addon","onChange","onChangeInner","onBlur","onFocus","rightIconClick","leftIconClick","style","Component","handleFocus","useCallback","event","preventDefault","handleChange","target","valueProps","useMemo","undefined","classNames","classes","field","disable","htmlFor","id","onKeyDown","autoComplete","onClick","iconName"],"mappings":"6PAUA,IAAIA,EAAqCA,IAAM,UAElCC,MAAAA,EAAgBC,IAC3BF,EAAYE,CAAK,EAGnB,IAAIC,EAAmCC,GAAK,WAA2B,OAAOC,MAAAC,cAAA,OAAA,KAAS,IAE1EC,MAAAA,EAAoBC,IAC/BL,EAAgBK,CAAS,EAwDdC,EACXL,GACA,SAAeM,GAAsD,IAArDC,QAAEA,EAAOC,MAAEA,EAAKC,SAAEA,KAAaC,GAAo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GAEdG,GAASA,GAEXL,GAAgBhC,MAAAC,cAAA,IAAA,CAAGS,UAAU,QAAQsB,GACrCC,GAAYjC,MAAAC,cAAA,IAAA,CAAGS,UAAW,SAAQkB,EAAQ,YAAc,KAAOK,GAC5D,IAIVV,EAAMF,YAAc"}
|
|
1
|
+
{"version":3,"file":"Field.js","sources":["../../../../../../../../src/core/ui/components/field/Field.tsx"],"sourcesContent":["/* eslint-disable react/jsx-props-no-spreading */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport { FC, ReactNode, memo, useMemo, useCallback, PropsWithChildren, CSSProperties, createElement } from 'react'\n\nimport { classNames } from '../../../utils/helpers/ui'\n\nimport classes from './field.module.scss'\nimport type { FieldError, IconComponentType } from './types'\n\nlet iconColor: string | (() => string) = () => '#000000'\n\nexport const setIconColor = (color: string | (() => string)): void => {\n iconColor = color\n}\n\nlet IconComponent: IconComponentType = memo(function IconComponent() { return <span /> })\n\nexport const setIconComponent = (component: IconComponentType): void => {\n IconComponent = component\n}\n\nexport type FileWrapperProps = PropsWithChildren<unknown> & {\n className?: string\n error?: boolean\n disabled?: boolean\n userDisabled?: boolean\n css?: string\n}\n\ntype EventType = { target: any; type?: any } & Partial<Event>\nexport interface FieldProps {\n label?: string\n name?: string\n type?: string\n min?: number | string | Date | any\n max?: number | string | Date | any\n value?: string | number | readonly string[] | undefined\n defaultValue?: string | number | readonly string[] | undefined\n placeholder?: string\n inputRef?: ReactHookFormRef\n error?: boolean\n errors?: FieldError\n disabled?: boolean\n userDisabled?: boolean\n checked?: boolean\n helpTextInfo?: string\n helpText?: string\n iconLeft?: string\n iconRight?: string\n withoutComponent?: boolean\n addon?: ReactNode\n children?: ReactNode\n className?: string\n onChange?: (event?: EventType) => unknown\n // TODO, rename... something like changeHandler or valueDecorator\n onChangeInner?: (value: string | number) => string | number\n onBlur?: (event?: EventType) => void\n onFocus?: (event?: EventType | undefined) => void\n rightIconClick?: (event?: EventType) => void\n leftIconClick?: (event?: EventType) => void\n options?: any[] | null\n creatable?: boolean\n async?: boolean\n style?: CSSProperties\n [key: string]: any\n}\n\ninterface SelectProps extends FieldProps {\n id?: string\n}\n\ntype OptionObj = { label: string | number | undefined; value: string | number | undefined }\ntype Option = OptionObj | string | number\n\nexport const Select: FC<SelectProps>\n= memo<SelectProps>(\n function Select({ options, value, inputRef, ...props }: SelectProps) {\n return (\n <div className='select'>\n <select {...props} ref={inputRef} defaultValue={value}>\n {options?.map((option: Option) => (\n <option\n key={`${JSON.stringify(option)}`}\n value={typeof option === 'object' ? (option as OptionObj)?.value : option}\n >\n {typeof option === 'object' ? (option as OptionObj)?.label : option}\n </option>\n ))}\n </select>\n </div>\n )\n },\n)\nconst TextAreaComponent = memo((props) => createElement('textarea', props))\n\nTextAreaComponent.displayName = 'TextAreaComponent'\n\nconst InputComponent = memo((props) => createElement('input', props))\n\nInputComponent.displayName = 'InputComponent'\n\nexport const Field: FC<FieldProps> = memo<FieldProps>(({\n label,\n name,\n type = 'text',\n value,\n defaultValue,\n placeholder,\n inputRef,\n error,\n disabled,\n userDisabled,\n withoutComponent,\n helpTextInfo,\n helpText,\n children,\n iconLeft,\n iconRight,\n addon,\n className,\n onChange,\n onChangeInner,\n onBlur,\n onFocus,\n rightIconClick,\n leftIconClick,\n options,\n style,\n ...props\n}: FieldProps) => {\n let Component: FC<any> = InputComponent\n\n if (!children && type === 'textarea') {\n Component = TextAreaComponent\n }\n const handleFocus = useCallback((event: Event | EventType | undefined) => {\n if (userDisabled) {\n event?.preventDefault?.()\n } else {\n onFocus && onFocus(event)\n }\n }, [userDisabled, onFocus])\n\n const handleChange = useCallback((event: { target: { value: string } }) => {\n if (userDisabled) {\n return\n }\n if (onChangeInner && event?.target) {\n // eslint-disable-next-line no-param-reassign\n event.target.value = onChangeInner((event.target.value as string)) as string\n onChange && onChange(event as EventType)\n } else {\n onChange && onChange(event as EventType)\n }\n }, [onChangeInner, onChange, userDisabled])\n\n const valueProps = useMemo(() => {\n if (value === undefined) {\n return { defaultValue }\n }\n return { value }\n }, [value, defaultValue])\n\n return (\n <div\n className={classNames(\n classes.field,\n (disabled || userDisabled) && classes.disabled,\n className,\n )}\n // TODO fix\n // error={error}\n style={style}\n >\n <label htmlFor={name} className='label'>{label}</label>\n <div className={`field ${addon ? 'has-addons' : ''}`}>\n <div\n className={`control mainControl ${iconLeft && !withoutComponent\n ? 'has-icons-left' : ''} ${iconRight ? 'has-icons-right' : ''}`}\n >\n {!withoutComponent && ((!children && (type === 'select' || options))\n ? (\n <Select\n name={name}\n id={name}\n inputRef={inputRef}\n className={`input ${error ? 'is-danger' : ''}`}\n type='select'\n placeholder={placeholder}\n value={value}\n options={options}\n // TODO also handle change but value versus event.target.value issue\n onChange={onChange}\n onBlur={onBlur}\n onFocus={handleFocus}\n onKeyDown={handleFocus}\n autoComplete='off'\n disabled={disabled}\n {...props}\n />\n )\n : (\n !children && (\n <Component\n name={name}\n id={name}\n ref={inputRef}\n className={`input ${error ? 'is-danger' : ''}`}\n type={type}\n placeholder={placeholder}\n {...valueProps}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={handleFocus}\n onKeyDown={handleFocus}\n autoComplete='off'\n disabled={disabled}\n {...props}\n />\n )))}\n\n {iconLeft && !withoutComponent && (\n <span\n className={`iconLeft icon is-small is-left ${leftIconClick ? 'is-action' : ''}`}\n onClick={leftIconClick}\n >\n <IconComponent\n iconName={iconLeft}\n color={iconColor}\n />\n </span>\n )}\n {iconRight && (\n <span\n className={`iconRight icon is-small is-right ${rightIconClick ? 'is-action' : ''}`}\n onClick={rightIconClick}\n >\n <IconComponent\n iconName={iconRight}\n color={iconColor}\n />\n </span>\n )}\n {children && children}\n </div>\n {addon && addon}\n </div>\n {helpTextInfo && <p className='help'>{helpTextInfo}</p>}\n {helpText && <p className={`help ${error ? 'is-danger' : ''}`}>{helpText}</p>}\n </div>\n )\n})\n\nField.displayName = 'Field'\n"],"names":["iconColor","setIconColor","color","IconComponent","memo","React","createElement","setIconComponent","component","Select","_ref","options","value","inputRef","props","className","_extends","ref","defaultValue","map","option","key","JSON","stringify","label","TextAreaComponent","displayName","InputComponent","Field","_ref2","name","type","placeholder","error","disabled","userDisabled","withoutComponent","helpTextInfo","helpText","children","iconLeft","iconRight","addon","onChange","onChangeInner","onBlur","onFocus","rightIconClick","leftIconClick","style","Component","handleFocus","useCallback","event","preventDefault","handleChange","target","valueProps","useMemo","undefined","classNames","classes","field","htmlFor","id","onKeyDown","autoComplete","onClick","iconName"],"mappings":"6PAUA,IAAIA,EAAqCA,IAAM,UAElCC,MAAAA,EAAgBC,IAC3BF,EAAYE,CAAK,EAGnB,IAAIC,EAAmCC,GAAK,WAA2B,OAAOC,MAAAC,cAAA,OAAA,KAAS,IAE1EC,MAAAA,EAAoBC,IAC/BL,EAAgBK,CAAS,EAwDdC,EACXL,GACA,SAAeM,GAAsD,IAArDC,QAAEA,EAAOC,MAAEA,EAAKC,SAAEA,KAAaC,GAAoBJ,EACjE,OACEL,MAAAC,cAAA,MAAA,CAAKS,UAAU,UACbV,MAAAC,cAAAU,SAAAA,KAAYF,EAAK,CAAEG,IAAKJ,EAAUK,aAAcN,IAC7CD,GAASQ,KAAKC,GACbf,MAAAC,cAAA,SAAA,CACEe,IAAK,GAAGC,KAAKC,UAAUH,KACvBR,MAAyB,iBAAXQ,EAAuBA,GAAsBR,MAAQQ,GAEhD,iBAAXA,EAAuBA,GAAsBI,MAAQJ,MAMzE,IAEIK,EAAoBrB,GAAMU,GAAUR,EAAc,WAAYQ,KAEpEW,EAAkBC,YAAc,oBAEhC,MAAMC,EAAiBvB,GAAMU,GAAUR,EAAc,QAASQ,KAE9Da,EAAeD,YAAc,uBAEhBE,EAAwBxB,GAAiByB,IA4BpC,IA5BqCL,MACrDA,EAAKM,KACLA,EAAIC,KACJA,EAAO,OAAMnB,MACbA,EAAKM,aACLA,EAAYc,YACZA,EAAWnB,SACXA,EAAQoB,MACRA,EAAKC,SACLA,EAAQC,aACRA,EA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