fictoan-react 1.0.0-alpha.2 → 1.0.0-alpha.5

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 (59) hide show
  1. package/dist/components/Element/Tags.cjs +1 -0
  2. package/dist/components/Element/Tags.d.ts +11 -0
  3. package/dist/components/Element/Tags.js +28 -0
  4. package/dist/components/Element/index.cjs +1 -1
  5. package/dist/components/Element/index.d.ts +1 -0
  6. package/dist/components/Element/index.js +11 -1
  7. package/dist/components/Form/BaseInputComponent/BaseInputComponent.cjs +1 -1
  8. package/dist/components/Form/BaseInputComponent/BaseInputComponent.js +2 -2
  9. package/dist/components/Form/{CheckBox/CheckBox.cjs → Checkbox/Checkbox.cjs} +1 -1
  10. package/dist/components/Form/{CheckBox/CheckBox.d.ts → Checkbox/Checkbox.d.ts} +1 -1
  11. package/dist/components/Form/{CheckBox/CheckBox.js → Checkbox/Checkbox.js} +1 -1
  12. package/dist/components/Form/Checkbox/Checkbox.stories.d.ts +6 -0
  13. package/dist/components/Form/{FormWrapper/FormWrapper.cjs → Form/Form.cjs} +1 -1
  14. package/dist/components/Form/Form/Form.d.ts +12 -0
  15. package/dist/components/Form/Form/Form.js +53 -0
  16. package/dist/components/Form/{FormWrapper/FormWrapper.stories.d.ts → Form/Form.stories.d.ts} +3 -3
  17. package/dist/components/Form/{FormWrapper → Form}/FormGenerator.cjs +1 -1
  18. package/dist/components/Form/{FormWrapper → Form}/FormGenerator.js +10 -10
  19. package/dist/components/Form/FormItemGroup/FormItemGroup.d.ts +2 -2
  20. package/dist/components/Form/InputField/InputField.cjs +1 -1
  21. package/dist/components/Form/InputField/InputField.js +1 -1
  22. package/dist/components/Form/PinInputField/PinInputField.cjs +1 -0
  23. package/dist/components/Form/PinInputField/PinInputField.d.ts +19 -0
  24. package/dist/components/Form/PinInputField/PinInputField.js +237 -0
  25. package/dist/components/Form/PinInputField/PinInputField.stories.d.ts +6 -0
  26. package/dist/components/Form/PinInputField/index.cjs +1 -0
  27. package/dist/components/Form/PinInputField/index.d.ts +1 -0
  28. package/dist/components/Form/PinInputField/index.js +11 -0
  29. package/dist/components/Form/RadioButton/SlidingSelector.cjs +1 -1
  30. package/dist/components/Form/RadioButton/SlidingSelector.d.ts +2 -3
  31. package/dist/components/Form/RadioButton/SlidingSelector.js +30 -24
  32. package/dist/components/Form/RadioButton/SlidingSelector.stories.d.ts +6 -0
  33. package/dist/components/Form/Select/Select.cjs +1 -1
  34. package/dist/components/Form/Select/Select.d.ts +10 -2
  35. package/dist/components/Form/Select/Select.js +23 -20
  36. package/dist/components/Form/index.cjs +1 -1
  37. package/dist/components/Form/index.d.ts +8 -7
  38. package/dist/components/Form/index.js +13 -12
  39. package/dist/components/ProgressBar/ProgressBar.cjs +1 -1
  40. package/dist/components/ProgressBar/ProgressBar.d.ts +2 -2
  41. package/dist/components/ProgressBar/ProgressBar.js +3 -3
  42. package/dist/components/index.cjs +1 -1
  43. package/dist/components/index.d.ts +2 -2
  44. package/dist/components/index.js +22 -11
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.css +1 -1
  47. package/dist/index.d.ts +2 -2
  48. package/dist/index.js +25 -12
  49. package/package.json +1 -1
  50. package/dist/components/Form/CheckBox/CheckBox.stories.d.ts +0 -6
  51. package/dist/components/Form/FormWrapper/FormWrapper.d.ts +0 -12
  52. package/dist/components/Form/FormWrapper/FormWrapper.js +0 -53
  53. package/dist/sliding-selector-k52RqIHf.cjs +0 -1
  54. package/dist/sliding-selector-w40geAFS.js +0 -1
  55. /package/dist/components/Form/{CheckBox → Checkbox}/Switch.cjs +0 -0
  56. /package/dist/components/Form/{CheckBox → Checkbox}/Switch.d.ts +0 -0
  57. /package/dist/components/Form/{CheckBox → Checkbox}/Switch.js +0 -0
  58. /package/dist/components/Form/{CheckBox → Checkbox}/Switch.stories.d.ts +0 -0
  59. /package/dist/components/Form/{FormWrapper → Form}/FormGenerator.d.ts +0 -0
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("./Element.cjs");function t(){return t=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},t.apply(this,arguments)}var o=function(o){return e.forwardRef((function(n,i){return e.createElement(r.Element,t({as:o,ref:i},n))}))},n=o("div"),i=o("article"),s=o("aside"),a=o("body"),c=o("footer"),p=o("header"),u=o("main"),l=o("nav"),d=o("section");exports.Article=i,exports.Aside=s,exports.Body=a,exports.Div=n,exports.Footer=c,exports.Header=p,exports.Main=u,exports.Nav=l,exports.Section=d;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { ElementProps } from "./constants";
3
+ export declare const Div: React.ForwardRefExoticComponent<ElementProps<{}> & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
4
+ export declare const Article: React.ForwardRefExoticComponent<ElementProps<{}> & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
5
+ export declare const Aside: React.ForwardRefExoticComponent<ElementProps<{}> & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
6
+ export declare const Body: React.ForwardRefExoticComponent<ElementProps<{}> & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
7
+ export declare const Footer: React.ForwardRefExoticComponent<ElementProps<{}> & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
8
+ export declare const Header: React.ForwardRefExoticComponent<ElementProps<{}> & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
9
+ export declare const Main: React.ForwardRefExoticComponent<ElementProps<{}> & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
10
+ export declare const Nav: React.ForwardRefExoticComponent<ElementProps<{}> & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
11
+ export declare const Section: React.ForwardRefExoticComponent<ElementProps<{}> & React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,28 @@
1
+ import r from "react";
2
+ import { Element as e } from "./Element.js";
3
+ function t() {
4
+ return t = Object.assign ? Object.assign.bind() : function(r2) {
5
+ for (var e2 = 1; e2 < arguments.length; e2++) {
6
+ var t2 = arguments[e2];
7
+ for (var n2 in t2)
8
+ Object.prototype.hasOwnProperty.call(t2, n2) && (r2[n2] = t2[n2]);
9
+ }
10
+ return r2;
11
+ }, t.apply(this, arguments);
12
+ }
13
+ var n = function(n2) {
14
+ return r.forwardRef(function(o2, a2) {
15
+ return r.createElement(e, t({ as: n2, ref: a2 }, o2));
16
+ });
17
+ }, o = n("div"), a = n("article"), i = n("aside"), c = n("body"), f = n("footer"), s = n("header"), p = n("main"), u = n("nav"), l = n("section");
18
+ export {
19
+ a as Article,
20
+ i as Aside,
21
+ c as Body,
22
+ o as Div,
23
+ f as Footer,
24
+ s as Header,
25
+ p as Main,
26
+ u as Nav,
27
+ l as Section
28
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Element.cjs");require("react"),exports.Element=e.Element;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Element.cjs"),r=require("./Tags.cjs");require("react"),exports.Element=e.Element,exports.Article=r.Article,exports.Aside=r.Aside,exports.Body=r.Body,exports.Div=r.Div,exports.Footer=r.Footer,exports.Header=r.Header,exports.Main=r.Main,exports.Nav=r.Nav,exports.Section=r.Section;
@@ -1,2 +1,3 @@
1
1
  export { Element } from "./Element";
2
+ export { Div, Article, Aside, Body, Footer, Header, Main, Nav, Section } from "./Tags";
2
3
  export type { ElementProps } from "./constants";
@@ -1,5 +1,15 @@
1
1
  import { Element } from "./Element.js";
2
+ import { Article, Aside, Body, Div, Footer, Header, Main, Nav, Section } from "./Tags.js";
2
3
  import "react";
3
4
  export {
4
- Element
5
+ Article,
6
+ Aside,
7
+ Body,
8
+ Div,
9
+ Element,
10
+ Footer,
11
+ Header,
12
+ Main,
13
+ Nav,
14
+ Section
5
15
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../../Element/Element.cjs"),r=require("../InputLabel/InputLabel.cjs"),a=require("../FormItem/FormItem.cjs");var n=["as","className","label","helpText","errorText","iconLeft","iconRight","validateThis","classNames"];function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},l.apply(this,arguments)}var s=e.forwardRef((function(s,c){var i=s.as,o=s.className,m=s.label,u=s.helpText,p=s.errorText,f=s.iconLeft,b=s.iconRight,h=s.validateThis,E=s.classNames,v=function(e,t){if(null==e)return{};var r,a,n=function(e,t){if(null==e)return{};var r,a,n={},l=Object.keys(e);for(a=0;a<l.length;a++)r=l[a],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)r=l[a],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(s,n);return e.createElement(a.FormItem,{required:v.required},e.createElement(t.Element,l({as:i,ref:c,classNames:[o||"",f?"with-icon-left":"",b?"with-icon-right":"",h?"validate-this":""].concat(E||[])},v)),f&&e.createElement(t.Element,{as:"span",className:"icon-left"},f),b&&e.createElement(t.Element,{as:"span",className:"icon-right"},b),m&&e.createElement(r.InputLabel,{label:m,htmlFor:v.id}),(u||p)&&e.createElement(t.Element,{as:"div",className:"info-section vertically-center-items",marginTop:"nano"},u&&e.createElement(t.Element,{as:"span",className:"help-text"},u),p&&e.createElement(t.Element,{as:"span",className:"error-text"},p)))}));exports.BaseInputComponent=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../../Element/Element.cjs"),r=require("../InputLabel/InputLabel.cjs"),a=require("../FormItem/FormItem.cjs");var n=["as","className","label","helpText","errorText","iconLeft","iconRight","validateThis","classNames"];function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},l.apply(this,arguments)}var s=e.forwardRef((function(s,c){var i=s.as,o=s.className,m=s.label,u=s.helpText,p=s.errorText,f=s.iconLeft,b=s.iconRight,h=s.validateThis,E=s.classNames,v=function(e,t){if(null==e)return{};var r,a,n=function(e,t){if(null==e)return{};var r,a,n={},l=Object.keys(e);for(a=0;a<l.length;a++)r=l[a],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)r=l[a],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(s,n);return e.createElement(a.FormItem,{"data-form-item":!0,required:v.required},e.createElement(t.Element,l({as:i,ref:c,classNames:[o||"",f?"with-icon-left":"",b?"with-icon-right":"",h?"validate-this":""].concat(E||[])},v)),f&&e.createElement(t.Element,{as:"span",className:"icon-left"},f),b&&e.createElement(t.Element,{as:"span",className:"icon-right"},b),m&&e.createElement(r.InputLabel,{label:m,htmlFor:v.id}),(u||p)&&e.createElement(t.Element,{as:"div",className:"info-section vertically-center-items",marginTop:"nano"},u&&e.createElement(t.Element,{as:"span",className:"help-text"},u),p&&e.createElement(t.Element,{as:"span",className:"error-text"},p)))}));exports.BaseInputComponent=s;
@@ -32,8 +32,8 @@ function s(e2, t2) {
32
32
  return n2;
33
33
  }
34
34
  var i = /* @__PURE__ */ e.forwardRef(function(i2, o) {
35
- var c = i2.as, m = i2.className, f = i2.label, p = i2.helpText, u = i2.errorText, h = i2.iconLeft, b = i2.iconRight, v = i2.validateThis, g = i2.classNames, O = s(i2, n);
36
- return e.createElement(a, { required: O.required }, /* @__PURE__ */ e.createElement(t, l({ as: c, ref: o, classNames: [m || "", h ? "with-icon-left" : "", b ? "with-icon-right" : "", v ? "validate-this" : ""].concat(g || []) }, O)), h && /* @__PURE__ */ e.createElement(t, { as: "span", className: "icon-left" }, h), b && /* @__PURE__ */ e.createElement(t, { as: "span", className: "icon-right" }, b), f && /* @__PURE__ */ e.createElement(r, { label: f, htmlFor: O.id }), (p || u) && /* @__PURE__ */ e.createElement(t, { as: "div", className: "info-section vertically-center-items", marginTop: "nano" }, p && /* @__PURE__ */ e.createElement(t, { as: "span", className: "help-text" }, p), u && /* @__PURE__ */ e.createElement(t, { as: "span", className: "error-text" }, u)));
35
+ var c = i2.as, m = i2.className, f = i2.label, p = i2.helpText, u = i2.errorText, h = i2.iconLeft, b = i2.iconRight, v = i2.validateThis, d = i2.classNames, g = s(i2, n);
36
+ return e.createElement(a, { "data-form-item": true, required: g.required }, /* @__PURE__ */ e.createElement(t, l({ as: c, ref: o, classNames: [m || "", h ? "with-icon-left" : "", b ? "with-icon-right" : "", v ? "validate-this" : ""].concat(d || []) }, g)), h && /* @__PURE__ */ e.createElement(t, { as: "span", className: "icon-left" }, h), b && /* @__PURE__ */ e.createElement(t, { as: "span", className: "icon-right" }, b), f && /* @__PURE__ */ e.createElement(r, { label: f, htmlFor: g.id }), (p || u) && /* @__PURE__ */ e.createElement(t, { as: "div", className: "info-section vertically-center-items", marginTop: "nano" }, p && /* @__PURE__ */ e.createElement(t, { as: "span", className: "help-text" }, p), u && /* @__PURE__ */ e.createElement(t, { as: "span", className: "error-text" }, u)));
37
37
  });
38
38
  export {
39
39
  i as BaseInputComponent
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../../Element/Element.cjs"),r=require("../BaseInputComponent/BaseInputComponent.cjs");function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},n.apply(this,arguments)}require("../InputLabel/InputLabel.cjs"),require("../FormItem/FormItem.cjs");var o=e.forwardRef((function(o,a){var c=n({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(o),o));return e.createElement(t.Element,{as:"div","data-checkbox":!0,ref:a},e.createElement(r.BaseInputComponent,n({as:"input",type:"checkbox"},c)))}));exports.CheckBox=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../../Element/Element.cjs"),r=require("../BaseInputComponent/BaseInputComponent.cjs");function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},n.apply(this,arguments)}require("../InputLabel/InputLabel.cjs"),require("../FormItem/FormItem.cjs");var o=e.forwardRef((function(o,a){var c=n({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(o),o));return e.createElement(t.Element,{as:"div","data-checkbox":!0,ref:a},e.createElement(r.BaseInputComponent,n({as:"input",type:"checkbox"},c)))}));exports.Checkbox=o;
@@ -2,4 +2,4 @@ import React from "react";
2
2
  import { BaseInputComponentProps } from "../BaseInputComponent/constants";
3
3
  export type CheckboxElementType = HTMLInputElement;
4
4
  export type CheckboxProps = Omit<BaseInputComponentProps<CheckboxElementType>, "as">;
5
- export declare const CheckBox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
5
+ export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
@@ -21,5 +21,5 @@ var o = /* @__PURE__ */ t.forwardRef(function(o2, a) {
21
21
  return t.createElement(e, { as: "div", "data-checkbox": true, ref: a }, /* @__PURE__ */ t.createElement(r, n({ as: "input", type: "checkbox" }, p)));
22
22
  });
23
23
  export {
24
- o as CheckBox
24
+ o as Checkbox
25
25
  };
@@ -0,0 +1,6 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { Checkbox } from "./Checkbox";
3
+ declare const meta: Meta<typeof Checkbox>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Checkbox>;
6
+ export declare const Default: Story;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("../../Element/Element.cjs"),t=require("../../Callout/Callout.cjs"),n=require("./FormGenerator.cjs");require("../../Row/Row.cjs"),require("../../Portion/Portion.cjs"),require("../InputLabel/InputLabel.cjs"),require("../InputField/InputField.cjs"),require("../BaseInputComponent/BaseInputComponent.cjs"),require("../FormItem/FormItem.cjs"),require("../InputField/FileUpload.cjs"),require("../CheckBox/CheckBox.cjs"),require("../CheckBox/Switch.cjs"),require("../RadioButton/RadioButton.cjs"),require("../RadioButton/RadioGroup.cjs"),require("../Select/Select.cjs"),require("../TextArea/TextArea.cjs");var o=["spacing","fields","onFieldsChange","children","errorText"];function i(){return i=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},i.apply(this,arguments)}var a=e.forwardRef((function(a,u){var c=a.spacing,l=void 0===c?"small":c,s=a.fields,p=a.onFieldsChange,j=a.children,d=a.errorText,f=function(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}(a,o),m=[];return l&&m.push("spacing-".concat(l)),s&&s.length>0&&(j=[n.generateFormThroughConfig(s,p,l),j]),e.createElement(r.Element,i({as:"form","data-form-wrapper":!0,ref:u,classNames:m},f),j,d&&e.createElement(t.Callout,{kind:"error"},d))}));exports.FormWrapper=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("../../Element/Element.cjs"),t=require("../../Callout/Callout.cjs"),n=require("./FormGenerator.cjs");require("../../Row/Row.cjs"),require("../../Portion/Portion.cjs"),require("../InputLabel/InputLabel.cjs"),require("../InputField/InputField.cjs"),require("../BaseInputComponent/BaseInputComponent.cjs"),require("../FormItem/FormItem.cjs"),require("../InputField/FileUpload.cjs"),require("../Checkbox/Checkbox.cjs"),require("../Checkbox/Switch.cjs"),require("../RadioButton/RadioButton.cjs"),require("../RadioButton/RadioGroup.cjs"),require("../Select/Select.cjs"),require("../TextArea/TextArea.cjs");var o=["spacing","fields","onFieldsChange","children","errorText"];function i(){return i=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},i.apply(this,arguments)}var u=e.forwardRef((function(u,a){var c=u.spacing,l=void 0===c?"small":c,s=u.fields,p=u.onFieldsChange,j=u.children,d=u.errorText,f=function(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}(u,o),m=[];return l&&m.push("spacing-".concat(l)),s&&s.length>0&&(j=[n.generateFormThroughConfig(s,p,l),j]),e.createElement(r.Element,i({as:"form","data-form":!0,ref:a,classNames:m},f),j,d&&e.createElement(t.Callout,{kind:"error"},d))}));exports.Form=u;
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import { CommonAndHTMLProps, SpacingTypes } from "../../Element/constants";
3
+ import { FormFieldsConfig } from "./FormGenerator";
4
+ export interface FormCustomProps {
5
+ spacing?: SpacingTypes;
6
+ fields?: FormFieldsConfig[];
7
+ onFieldsChange?: React.FormEventHandler;
8
+ errorText?: string;
9
+ }
10
+ export type FormElementType = HTMLFormElement;
11
+ export type FormProps = Omit<CommonAndHTMLProps<FormElementType>, keyof FormCustomProps> & FormCustomProps;
12
+ export declare const Form: React.ForwardRefExoticComponent<Omit<CommonAndHTMLProps<HTMLFormElement>, keyof FormCustomProps> & FormCustomProps & React.RefAttributes<HTMLFormElement>>;
@@ -0,0 +1,53 @@
1
+ import t from "react";
2
+ import { Element as r } from "../../Element/Element.js";
3
+ import { Callout as e } from "../../Callout/Callout.js";
4
+ import { generateFormThroughConfig as o } from "./FormGenerator.js";
5
+ import "../../Row/Row.js";
6
+ import "../../Portion/Portion.js";
7
+ import "../InputLabel/InputLabel.js";
8
+ import "../InputField/InputField.js";
9
+ import "../BaseInputComponent/BaseInputComponent.js";
10
+ import "../FormItem/FormItem.js";
11
+ import "../InputField/FileUpload.js";
12
+ import "../Checkbox/Checkbox.js";
13
+ import "../Checkbox/Switch.js";
14
+ import "../RadioButton/RadioButton.js";
15
+ import "../RadioButton/RadioGroup.js";
16
+ import "../Select/Select.js";
17
+ import "../TextArea/TextArea.js";
18
+ var n = ["spacing", "fields", "onFieldsChange", "children", "errorText"];
19
+ function i() {
20
+ return i = Object.assign ? Object.assign.bind() : function(t2) {
21
+ for (var r2 = 1; r2 < arguments.length; r2++) {
22
+ var e2 = arguments[r2];
23
+ for (var o2 in e2)
24
+ Object.prototype.hasOwnProperty.call(e2, o2) && (t2[o2] = e2[o2]);
25
+ }
26
+ return t2;
27
+ }, i.apply(this, arguments);
28
+ }
29
+ function a(t2, r2) {
30
+ if (null == t2)
31
+ return {};
32
+ var e2, o2, n2 = function(t3, r3) {
33
+ if (null == t3)
34
+ return {};
35
+ var e3, o3, n3 = {}, i3 = Object.keys(t3);
36
+ for (o3 = 0; o3 < i3.length; o3++)
37
+ e3 = i3[o3], r3.indexOf(e3) >= 0 || (n3[e3] = t3[e3]);
38
+ return n3;
39
+ }(t2, r2);
40
+ if (Object.getOwnPropertySymbols) {
41
+ var i2 = Object.getOwnPropertySymbols(t2);
42
+ for (o2 = 0; o2 < i2.length; o2++)
43
+ e2 = i2[o2], r2.indexOf(e2) >= 0 || Object.prototype.propertyIsEnumerable.call(t2, e2) && (n2[e2] = t2[e2]);
44
+ }
45
+ return n2;
46
+ }
47
+ var p = /* @__PURE__ */ t.forwardRef(function(p2, l) {
48
+ var s = p2.spacing, m = void 0 === s ? "small" : s, c = p2.fields, u = p2.onFieldsChange, f = p2.children, j = p2.errorText, d = a(p2, n), b = [];
49
+ return m && b.push("spacing-".concat(m)), c && c.length > 0 && (f = [o(c, u, m), f]), /* @__PURE__ */ t.createElement(r, i({ as: "form", "data-form": true, ref: l, classNames: b }, d), f, j && /* @__PURE__ */ t.createElement(e, { kind: "error" }, j));
50
+ });
51
+ export {
52
+ p as Form
53
+ };
@@ -1,7 +1,7 @@
1
1
  import { Meta, StoryObj } from "@storybook/react";
2
- import { FormWrapper } from "./FormWrapper";
3
- declare const meta: Meta<typeof FormWrapper>;
2
+ import { Form } from "./Form";
3
+ declare const meta: Meta<typeof Form>;
4
4
  export default meta;
5
- type Story = StoryObj<typeof FormWrapper>;
5
+ type Story = StoryObj<typeof Form>;
6
6
  export declare const Default: Story;
7
7
  export declare const UsingFieldsProp: Story;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../../Element/Element.cjs"),r=require("../../Row/Row.cjs"),n=require("../../Portion/Portion.cjs"),o=require("../InputLabel/InputLabel.cjs"),a=require("../InputField/InputField.cjs"),i=require("../InputField/FileUpload.cjs"),l=require("../CheckBox/CheckBox.cjs"),u=require("../CheckBox/Switch.cjs"),p=require("../RadioButton/RadioButton.cjs"),c=require("../RadioButton/RadioGroup.cjs"),s=require("../Select/Select.cjs"),d=require("../TextArea/TextArea.cjs");require("../BaseInputComponent/BaseInputComponent.cjs"),require("../FormItem/FormItem.cjs");var b=["as"],S=["desktopSpan","tabletLandscapeSpan","tabletPortraitSpan","mobileSpan","isHorizontal"];function j(){return j=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},j.apply(this,arguments)}function m(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var f={CheckBox:l.CheckBox,Switch:u.Switch,InputField:a.InputField,FileUpload:i.FileUpload,InputLabel:o.InputLabel,RadioButton:p.RadioButton,RadioGroup:c.RadioGroup,Select:s.Select,TextArea:d.TextArea,Empty:"div"},h=function(r,n){var o=r.as,i=m(r,b);return e.createElement(t.Element,j({as:f[o]||a.InputField},i,{isFullWidth:!0,onChange:n}))};exports.generateFormThroughConfig=function(t,o,a){var i=[];for(var l in t){var u=t[l],p=u.desktopSpan,c=u.tabletLandscapeSpan,s=u.tabletPortraitSpan,d=u.mobileSpan,b=u.isHorizontal,f=m(u,S),g={desktopSpan:p,tabletLandscapeSpan:c,tabletPortraitSpan:s,mobileSpan:d,isHorizontal:b};i.push(e.createElement(n.Portion,j({},g,{key:"fields-".concat(l)}),h(f,o)))}return e.createElement(r.Row,{layout:"grid",gutters:a},i)};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../../Element/Element.cjs"),r=require("../../Row/Row.cjs"),n=require("../../Portion/Portion.cjs"),o=require("../InputLabel/InputLabel.cjs"),a=require("../InputField/InputField.cjs"),i=require("../InputField/FileUpload.cjs"),l=require("../Checkbox/Checkbox.cjs"),u=require("../Checkbox/Switch.cjs"),p=require("../RadioButton/RadioButton.cjs"),c=require("../RadioButton/RadioGroup.cjs"),s=require("../Select/Select.cjs"),d=require("../TextArea/TextArea.cjs");require("../BaseInputComponent/BaseInputComponent.cjs"),require("../FormItem/FormItem.cjs");var b=["as"],S=["desktopSpan","tabletLandscapeSpan","tabletPortraitSpan","mobileSpan","isHorizontal"];function j(){return j=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},j.apply(this,arguments)}function m(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var f={Checkbox:l.Checkbox,Switch:u.Switch,InputField:a.InputField,FileUpload:i.FileUpload,InputLabel:o.InputLabel,RadioButton:p.RadioButton,RadioGroup:c.RadioGroup,Select:s.Select,TextArea:d.TextArea,Empty:"div"},h=function(r,n){var o=r.as,i=m(r,b);return e.createElement(t.Element,j({as:f[o]||a.InputField},i,{isFullWidth:!0,onChange:n}))};exports.generateFormThroughConfig=function(t,o,a){var i=[];for(var l in t){var u=t[l],p=u.desktopSpan,c=u.tabletLandscapeSpan,s=u.tabletPortraitSpan,d=u.mobileSpan,b=u.isHorizontal,f=m(u,S),g={desktopSpan:p,tabletLandscapeSpan:c,tabletPortraitSpan:s,mobileSpan:d,isHorizontal:b};i.push(e.createElement(n.Portion,j({},g,{key:"fields-".concat(l)}),h(f,o)))}return e.createElement(r.Row,{layout:"grid",gutters:a},i)};
@@ -5,24 +5,24 @@ import { Portion as r } from "../../Portion/Portion.js";
5
5
  import { InputLabel as n } from "../InputLabel/InputLabel.js";
6
6
  import { InputField as a } from "../InputField/InputField.js";
7
7
  import { FileUpload as i } from "../InputField/FileUpload.js";
8
- import { CheckBox as p } from "../CheckBox/CheckBox.js";
9
- import { Switch as l } from "../CheckBox/Switch.js";
8
+ import { Checkbox as p } from "../Checkbox/Checkbox.js";
9
+ import { Switch as l } from "../Checkbox/Switch.js";
10
10
  import { RadioButton as m } from "../RadioButton/RadioButton.js";
11
11
  import { RadioGroup as s } from "../RadioButton/RadioGroup.js";
12
12
  import { Select as u } from "../Select/Select.js";
13
13
  import { TextArea as c } from "../TextArea/TextArea.js";
14
14
  import "../BaseInputComponent/BaseInputComponent.js";
15
15
  import "../FormItem/FormItem.js";
16
- var f = ["as"], d = ["desktopSpan", "tabletLandscapeSpan", "tabletPortraitSpan", "mobileSpan", "isHorizontal"];
17
- function b() {
18
- return b = Object.assign ? Object.assign.bind() : function(t2) {
16
+ var f = ["as"], b = ["desktopSpan", "tabletLandscapeSpan", "tabletPortraitSpan", "mobileSpan", "isHorizontal"];
17
+ function d() {
18
+ return d = Object.assign ? Object.assign.bind() : function(t2) {
19
19
  for (var e2 = 1; e2 < arguments.length; e2++) {
20
20
  var o2 = arguments[e2];
21
21
  for (var r2 in o2)
22
22
  Object.prototype.hasOwnProperty.call(o2, r2) && (t2[r2] = o2[r2]);
23
23
  }
24
24
  return t2;
25
- }, b.apply(this, arguments);
25
+ }, d.apply(this, arguments);
26
26
  }
27
27
  function j(t2, e2) {
28
28
  if (null == t2)
@@ -42,14 +42,14 @@ function j(t2, e2) {
42
42
  }
43
43
  return n2;
44
44
  }
45
- var S = { CheckBox: p, Switch: l, InputField: a, FileUpload: i, InputLabel: n, RadioButton: m, RadioGroup: s, Select: u, TextArea: c, Empty: "div" }, h = function(o2, r2) {
45
+ var S = { Checkbox: p, Switch: l, InputField: a, FileUpload: i, InputLabel: n, RadioButton: m, RadioGroup: s, Select: u, TextArea: c, Empty: "div" }, h = function(o2, r2) {
46
46
  var n2 = o2.as, i2 = j(o2, f);
47
- return t.createElement(e, b({ as: S[n2] || a }, i2, { isFullWidth: true, onChange: r2 }));
47
+ return t.createElement(e, d({ as: S[n2] || a }, i2, { isFullWidth: true, onChange: r2 }));
48
48
  }, v = function(e2, n2, a2) {
49
49
  var i2 = [];
50
50
  for (var p2 in e2) {
51
- var l2 = e2[p2], m2 = l2.desktopSpan, s2 = l2.tabletLandscapeSpan, u2 = l2.tabletPortraitSpan, c2 = l2.mobileSpan, f2 = l2.isHorizontal, S2 = j(l2, d), v2 = { desktopSpan: m2, tabletLandscapeSpan: s2, tabletPortraitSpan: u2, mobileSpan: c2, isHorizontal: f2 };
52
- i2.push(/* @__PURE__ */ t.createElement(r, b({}, v2, { key: "fields-".concat(p2) }), h(S2, n2)));
51
+ var l2 = e2[p2], m2 = l2.desktopSpan, s2 = l2.tabletLandscapeSpan, u2 = l2.tabletPortraitSpan, c2 = l2.mobileSpan, f2 = l2.isHorizontal, S2 = j(l2, b), v2 = { desktopSpan: m2, tabletLandscapeSpan: s2, tabletPortraitSpan: u2, mobileSpan: c2, isHorizontal: f2 };
52
+ i2.push(/* @__PURE__ */ t.createElement(r, d({}, v2, { key: "fields-".concat(p2) }), h(S2, n2)));
53
53
  }
54
54
  return t.createElement(o, { layout: "grid", gutters: a2 }, i2);
55
55
  };
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
- import { CommonAndHTMLProps } from "../../Element/constants";
2
+ import { CommonAndHTMLProps, SpacingTypes } from "../../Element/constants";
3
3
  export interface FormItemGroupCustomProps {
4
4
  isJoint?: boolean;
5
5
  retainLayout?: boolean;
6
- spacing?: string;
6
+ spacing?: SpacingTypes;
7
7
  }
8
8
  export type FormItemGroupElementType = HTMLDivElement;
9
9
  export type FormItemGroupProps = Omit<CommonAndHTMLProps<FormItemGroupElementType>, keyof FormItemGroupCustomProps> & FormItemGroupCustomProps;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../BaseInputComponent/BaseInputComponent.cjs");function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},r.apply(this,arguments)}require("../../Element/Element.cjs"),require("../InputLabel/InputLabel.cjs"),require("../FormItem/FormItem.cjs");var n=e.forwardRef((function(n,o){var u=r({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(n),n));return e.createElement(t.BaseInputComponent,r({as:"input","data-input":!0,ref:o,placeholder:" "},u))}));exports.InputField=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../BaseInputComponent/BaseInputComponent.cjs");function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},r.apply(this,arguments)}require("../../Element/Element.cjs"),require("../InputLabel/InputLabel.cjs"),require("../FormItem/FormItem.cjs");var n=e.forwardRef((function(n,o){var u=r({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(n),n));return e.createElement(t.BaseInputComponent,r({as:"input","data-input-field":!0,ref:o,placeholder:" "},u))}));exports.InputField=n;
@@ -18,7 +18,7 @@ var n = /* @__PURE__ */ t.forwardRef(function(n2, o) {
18
18
  if (null == t2)
19
19
  throw new TypeError("Cannot destructure " + t2);
20
20
  }(n2), n2));
21
- return t.createElement(r, e({ as: "input", "data-input": true, ref: o, placeholder: " " }, a));
21
+ return t.createElement(r, e({ as: "input", "data-input-field": true, ref: o, placeholder: " " }, a));
22
22
  });
23
23
  export {
24
24
  n as InputField
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../../Row/Row.cjs"),r=require("../InputField/InputField.cjs");function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}require("../../Element/Element.cjs"),require("../BaseInputComponent/BaseInputComponent.cjs"),require("../InputLabel/InputLabel.cjs"),require("../FormItem/FormItem.cjs");var o=["numberOfFields","onChange","type","mask","isOTP","autoFocus","pasteFromClipboard","spacing","focusFirstInputOnReset"];function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},u.apply(this,arguments)}function i(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||s(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(e,t,r){var o;return o=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,"string");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(t),(t="symbol"==n(o)?o:String(o))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,u,i,l=[],a=!0,c=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=u.call(r)).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(f){c=!0,o=f}finally{try{if(!a&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,t)||s(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function y(e,t){return("alphanumeric"===t?/^[a-zA-Z0-9]+$/i:/^[0-9]+$/).test(e)}var b=e.forwardRef((function(n,l){var c=n.numberOfFields,s=n.onChange,p=n.type,b=void 0===p?"number":p,m=n.mask,v=void 0!==m&&m,d=n.isOTP,g=void 0!==d&&d,h=n.autoFocus,O=void 0!==h&&h,j=n.pasteFromClipboard,S=void 0===j?"enabled":j,w=n.spacing,A=void 0===w?"small":w,I=n.focusFirstInputOnReset,P=void 0===I||I,F=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},u=Object.keys(e);for(n=0;n<u.length;n++)r=u[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n<u.length;n++)r=u[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(n,o),k=e.useRef(null),C=f(e.useState([]),2),E=C[0],R=C[1],x=f(e.useState([]),2),T=x[0],q=x[1],D=f(e.useState(!0),2),B=D[0],L=D[1],M=f(e.useState(-1),2),$=M[0],z=M[1],H=e.useCallback((function(e){var t,r=E[e];null==r||null===(t=r.current)||void 0===t||t.focus()}),[E]);e.useEffect((function(){R((function(t){return Array(c).fill(0).map((function(r,n){var o,u=t[n]||e.createRef();return O&&0===n&&(null===(o=u.current)||void 0===o||o.focus()),u}))}))}),[c,O]),e.useImperativeHandle(l,(function(){return a(a({},k.current),{},{reset:function(){U()}})}),[E]);var K=e.useCallback((function(e){if(B){var t=e+1<c?e+1:null;t&&H(t)}}),[H,c,B]),U=e.useCallback((function(){q(Array(c).fill("")),null==s||s(""),P&&(H(0),z(0))}),[c,s,H,P]),Z=e.useCallback((function(e,t){var r=i(T);r[t]=e,q(r),null==s||s(r.join("")),""!==e&&r.length===c&&r.every((function(e){return null!=e&&""!==e}))&&t==c-1||(L(!0),K(t))}),[K,c,s,T]),G=function(){z(-1)};return e.createElement(t.Row,u({layout:"flexbox","data-pin-input-field":!0,gutters:A,ref:k},F),i(Array(c)).map((function(t,n){return e.createElement(r.InputField,{key:n,ref:E[n],type:v?"password":"number"===b?"tel":"text",inputMode:"number"===b?"numeric":"text",onChange:function(e){return function(e,t){var r=e.currentTarget.value,n=T[t];if(""!==r)if(r.length>1&&t<c-1){if(y(r,b)){var o=[];o=""==n?r.split("").filter((function(e,r){return t+r<c})):e.currentTarget.selectionEnd===r.length?r.split("").filter((function(e,r){return r>0&&t+r-1<c})):r.split("").filter((function(e,n){return n<r.length-1&&t+n<c})),q((function(e){return e.map((function(e,r){return r>=t&&r<t+o.length?o[r-t]:e}))})),H(t+o.length<c?t+o.length:c-1),null==s||s(o.join(""))}}else{var u=r;(null==n?void 0:n.length)>0&&(n[0]===r.charAt(0)?u=r.charAt(1):n[0]===r.charAt(1)&&(u=r.charAt(0))),y(u,b)&&Z(u,t)}else Z("",t)}(e,n)},onKeyDown:function(e){return function(e,t){if("Backspace"===e.key)if(""===e.target.value){if(t>0){var r=t-1;Z("",r),H(r),L(!0)}}else L(!1);else if("Escape"===e.key){var n;null===(n=E[t].current)||void 0===n||n.blur(),G()}else"ArrowRight"===e.key?t<c-1&&H(t+1):"ArrowLeft"===e.key&&t>0&&H(t-1)}(e,n)},onFocus:function(e){z(n)},onSelect:function(e){return t=e.target,void setTimeout((function(){t.setSelectionRange(t.value.length,t.value.length)}),0);var t},onBlur:G,placeholder:$!==n?"⦁":void 0,autoComplete:g?"one-time-code":"off",value:T[n]||"",autoFocus:O&&0===n,onCopy:function(e){return"disabled"===S&&e.preventDefault()},onPaste:function(e){return"disabled"===S&&e.preventDefault()}})})))}));exports.PinInputField=b;
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import { CommonAndHTMLProps, SpacingTypes } from "../../Element/constants";
3
+ type PinInputFieldCustomProps = {
4
+ numberOfFields: number;
5
+ onChange?: (value: string) => void;
6
+ type?: "alphanumeric" | "number";
7
+ mask?: boolean;
8
+ isOTP?: boolean;
9
+ autoFocus?: boolean;
10
+ pasteFromClipboard?: "enabled" | "disabled";
11
+ spacing?: SpacingTypes;
12
+ focusFirstInputOnReset?: boolean;
13
+ };
14
+ export type PinInputFieldElementType = HTMLDivElement & {
15
+ reset: () => void;
16
+ };
17
+ export type PinInputFieldProps = Omit<CommonAndHTMLProps<PinInputFieldElementType>, keyof PinInputFieldCustomProps> & PinInputFieldCustomProps;
18
+ export declare const PinInputField: React.ForwardRefExoticComponent<Omit<CommonAndHTMLProps<PinInputFieldElementType>, keyof PinInputFieldCustomProps> & PinInputFieldCustomProps & React.RefAttributes<PinInputFieldElementType>>;
19
+ export {};
@@ -0,0 +1,237 @@
1
+ import t, { useRef as e, useState as r, useCallback as n, useEffect as o, createRef as i, useImperativeHandle as u } from "react";
2
+ import { Row as l } from "../../Row/Row.js";
3
+ import { InputField as a } from "../InputField/InputField.js";
4
+ import "../../Element/Element.js";
5
+ import "../BaseInputComponent/BaseInputComponent.js";
6
+ import "../InputLabel/InputLabel.js";
7
+ import "../FormItem/FormItem.js";
8
+ function c(t2) {
9
+ return (c = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t3) {
10
+ return typeof t3;
11
+ } : function(t3) {
12
+ return t3 && "function" == typeof Symbol && t3.constructor === Symbol && t3 !== Symbol.prototype ? "symbol" : typeof t3;
13
+ })(t2);
14
+ }
15
+ var f = ["numberOfFields", "onChange", "type", "mask", "isOTP", "autoFocus", "pasteFromClipboard", "spacing", "focusFirstInputOnReset"];
16
+ function s() {
17
+ return s = Object.assign ? Object.assign.bind() : function(t2) {
18
+ for (var e2 = 1; e2 < arguments.length; e2++) {
19
+ var r2 = arguments[e2];
20
+ for (var n2 in r2)
21
+ Object.prototype.hasOwnProperty.call(r2, n2) && (t2[n2] = r2[n2]);
22
+ }
23
+ return t2;
24
+ }, s.apply(this, arguments);
25
+ }
26
+ function p(t2) {
27
+ return function(t3) {
28
+ if (Array.isArray(t3))
29
+ return g(t3);
30
+ }(t2) || function(t3) {
31
+ if ("undefined" != typeof Symbol && null != t3[Symbol.iterator] || null != t3["@@iterator"])
32
+ return Array.from(t3);
33
+ }(t2) || d(t2) || function() {
34
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35
+ }();
36
+ }
37
+ function y(t2, e2) {
38
+ var r2 = Object.keys(t2);
39
+ if (Object.getOwnPropertySymbols) {
40
+ var n2 = Object.getOwnPropertySymbols(t2);
41
+ e2 && (n2 = n2.filter(function(e3) {
42
+ return Object.getOwnPropertyDescriptor(t2, e3).enumerable;
43
+ })), r2.push.apply(r2, n2);
44
+ }
45
+ return r2;
46
+ }
47
+ function m(t2) {
48
+ for (var e2 = 1; e2 < arguments.length; e2++) {
49
+ var r2 = null != arguments[e2] ? arguments[e2] : {};
50
+ e2 % 2 ? y(Object(r2), true).forEach(function(e3) {
51
+ b(t2, e3, r2[e3]);
52
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t2, Object.getOwnPropertyDescriptors(r2)) : y(Object(r2)).forEach(function(e3) {
53
+ Object.defineProperty(t2, e3, Object.getOwnPropertyDescriptor(r2, e3));
54
+ });
55
+ }
56
+ return t2;
57
+ }
58
+ function b(t2, e2, r2) {
59
+ var n2;
60
+ return n2 = function(t3, e3) {
61
+ if ("object" != c(t3) || !t3)
62
+ return t3;
63
+ var r3 = t3[Symbol.toPrimitive];
64
+ if (void 0 !== r3) {
65
+ var n3 = r3.call(t3, e3 || "default");
66
+ if ("object" != c(n3))
67
+ return n3;
68
+ throw new TypeError("@@toPrimitive must return a primitive value.");
69
+ }
70
+ return ("string" === e3 ? String : Number)(t3);
71
+ }(e2, "string"), (e2 = "symbol" == c(n2) ? n2 : String(n2)) in t2 ? Object.defineProperty(t2, e2, { value: r2, enumerable: true, configurable: true, writable: true }) : t2[e2] = r2, t2;
72
+ }
73
+ function v(t2, e2) {
74
+ return function(t3) {
75
+ if (Array.isArray(t3))
76
+ return t3;
77
+ }(t2) || function(t3, e3) {
78
+ var r2 = null == t3 ? null : "undefined" != typeof Symbol && t3[Symbol.iterator] || t3["@@iterator"];
79
+ if (null != r2) {
80
+ var n2, o2, i2, u2, l2 = [], a2 = true, c2 = false;
81
+ try {
82
+ if (i2 = (r2 = r2.call(t3)).next, 0 === e3) {
83
+ if (Object(r2) !== r2)
84
+ return;
85
+ a2 = false;
86
+ } else
87
+ for (; !(a2 = (n2 = i2.call(r2)).done) && (l2.push(n2.value), l2.length !== e3); a2 = true)
88
+ ;
89
+ } catch (t4) {
90
+ c2 = true, o2 = t4;
91
+ } finally {
92
+ try {
93
+ if (!a2 && null != r2.return && (u2 = r2.return(), Object(u2) !== u2))
94
+ return;
95
+ } finally {
96
+ if (c2)
97
+ throw o2;
98
+ }
99
+ }
100
+ return l2;
101
+ }
102
+ }(t2, e2) || d(t2, e2) || function() {
103
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
104
+ }();
105
+ }
106
+ function d(t2, e2) {
107
+ if (t2) {
108
+ if ("string" == typeof t2)
109
+ return g(t2, e2);
110
+ var r2 = Object.prototype.toString.call(t2).slice(8, -1);
111
+ return "Object" === r2 && t2.constructor && (r2 = t2.constructor.name), "Map" === r2 || "Set" === r2 ? Array.from(t2) : "Arguments" === r2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r2) ? g(t2, e2) : void 0;
112
+ }
113
+ }
114
+ function g(t2, e2) {
115
+ (null == e2 || e2 > t2.length) && (e2 = t2.length);
116
+ for (var r2 = 0, n2 = new Array(e2); r2 < e2; r2++)
117
+ n2[r2] = t2[r2];
118
+ return n2;
119
+ }
120
+ function h(t2, e2) {
121
+ if (null == t2)
122
+ return {};
123
+ var r2, n2, o2 = function(t3, e3) {
124
+ if (null == t3)
125
+ return {};
126
+ var r3, n3, o3 = {}, i3 = Object.keys(t3);
127
+ for (n3 = 0; n3 < i3.length; n3++)
128
+ r3 = i3[n3], e3.indexOf(r3) >= 0 || (o3[r3] = t3[r3]);
129
+ return o3;
130
+ }(t2, e2);
131
+ if (Object.getOwnPropertySymbols) {
132
+ var i2 = Object.getOwnPropertySymbols(t2);
133
+ for (n2 = 0; n2 < i2.length; n2++)
134
+ r2 = i2[n2], e2.indexOf(r2) >= 0 || Object.prototype.propertyIsEnumerable.call(t2, r2) && (o2[r2] = t2[r2]);
135
+ }
136
+ return o2;
137
+ }
138
+ function O(t2, e2) {
139
+ return ("alphanumeric" === e2 ? /^[a-zA-Z0-9]+$/i : /^[0-9]+$/).test(t2);
140
+ }
141
+ var j = /* @__PURE__ */ t.forwardRef(function(c2, y2) {
142
+ var b2 = c2.numberOfFields, d2 = c2.onChange, g2 = c2.type, j2 = void 0 === g2 ? "number" : g2, w = c2.mask, S = void 0 !== w && w, A = c2.isOTP, P = void 0 !== A && A, I = c2.autoFocus, F = void 0 !== I && I, E = c2.pasteFromClipboard, k = void 0 === E ? "enabled" : E, C = c2.spacing, x = void 0 === C ? "small" : C, T = c2.focusFirstInputOnReset, D = void 0 === T || T, R = h(c2, f), B = e(null), L = v(r([]), 2), $ = L[0], M = L[1], z = v(r([]), 2), K = z[0], N = z[1], U = v(r(true), 2), Z = U[0], q = U[1], G = v(r(-1), 2), H = G[0], J = G[1], Q = n(function(t2) {
143
+ var e2, r2 = $[t2];
144
+ null == r2 || null === (e2 = r2.current) || void 0 === e2 || e2.focus();
145
+ }, [$]);
146
+ o(function() {
147
+ M(function(t2) {
148
+ return Array(b2).fill(0).map(function(e2, r2) {
149
+ var n2, o2 = t2[r2] || /* @__PURE__ */ i();
150
+ F && 0 === r2 && (null === (n2 = o2.current) || void 0 === n2 || n2.focus());
151
+ return o2;
152
+ });
153
+ });
154
+ }, [b2, F]), u(y2, function() {
155
+ return m(m({}, B.current), {}, { reset: function() {
156
+ W();
157
+ } });
158
+ }, [$]);
159
+ var V = n(function(t2) {
160
+ if (Z) {
161
+ var e2 = t2 + 1 < b2 ? t2 + 1 : null;
162
+ e2 && Q(e2);
163
+ }
164
+ }, [Q, b2, Z]), W = n(function() {
165
+ N(Array(b2).fill("")), null == d2 || d2(""), D && (Q(0), J(0));
166
+ }, [b2, d2, Q, D]), X = n(function(t2, e2) {
167
+ var r2 = p(K);
168
+ r2[e2] = t2, N(r2), null == d2 || d2(r2.join("")), "" !== t2 && r2.length === b2 && r2.every(function(t3) {
169
+ return null != t3 && "" !== t3;
170
+ }) && e2 == b2 - 1 || (q(true), V(e2));
171
+ }, [V, b2, d2, K]), Y = function() {
172
+ J(-1);
173
+ };
174
+ return t.createElement(l, s({ layout: "flexbox", "data-pin-input-field": true, gutters: x, ref: B }, R), p(Array(b2)).map(function(e2, r2) {
175
+ return t.createElement(a, { key: r2, ref: $[r2], type: S ? "password" : "number" === j2 ? "tel" : "text", inputMode: "number" === j2 ? "numeric" : "text", onChange: function(t2) {
176
+ return function(t3, e3) {
177
+ var r3 = t3.currentTarget.value, n2 = K[e3];
178
+ if ("" !== r3)
179
+ if (r3.length > 1 && e3 < b2 - 1) {
180
+ if (O(r3, j2)) {
181
+ var o2 = [];
182
+ o2 = "" == n2 ? r3.split("").filter(function(t4, r4) {
183
+ return e3 + r4 < b2;
184
+ }) : t3.currentTarget.selectionEnd === r3.length ? r3.split("").filter(function(t4, r4) {
185
+ return r4 > 0 && e3 + r4 - 1 < b2;
186
+ }) : r3.split("").filter(function(t4, n3) {
187
+ return n3 < r3.length - 1 && e3 + n3 < b2;
188
+ }), N(function(t4) {
189
+ return t4.map(function(t5, r4) {
190
+ return r4 >= e3 && r4 < e3 + o2.length ? o2[r4 - e3] : t5;
191
+ });
192
+ }), Q(e3 + o2.length < b2 ? e3 + o2.length : b2 - 1), null == d2 || d2(o2.join(""));
193
+ }
194
+ } else {
195
+ var i2 = r3;
196
+ (null == n2 ? void 0 : n2.length) > 0 && (n2[0] === r3.charAt(0) ? i2 = r3.charAt(1) : n2[0] === r3.charAt(1) && (i2 = r3.charAt(0))), O(i2, j2) && X(i2, e3);
197
+ }
198
+ else
199
+ X("", e3);
200
+ }(t2, r2);
201
+ }, onKeyDown: function(t2) {
202
+ return function(t3, e3) {
203
+ if ("Backspace" === t3.key)
204
+ if ("" === t3.target.value) {
205
+ if (e3 > 0) {
206
+ var r3 = e3 - 1;
207
+ X("", r3), Q(r3), q(true);
208
+ }
209
+ } else
210
+ q(false);
211
+ else if ("Escape" === t3.key) {
212
+ var n2;
213
+ null === (n2 = $[e3].current) || void 0 === n2 || n2.blur(), Y();
214
+ } else
215
+ "ArrowRight" === t3.key ? e3 < b2 - 1 && Q(e3 + 1) : "ArrowLeft" === t3.key && e3 > 0 && Q(e3 - 1);
216
+ }(t2, r2);
217
+ }, onFocus: function(t2) {
218
+ return function(t3, e3) {
219
+ J(e3);
220
+ }(0, r2);
221
+ }, onSelect: function(t2) {
222
+ return function(t3) {
223
+ var e3 = t3.target;
224
+ setTimeout(function() {
225
+ e3.setSelectionRange(e3.value.length, e3.value.length);
226
+ }, 0);
227
+ }(t2);
228
+ }, onBlur: Y, placeholder: H !== r2 ? "⦁" : void 0, autoComplete: P ? "one-time-code" : "off", value: K[r2] || "", autoFocus: F && 0 === r2, onCopy: function(t2) {
229
+ return "disabled" === k && t2.preventDefault();
230
+ }, onPaste: function(t2) {
231
+ return "disabled" === k && t2.preventDefault();
232
+ } });
233
+ }));
234
+ });
235
+ export {
236
+ j as PinInputField
237
+ };
@@ -0,0 +1,6 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { PinInputField } from "./PinInputField";
3
+ declare const meta: Meta<typeof PinInputField>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof PinInputField>;
6
+ export declare const Default: Story;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PinInputField.cjs");require("react"),require("../../Row/Row.cjs"),require("../../Element/Element.cjs"),require("../InputField/InputField.cjs"),require("../BaseInputComponent/BaseInputComponent.cjs"),require("../InputLabel/InputLabel.cjs"),require("../FormItem/FormItem.cjs"),exports.PinInputField=e.PinInputField;
@@ -0,0 +1 @@
1
+ export { PinInputField, type PinInputFieldProps, type PinInputFieldElementType } from "./PinInputField";
@@ -0,0 +1,11 @@
1
+ import { PinInputField } from "./PinInputField.js";
2
+ import "react";
3
+ import "../../Row/Row.js";
4
+ import "../../Element/Element.js";
5
+ import "../InputField/InputField.js";
6
+ import "../BaseInputComponent/BaseInputComponent.js";
7
+ import "../InputLabel/InputLabel.js";
8
+ import "../FormItem/FormItem.js";
9
+ export {
10
+ PinInputField
11
+ };