@mobilestockweb/confirmation 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +51 -0
  2. package/index.js +1 -0
  3. package/package.json +17 -0
package/index.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Form } from '@mobilestockweb/form';
3
+ import { IconProps } from '@mobilestockweb/icons';
4
+ import { TypographyProps } from '@mobilestockweb/typography';
5
+ import { ReactNode } from 'react';
6
+
7
+ declare function Confirm(props: Omit<React.ComponentProps<typeof Form.Button>, 'onClick' | 'type'>): react_jsx_runtime.JSX.Element;
8
+ declare namespace Confirm {
9
+ var displayName: string;
10
+ }
11
+
12
+ declare function Cancel(props: Omit<React.ComponentProps<typeof Form.Button>, 'onClick' | 'type'>): react_jsx_runtime.JSX.Element;
13
+ declare namespace Cancel {
14
+ var displayName: string;
15
+ }
16
+
17
+ declare function Icon(props: IconProps): react_jsx_runtime.JSX.Element;
18
+ declare namespace Icon {
19
+ var displayName: string;
20
+ }
21
+
22
+ declare function TitleBase(props: TypographyProps): react_jsx_runtime.JSX.Element;
23
+ declare namespace TitleBase {
24
+ var displayName: string;
25
+ }
26
+
27
+ declare function Message(props: TypographyProps): react_jsx_runtime.JSX.Element;
28
+ declare namespace Message {
29
+ var displayName: string;
30
+ }
31
+
32
+ interface ConfirmationProps {
33
+ children?: ReactNode;
34
+ keyWord: string;
35
+ onCancel?(): void;
36
+ onConfirm(): void;
37
+ }
38
+ declare function ConfirmationProvider(props: ConfirmationProps): react_jsx_runtime.JSX.Element;
39
+
40
+ declare const Confirmation: typeof ConfirmationProvider & {
41
+ Title: typeof TitleBase & {
42
+ Icon: typeof Icon;
43
+ };
44
+ Message: typeof Message;
45
+ Button: (() => never) & {
46
+ Cancel: typeof Cancel;
47
+ Confirm: typeof Confirm;
48
+ };
49
+ };
50
+
51
+ export { Confirmation };
package/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var _=Object.create;var C=Object.defineProperty,$=Object.defineProperties,q=Object.getOwnPropertyDescriptor,K=Object.getOwnPropertyDescriptors,J=Object.getOwnPropertyNames,b=Object.getOwnPropertySymbols,Q=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var D=(o,t,n)=>t in o?C(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,i=(o,t)=>{for(var n in t||(t={}))E.call(t,n)&&D(o,n,t[n]);if(b)for(var n of b(t))Y.call(t,n)&&D(o,n,t[n]);return o},g=(o,t)=>$(o,K(t));var Z=(o,t)=>{for(var n in t)C(o,n,{get:t[n],enumerable:!0})},R=(o,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of J(t))!E.call(o,e)&&e!==n&&C(o,e,{get:()=>t[e],enumerable:!(a=q(t,e))||a.enumerable});return o};var j=(o,t,n)=>(n=o!=null?_(Q(o)):{},R(t||!o||!o.__esModule?C(n,"default",{value:o,enumerable:!0}):n,o)),oo=o=>R(C({},"__esModule",{value:!0}),o);var ro={};Z(ro,{Confirmation:()=>no});module.exports=oo(ro);var w=require("@mobilestockweb/form");var f=require("react"),T=require("zod");var h=require("react"),m=require("@mobilestockweb/container"),N=require("@mobilestockweb/form"),O=j(require("@mobilestockweb/tools"));var k=require("@mobilestockweb/form");var I=require("react/jsx-runtime");function p(o){return(0,I.jsx)(k.Form.Button,g(i({text:"Confirmar",backgroundColor:"DEFAULT_DARK"},o),{type:"SUBMIT"}))}p.displayName="Confirmation.Button.Confirm";var v=require("@mobilestockweb/typography");var F=require("react/jsx-runtime");function s(o){return(0,F.jsx)(v.Typography,i({align:"CENTER"},o))}s.displayName="Confirmation.Message";var M=require("@mobilestockweb/icons");var S=require("react/jsx-runtime");function l(o){return(0,S.jsx)(M.Icon,i({size:"LG"},o))}l.displayName="Confirmation.Title.Icon";var V=require("@mobilestockweb/typography");var z=require("react/jsx-runtime");function c(o){return(0,z.jsx)(V.Typography,i({size:"XL",weight:"BOLD"},o))}c.displayName="Confirmation.TitleBase";var r=require("react/jsx-runtime");function d(o,t){return h.Children.toArray(t).find(n=>(0,h.isValidElement)(n)&&O.default.isComponentWithDisplayName(n.type)&&n.type.displayName===o)}function U(o){let{onCancel:t,handleSubmit:n}=P(),a=d(l.displayName,o.children),e=d(c.displayName,o.children),B=d(s.displayName,o.children),G=d(u.Cancel.displayName,o.children),X=d(u.Confirm.displayName,o.children);return(0,r.jsxs)(m.Container.Vertical,{gap:"MD",align:"CENTER",children:[(0,r.jsxs)(m.Container.Horizontal,{align:"CENTER",gap:"XS",children:[a,e]}),(0,r.jsxs)(m.Container.Vertical,{padding:"MD",gap:"MD",children:[B,(0,r.jsx)(N.Form,{onSubmit:n,children:(0,r.jsxs)(m.Container.Vertical,{gap:"MD",children:[(0,r.jsx)(N.Form.Input,{label:"Digite aqui",name:"textConfirmation",type:"text"}),(0,r.jsxs)(m.Container.Horizontal,{gap:"MD",align:"CENTER",children:[t&&(G||(0,r.jsx)(y,{})),X||(0,r.jsx)(p,{})]})]})})]})]})}var x=require("react/jsx-runtime"),W=(0,f.createContext)(void 0);function L(o){let t=(0,f.useCallback)(({data:a})=>{T.z.object({textConfirmation:T.z.string().refine(B=>B.trim().toUpperCase()===`${o.keyWord.toUpperCase()}`,{message:`Digite ${o.keyWord.toUpperCase()} para prosseguir`})}).parse(a),o.onConfirm()},[o.keyWord,o.onConfirm]),n={keyWord:o.keyWord,onCancel:o.onCancel,onConfirm:o.onConfirm,handleSubmit:t};return(0,x.jsx)(W.Provider,{value:n,children:(0,x.jsx)(U,{children:o.children})})}function P(){let o=(0,f.useContext)(W);if(!o)throw new Error("useConfirmation should used inside a ConfirmationProvider");return o}var H=require("react/jsx-runtime");function y(o){let{onCancel:t}=P();return(0,H.jsx)(w.Form.Button,g(i({text:"Cancelar",backgroundColor:"CANCEL_LIGHT"},o),{type:"BUTTON",onClick:t}))}y.displayName="Confirmation.Button.Cancel";function to(){throw new Error("The Confirmation.Button component should not be used directly. Use Confirmation.Button.Cancel or Confirmation.Button.Confirm instead.")}var u=Object.assign(to,{Cancel:y,Confirm:p});var A=Object.assign(c,{Icon:l});var no=Object.assign(L,{Title:A,Message:s,Button:u});0&&(module.exports={Confirmation});
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@mobilestockweb/confirmation",
3
+ "version": "0.0.1",
4
+ "main": "index.js",
5
+ "dependencies": {
6
+ "@mobilestockweb/typography": "^0.0.6",
7
+ "@mobilestockweb/container": "^0.1.0",
8
+ "@mobilestockweb/form": "^0.2.1",
9
+ "@mobilestockweb/tools": "^0.0.16",
10
+ "@mobilestockweb/icons": "^0.0.7"
11
+ },
12
+ "peerDependencies": {
13
+ "react": "18.2.0",
14
+ "react-dom": "18.2.0",
15
+ "zod": "^3.24.2"
16
+ }
17
+ }