chop-logic-components 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/button/Button.d.ts +2 -1
- package/dist/components/misc/portal/Portal.d.ts +6 -0
- package/dist/components/modal/Modal.d.ts +9 -0
- package/dist/components/modal/__docs__/Example.d.ts +5 -0
- package/dist/components/modal/__docs__/Modal.stories.d.ts +7 -0
- package/dist/components/modal/elements/Header.d.ts +8 -0
- package/dist/components/modal/elements/Layout.d.ts +9 -0
- package/dist/hooks/__tests__/use-click-outside.test.d.ts +1 -0
- package/dist/hooks/__tests__/use-key-press.test.d.ts +1 -0
- package/dist/hooks/__tests__/use-modal-focus.test.d.ts +1 -0
- package/dist/hooks/__tests__/use-mount.test.d.ts +1 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/use-click-outside.d.ts +17 -0
- package/dist/hooks/use-key-press.d.ts +18 -0
- package/dist/hooks/use-modal-focus-trap.d.ts +14 -0
- package/dist/hooks/use-mount.d.ts +8 -0
- package/dist/index.cjs.js +10 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +549 -515
- package/dist/index.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/utils/__tests__/move-focus-on-element-by-id.test.d.ts +1 -0
- package/package.json +11 -10
- package/dist/utils/use-click-outside.d.ts +0 -12
- /package/dist/{utils/__tests__/use-click-outside.test.d.ts → components/modal/__tests__/Modal.test.d.ts} +0 -0
|
@@ -4,9 +4,10 @@ import { default as React, MouseEventHandler } from 'react';
|
|
|
4
4
|
export type ChopLogicButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
5
5
|
text?: string;
|
|
6
6
|
onClick?: MouseEventHandler<HTMLButtonElement> | (() => void);
|
|
7
|
-
view?: 'primary' | 'secondary' | 'danger';
|
|
7
|
+
view?: 'primary' | 'secondary' | 'danger' | 'icon';
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
icon?: Icon;
|
|
10
|
+
label?: string;
|
|
10
11
|
};
|
|
11
12
|
declare const Button: React.FC<ChopLogicButtonProps>;
|
|
12
13
|
export default Button;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
export type ChopLogicModalProps = PropsWithChildren & React.HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
isOpened: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
8
|
+
declare const ChopLogicModal: React.FC<ChopLogicModalProps>;
|
|
9
|
+
export default ChopLogicModal;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
type ChopLogicModalLayoutHeaderProps = {
|
|
4
|
+
title: string;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
};
|
|
7
|
+
declare const ChopLogicModalLayoutHeader: ({ title, onClose }: ChopLogicModalLayoutHeaderProps) => React.ReactElement;
|
|
8
|
+
export default ChopLogicModalLayoutHeader;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React, PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
type ModalLayoutProps = PropsWithChildren & React.HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
title: string;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
isOpened: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const ChopLogicModalLayout: ({ title, onClose, isOpened, children, ...rest }: ModalLayoutProps) => React.ReactElement;
|
|
9
|
+
export default ChopLogicModalLayout;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
type UseClickOutsideParams = {
|
|
4
|
+
ref: React.RefObject<HTMLDivElement>;
|
|
5
|
+
onClickOutsideHandler: () => void;
|
|
6
|
+
dependentRef?: React.RefObject<HTMLDivElement>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Custom hook that triggers a callback when a click event occurs outside specified elements.
|
|
10
|
+
*
|
|
11
|
+
* @param {UseClickOutsideParams} ref - Reference to the main element to check if the click is outside
|
|
12
|
+
* @param {UseClickOutsideParams} onClickOutsideHandler - Callback function to execute when a click event occurs outside
|
|
13
|
+
* @param {UseClickOutsideParams} dependentRef - Reference to a dependent element to check if the click is outside
|
|
14
|
+
* @return {void} Function does not return anything
|
|
15
|
+
*/
|
|
16
|
+
export declare const useClickOutside: ({ ref, onClickOutsideHandler, dependentRef }: UseClickOutsideParams) => void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
type useKeyPressParams = {
|
|
4
|
+
keyCode: string;
|
|
5
|
+
ref: React.RefObject<HTMLDivElement>;
|
|
6
|
+
onKeyPress: () => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Hook that listens for a specific key press event and triggers an action when the key is pressed.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} params - An object containing the following properties:
|
|
12
|
+
* - ref: A ref object that refers to the HTML element to attach the event listener to.
|
|
13
|
+
* - keyCode: The key code of the key to listen for.
|
|
14
|
+
* - onKeyPress: A function to be called when the key is pressed.
|
|
15
|
+
* @return {void} This hook does not return anything.
|
|
16
|
+
*/
|
|
17
|
+
export declare const useKeyPress: ({ ref, keyCode, onKeyPress }: useKeyPressParams) => void;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type ModalFocusTrapParams = {
|
|
2
|
+
modalRef: React.RefObject<HTMLDivElement>;
|
|
3
|
+
isOpened: boolean;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Traps the focus within a modal element when it is opened.
|
|
7
|
+
*
|
|
8
|
+
* @param {ModalFocusTrapParams} params - An object containing the modal reference and a boolean indicating whether the modal is opened.
|
|
9
|
+
* @param {React.RefObject<HTMLDivElement>} params.modalRef - A reference to the modal element.
|
|
10
|
+
* @param {boolean} params.isOpened - A boolean indicating whether the modal is opened.
|
|
11
|
+
* @return {void} This function does not return anything.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useModalFocusTrap: ({ modalRef, isOpened }: ModalFocusTrapParams) => void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook that manages the mounting state based on the isOpened prop and a delay.
|
|
3
|
+
*
|
|
4
|
+
* @param {boolean} isOpened - Indicates if the component is opened.
|
|
5
|
+
* @param {number} [delay=300] - The delay in milliseconds before unmounting.
|
|
6
|
+
* @return {boolean} The current state of mounting.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useMount: (isOpened: boolean, delay?: number) => boolean;
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react");var ve={exports:{}},J={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var qe;function wr(){if(qe)return J;qe=1;var r=P,c=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,v={key:!0,ref:!0,__self:!0,__source:!0};function h(_,d,y){var u,R={},C=null,g=null;y!==void 0&&(C=""+y),d.key!==void 0&&(C=""+d.key),d.ref!==void 0&&(g=d.ref);for(u in d)i.call(d,u)&&!v.hasOwnProperty(u)&&(R[u]=d[u]);if(_&&_.defaultProps)for(u in d=_.defaultProps,d)R[u]===void 0&&(R[u]=d[u]);return{$$typeof:c,type:_,key:C,ref:g,props:R,_owner:s.current}}return J.Fragment=a,J.jsx=h,J.jsxs=h,J}var G={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+oe+e}}var ie=!1,H;{var
|
|
19
|
-
`),j=
|
|
20
|
-
`),E=
|
|
21
|
-
`+
|
|
17
|
+
*/var Ue;function Rr(){return Ue||(Ue=1,process.env.NODE_ENV!=="production"&&function(){var r=P,c=Symbol.for("react.element"),a=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),_=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),k=Symbol.iterator,$="@@iterator";function A(e){if(e===null||typeof e!="object")return null;var t=k&&e[k]||e[$];return typeof t=="function"?t:null}var S=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(e){{for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];re("error",e,n)}}function re(e,t,n){{var o=S.ReactDebugCurrentFrame,p=o.getStackAddendum();p!==""&&(t+="%s",n=n.concat([p]));var b=n.map(function(f){return String(f)});b.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,b)}}var te=!1,X=!1,ne=!1,Ie=!1,Je=!1,be;be=Symbol.for("react.module.reference");function Ge(e){return!!(typeof e=="string"||typeof e=="function"||e===i||e===v||Je||e===s||e===y||e===u||Ie||e===g||te||X||ne||typeof e=="object"&&e!==null&&(e.$$typeof===C||e.$$typeof===R||e.$$typeof===h||e.$$typeof===_||e.$$typeof===d||e.$$typeof===be||e.getModuleId!==void 0))}function Xe(e,t,n){var o=e.displayName;if(o)return o;var p=t.displayName||t.name||"";return p!==""?n+"("+p+")":n}function me(e){return e.displayName||"Context"}function F(e){if(e==null)return null;if(typeof e.tag=="number"&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case i:return"Fragment";case a:return"Portal";case v:return"Profiler";case s:return"StrictMode";case y:return"Suspense";case u:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case _:var t=e;return me(t)+".Consumer";case h:var n=e;return me(n._context)+".Provider";case d:return Xe(e,e.render,"ForwardRef");case R:var o=e.displayName||null;return o!==null?o:F(e.type)||"Memo";case C:{var p=e,b=p._payload,f=p._init;try{return F(f(b))}catch{return null}}}return null}var L=Object.assign,K=0,ge,ye,Ee,xe,we,Re,Ce;function ke(){}ke.__reactDisabledLog=!0;function ze(){{if(K===0){ge=console.log,ye=console.info,Ee=console.warn,xe=console.error,we=console.group,Re=console.groupCollapsed,Ce=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ke,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}K++}}function He(){{if(K--,K===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},e,{value:ge}),info:L({},e,{value:ye}),warn:L({},e,{value:Ee}),error:L({},e,{value:xe}),group:L({},e,{value:we}),groupCollapsed:L({},e,{value:Re}),groupEnd:L({},e,{value:Ce})})}K<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=S.ReactCurrentDispatcher,oe;function z(e,t,n){{if(oe===void 0)try{throw Error()}catch(p){var o=p.stack.trim().match(/\n( *(at )?)/);oe=o&&o[1]||""}return`
|
|
18
|
+
`+oe+e}}var ie=!1,H;{var Ze=typeof WeakMap=="function"?WeakMap:Map;H=new Ze}function je(e,t){if(!e||ie)return"";{var n=H.get(e);if(n!==void 0)return n}var o;ie=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var b;b=ae.current,ae.current=null,ze();try{if(t){var f=function(){throw Error()};if(Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(T){o=T}Reflect.construct(e,[],f)}else{try{f.call()}catch(T){o=T}e.call(f.prototype)}}else{try{throw Error()}catch(T){o=T}e()}}catch(T){if(T&&o&&typeof T.stack=="string"){for(var l=T.stack.split(`
|
|
19
|
+
`),j=o.stack.split(`
|
|
20
|
+
`),E=l.length-1,w=j.length-1;E>=1&&w>=0&&l[E]!==j[w];)w--;for(;E>=1&&w>=0;E--,w--)if(l[E]!==j[w]){if(E!==1||w!==1)do if(E--,w--,w<0||l[E]!==j[w]){var O=`
|
|
21
|
+
`+l[E].replace(" at new "," at ");return e.displayName&&O.includes("<anonymous>")&&(O=O.replace("<anonymous>",e.displayName)),typeof e=="function"&&H.set(e,O),O}while(E>=1&&w>=0);break}}}finally{ie=!1,ae.current=b,He(),Error.prepareStackTrace=p}var V=e?e.displayName||e.name:"",M=V?z(V):"";return typeof e=="function"&&H.set(e,M),M}function Qe(e,t,n){return je(e,!1)}function er(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function Z(e,t,n){if(e==null)return"";if(typeof e=="function")return je(e,er(e));if(typeof e=="string")return z(e);switch(e){case y:return z("Suspense");case u:return z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return Qe(e.render);case R:return Z(e.type,t,n);case C:{var o=e,p=o._payload,b=o._init;try{return Z(b(p),t,n)}catch{}}}return""}var B=Object.prototype.hasOwnProperty,Te={},Se=S.ReactDebugCurrentFrame;function Q(e){if(e){var t=e._owner,n=Z(e.type,e._source,t?t.type:null);Se.setExtraStackFrame(n)}else Se.setExtraStackFrame(null)}function rr(e,t,n,o,p){{var b=Function.call.bind(B);for(var f in e)if(b(e,f)){var l=void 0;try{if(typeof e[f]!="function"){var j=Error((o||"React class")+": "+n+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw j.name="Invariant Violation",j}l=e[f](t,f,o,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){l=E}l&&!(l instanceof Error)&&(Q(p),x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",o||"React class",n,f,typeof l),Q(null)),l instanceof Error&&!(l.message in Te)&&(Te[l.message]=!0,Q(p),x("Failed %s type: %s",n,l.message),Q(null))}}}var tr=Array.isArray;function se(e){return tr(e)}function nr(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,n=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function ar(e){try{return Oe(e),!1}catch{return!0}}function Oe(e){return""+e}function Pe(e){if(ar(e))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",nr(e)),Oe(e)}var I=S.ReactCurrentOwner,or={key:!0,ref:!0,__self:!0,__source:!0},De,Fe,ce;ce={};function ir(e){if(B.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function sr(e){if(B.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function cr(e,t){if(typeof e.ref=="string"&&I.current&&t&&I.current.stateNode!==t){var n=F(I.current.type);ce[n]||(x('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(I.current.type),e.ref),ce[n]=!0)}}function lr(e,t){{var n=function(){De||(De=!0,x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function ur(e,t){{var n=function(){Fe||(Fe=!0,x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var fr=function(e,t,n,o,p,b,f){var l={$$typeof:c,type:e,key:t,ref:n,props:f,_owner:b};return l._store={},Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:p}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l};function dr(e,t,n,o,p){{var b,f={},l=null,j=null;n!==void 0&&(Pe(n),l=""+n),sr(t)&&(Pe(t.key),l=""+t.key),ir(t)&&(j=t.ref,cr(t,p));for(b in t)B.call(t,b)&&!or.hasOwnProperty(b)&&(f[b]=t[b]);if(e&&e.defaultProps){var E=e.defaultProps;for(b in E)f[b]===void 0&&(f[b]=E[b])}if(l||j){var w=typeof e=="function"?e.displayName||e.name||"Unknown":e;l&&lr(f,w),j&&ur(f,w)}return fr(e,l,j,p,o,I.current,f)}}var le=S.ReactCurrentOwner,Ne=S.ReactDebugCurrentFrame;function U(e){if(e){var t=e._owner,n=Z(e.type,e._source,t?t.type:null);Ne.setExtraStackFrame(n)}else Ne.setExtraStackFrame(null)}var ue;ue=!1;function fe(e){return typeof e=="object"&&e!==null&&e.$$typeof===c}function $e(){{if(le.current){var e=F(le.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function _r(e){return""}var Ae={};function pr(e){{var t=$e();if(!t){var n=typeof e=="string"?e:e.displayName||e.name;n&&(t=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+n+">.")}return
|
|
25
|
+
Check the top-level render call using <`+n+">.")}return t}}function Le(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=pr(t);if(Ae[n])return;Ae[n]=!0;var o="";e&&e._owner&&e._owner!==le.current&&(o=" It was passed a child from "+F(e._owner.type)+"."),U(e),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,o),U(null)}}function Me(e,t){{if(typeof e!="object")return;if(se(e))for(var n=0;n<e.length;n++){var o=e[n];fe(o)&&Le(o,t)}else if(fe(e))e._store&&(e._store.validated=!0);else if(e){var p=A(e);if(typeof p=="function"&&p!==e.entries)for(var b=p.call(e),f;!(f=b.next()).done;)fe(f.value)&&Le(f.value,t)}}}function vr(e){{var t=e.type;if(t==null||typeof t=="string")return;var n;if(typeof t=="function")n=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===d||t.$$typeof===R))n=t.propTypes;else return;if(n){var o=F(t);rr(n,e.props,"prop",o,e)}else if(t.PropTypes!==void 0&&!ue){ue=!0;var p=F(t);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",p||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function hr(e){{for(var t=Object.keys(e.props),n=0;n<t.length;n++){var o=t[n];if(o!=="children"&&o!=="key"){U(e),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",o),U(null);break}}e.ref!==null&&(U(e),x("Invalid attribute `ref` supplied to `React.Fragment`."),U(null))}}var We={};function Ye(e,t,n,o,p,b){{var f=Ge(e);if(!f){var l="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(l+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var j=_r();j?l+=j:l+=$e();var E;e===null?E="null":se(e)?E="array":e!==void 0&&e.$$typeof===c?(E="<"+(F(e.type)||"Unknown")+" />",l=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,l)}var w=dr(e,t,n,p,b);if(w==null)return w;if(f){var O=t.children;if(O!==void 0)if(o)if(se(O)){for(var V=0;V<O.length;V++)Me(O[V],e);Object.freeze&&Object.freeze(O)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Me(O,e)}if(B.call(t,"key")){var M=F(e),T=Object.keys(t).filter(function(xr){return xr!=="key"}),de=T.length>0?"{key: someKey, "+T.join(": ..., ")+": ...}":"{key: someKey}";if(!We[M+de]){var Er=T.length>0?"{"+T.join(": ..., ")+": ...}":"{}";x(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,de,
|
|
30
|
+
<%s key={someKey} {...props} />`,de,M,Er,M),We[M+de]=!0}}return e===i?hr(w):vr(w),w}}function br(e,t,n){return Ye(e,t,n,!0)}function mr(e,t,n){return Ye(e,t,n,!1)}var gr=mr,yr=br;G.Fragment=i,G.jsx=gr,G.jsxs=yr}()),G}process.env.NODE_ENV==="production"?ve.exports=wr():ve.exports=Rr();var m=ve.exports;const Cr="_button_11cqj_1",kr="_text_11cqj_21",jr="_primary_11cqj_26",Tr="_danger_11cqj_27",Sr="_secondary_11cqj_50",Or="_icon_11cqj_66",Pr="_disabled_11cqj_80",W={button:Cr,text:kr,primary:jr,danger:Tr,secondary:Sr,icon:Or,disabled:Pr};function D(r){return r.map(a=>{if(typeof a=="string")return a.trim();if(typeof a=="object"){const i=[];for(const s in a)a[s]&&i.push(s.trim());return i.join(" ")}}).filter(a=>!!a).join(" ")}const Dr=({disabled:r,onClick:c,text:a,type:i="button",view:s="primary",icon:v,label:h,..._})=>{const d=D([W.button,_==null?void 0:_.className,{[W.primary]:s==="primary",[W.secondary]:s==="secondary",[W.danger]:s==="danger",[W.icon]:s==="icon",[W.disabled]:!!r}]);return m.jsxs("button",{"aria-label":h,type:i,className:d,onClick:r?void 0:c,disabled:r,..._,children:[v&&m.jsx("span",{className:v,"aria-hidden":"true"}),s!=="icon"&&m.jsx("span",{className:W.text,children:a})]})},Fr="_container_b5mrn_1",Nr="_wrapper_b5mrn_7",$r="_input_b5mrn_21",Ar="_invalid_b5mrn_27",Lr="_error_b5mrn_47",Mr="_disabled_b5mrn_51",Y={container:Fr,wrapper:Nr,input:$r,invalid:Ar,error:Lr,disabled:Mr},Wr="_label_16gin_1",Yr="_text_16gin_10",qr="_required_16gin_16",_e={label:Wr,text:Yr,required:qr},he=({label:r,required:c,inputId:a,className:i,isTextHidden:s=!1})=>m.jsxs("label",{htmlFor:a,className:D([_e.label,i]),children:[!s&&m.jsx("span",{className:_e.text,children:r}),c&&m.jsx("abbr",{title:"required",className:_e.required,children:"*"})]}),Ur="_message_1ly5l_1",Vr="_visible_1ly5l_8",Ve={message:Ur,visible:Vr},Kr=({errorId:r,message:c="Invalid input",className:a,visible:i=!1})=>m.jsx("span",{id:r,className:D([Ve.message,a,{[Ve.visible]:i}]),children:c}),Br=({id:r,name:c,label:a,disabled:i,placeholder:s="Type here...",valid:v=!0,required:h=!1,errorMessage:_,defaultValue:d,onChange:y,...u})=>{const[R,C]=P.useState(typeof d=="string"?d:""),g=`${r}_error`,k=D([Y.container,u==null?void 0:u.className]),$=D([Y.wrapper,{[Y.disabled]:!!i,[Y.invalid]:!v}]),A=S=>{const{value:x=""}=S.target;C(x),y&&y(S)};return m.jsxs("div",{className:k,children:[m.jsxs("div",{className:$,children:[m.jsx(he,{label:a,required:h,inputId:r,className:Y.label}),m.jsx("input",{id:r,name:c,type:"text",className:Y.input,disabled:i,placeholder:s,required:h,"aria-invalid":!v,"aria-errormessage":g,value:R,onChange:A,...u})]}),m.jsx(Kr,{errorId:g,message:_,className:Y.error,visible:!v})]})},Ir="_wrapper_gevmw_1",Jr="_combobox_gevmw_17",Gr="_combobox_label_gevmw_42",Xr="_dropdown_gevmw_47",zr="_dropdown_opened_gevmw_68",Hr="_option_gevmw_73",Zr="_active_gevmw_82",Qr="_disabled_gevmw_91",et="_icon_gevmw_97",N={wrapper:Ir,combobox:Jr,combobox_label:Gr,dropdown:Xr,dropdown_opened:zr,option:Hr,active:Zr,disabled:Qr,icon:et},Ke=({ref:r,onClickOutsideHandler:c,dependentRef:a})=>{P.useEffect(()=>{const i=s=>{const v=(r==null?void 0:r.current)&&!r.current.contains(s.target),h=a!=null&&a.current?!a.current.contains(s.target):!0;v&&h&&c()};return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[r,a,c])};var q=(r=>(r.CheckMark="chop-icon__check",r.Home="chop-icon__home",r.Menu="chop-icon__menu",r.Enlarge="chop-icon__enlarge2",r.Shrink="chop-icon__shrink2",r.Settings="chop-icon__cog",r.Delete="chop-icon__bin2",r.Up="chop-icon__circle-up",r.Down="chop-icon__circle-down",r.Right="chop-icon__circle-right",r.Left="chop-icon__circle-left",r.Sound="chop-icon__volume-medium",r.NoSound="chop-icon__volume-mute2",r.LightMode="chop-icon__sun",r.DarkMode="chop-icon__contrast",r.Cancel="chop-icon__close",r.Sidebar="chop-icon__magic-wand",r.Telegram="chop-icon__telegram",r.Github="chop-icon__github",r.Mail="chop-icon__mail4",r.Propositions="chop-icon__cube",r.Resolution="chop-icon__libreoffice",r.Predicates="chop-icon__cubes",r.TruthTables="chop-icon__delicious",r.Syllogisms="chop-icon__dice",r.English="chop-icon__english-lang",r.Russian="chop-icon__russian-lang",r.Required="chop-icon__fire",r.Checked="chop-icon__checkbox-checked",r.Unchecked="chop-icon__checkbox-unchecked",r.Info="chop-icon__exclamation-triangle",r.LinkedIn="chop-icon__linkedin-square",r.File="chop-icon__file-empty",r.Files="chop-icon__files-empty",r.Facebook="chop-icon__facebook2",r.CaretUp="chop-icon__caret-up",r.CaretDown="chop-icon__caret-down",r.SavePDF="chop-icon__file-pdf",r.ExportXML="chop-icon__download",r.ImportXML="chop-icon__upload",r.Copy="chop-icon__copy",r.Paste="chop-icon__paste",r.Cut="chop-icon__scissors",r.Reset="chop-icon__trash",r.Clear="chop-icon__cross",r))(q||{});const rt=({isOpened:r,onClick:c,comboboxId:a,dropdownId:i,selected:s,name:v,placeholder:h,disabled:_,required:d})=>{const y=D([N.icon,{[q.CaretUp]:r,[q.CaretDown]:!r}]);return m.jsxs("button",{type:"button",name:v,value:s==null?void 0:s.id,role:"combobox","aria-haspopup":"listbox","aria-expanded":r,"aria-controls":i,id:a,className:N.combobox,onClick:c,disabled:_,"aria-required":d,children:[m.jsx("span",{className:N.combobox_label,children:(s==null?void 0:s.label)??h}),m.jsx("span",{className:y,"aria-hidden":"true"})]})};function pe(r){const c=document.getElementById(r);c&&c.focus()}const tt=({value:r,isSelected:c,onSelect:a})=>{const{id:i,label:s}=r,v=D([N.icon,q.CheckMark]),h=_=>d=>{switch(d.key){case" ":case"SpaceBar":case"Enter":d.preventDefault(),a(_);break}};return m.jsxs("li",{id:i,role:"option",className:N.option,"aria-selected":c,tabIndex:0,onKeyDown:h(i),onClick:()=>a(i),children:[m.jsx("span",{children:s}),c&&m.jsx("span",{className:v,"aria-hidden":"true"})]})},nt=({values:r,isOpened:c,onClose:a,onSelect:i,dropdownId:s,comboboxId:v,selected:h})=>{const _=D([N.dropdown,{[N.dropdown_opened]:c}]),d=u=>{i(u),a(),pe(v)},y=u=>{let R="";r.forEach(g=>{document.getElementById(g.id)===document.activeElement&&(R=g.id)});const C=r.findIndex(g=>g.id===R);switch(u.key){case"Escape":u.preventDefault(),a();break;case"ArrowUp":{u.preventDefault();const g=C-1>=0?C-1:r.length-1,k=r[g];k&&pe(k.id);break}case"ArrowDown":case"Tab":{u.preventDefault();const g=C===r.length-1?0:C+1,k=r[g];k&&pe(k.id);break}}};return m.jsx("ul",{className:_,role:"listbox",id:s,tabIndex:-1,onKeyDown:y,children:r.map(u=>m.jsx(tt,{value:u,onSelect:()=>d(u.id),isSelected:u.id===(h==null?void 0:h.id)},u.id))})},Be=({ref:r,keyCode:c,onKeyPress:a})=>{P.useEffect(()=>{const i=s=>{(s==null?void 0:s.code)===c&&(r!=null&&r.current)&&a()};return document.addEventListener("keydown",i,!1),()=>{document.removeEventListener("keydown",i,!1)}},[r,c,a])},at=({id:r,values:c,onSelectChange:a,name:i,label:s,required:v=!1,placeholder:h="Not selected",disabled:_=!1,...d})=>{const[y,u]=P.useState(!1),[R,C]=P.useState(),g=`${r}_combobox`,k=`${r}_dropdown`,$=D([N.wrapper,d==null?void 0:d.className,{[N.disabled]:_}]),A=P.useRef(null),S=()=>u(!1),x=()=>u(!y),re=te=>{const X=c.find(ne=>ne.id===te);C(X),a==null||a(X)};return Ke({ref:A,onClickOutsideHandler:S}),Be({keyCode:"Escape",ref:A,onKeyPress:S}),m.jsxs("div",{className:$,ref:A,children:[m.jsx(he,{label:s,required:v,inputId:g,className:N.label}),m.jsx(rt,{name:i,isOpened:y,comboboxId:g,dropdownId:k,onClick:x,selected:R,placeholder:h,disabled:_,required:v}),m.jsx(nt,{values:c,selected:R,isOpened:y,onClose:S,dropdownId:k,comboboxId:g,onSelect:re})]})},ot="_wrapper_1ab48_1",it="_input_1ab48_9",st="_label_1ab48_23",ct="_disabled_1ab48_38",ee={wrapper:ot,input:it,label:st,disabled:ct},lt=({id:r,name:c,label:a,disabled:i,required:s=!1,onChange:v,isLabelHidden:h,className:_,...d})=>{const[y,u]=P.useState(!1),R=D([ee.wrapper,_,{[ee.disabled]:!!i}]),C=D([ee.label,{[q.Checked]:y,[q.Unchecked]:!y}]),g=k=>{if(i)return;const $=k.target.checked;u($),v&&v(k)};return m.jsxs("div",{className:R,children:[m.jsx("input",{id:r,name:c,type:"checkbox",className:ee.input,disabled:i,required:s,checked:y,onChange:g,"aria-label":h?a:void 0,...d}),m.jsx(he,{label:a,required:s,inputId:r,className:C,isTextHidden:h})]})},ut=(r,c=300)=>{const[a,i]=P.useState(!1);return P.useEffect(()=>{r&&!a?i(!0):!r&&a&&setTimeout(()=>{i(!1)},c)},[r]),a},ft=({modalRef:r,isOpened:c})=>{P.useEffect(()=>{const a=r.current;if(!c||!a)return;const i=a.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),s=i[0],v=i[i.length-1],h=_=>{_.key==="Tab"&&(_.shiftKey&&document.activeElement===s?(_.preventDefault(),v.focus()):!_.shiftKey&&document.activeElement===v&&(_.preventDefault(),s.focus()))};return a.addEventListener("keydown",h),()=>{a.removeEventListener("keydown",h)}},[r,c])};exports.ChopIcon=q;exports.ChopLogicButton=Dr;exports.ChopLogicCheckbox=lt;exports.ChopLogicSelect=at;exports.ChopLogicTextInput=Br;exports.useClickOutside=Ke;exports.useKeyPress=Be;exports.useModalFocusTrap=ft;exports.useMount=ut;
|
|
31
31
|
//# sourceMappingURL=index.cjs.js.map
|