@pickaxeproject/react 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Pickaxe/Form/Questions/Option.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/index.js +1 -1
- package/dist/cjs/src/types/form.d.ts +2 -0
- package/dist/esm/components/Pickaxe/Form/Questions/Option.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/index.js +1 -1
- package/dist/esm/src/types/form.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/studio/useStyleFontSize.js"),i=require("react"),r=require("./Dropdown.js"),a=require("../../../../common/cn.js");exports.default=({field:c,update:l})=>{const{colors:o,isRtl:u,translations:d}=s.usePickaxeContext(),{setError:p}=t.useResponseContext(),x=n.useStyleFontSize(),j=i.useRef(null),b=i.useMemo((()=>c.example.split("S3P32X")),[c.example]),[g,m]=i.useState((()=>{const e=b.includes(c.input);return c.allowOther&&c.input&&!e?c.input:""})),f=i.useMemo((()=>!!c.allowOther&&(!b.includes(c.input)&&""!==c.input)),[c.allowOther,c.input,b]);return e.jsxs("div",Object.assign({className:"flex flex-col gap-y-3",dir:u?"rtl":"ltr"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[e.jsx("p",Object.assign({className:a.default(x.b3,"font-semibold opacity-70")},{children:c.main})),c.isRequired&&e.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:o.error}},{children:"*"}))]})),e.jsx(r.default,Object.assign({id:c.id.replace(/[^A-Za-z]+/g,""),value:c.input,placeholder:"Select an option",closeOnSelect:!1,maxToken:c.maxLength,isDropdown:c.isDropdown},{children:e.jsxs("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:[b.map(((s,t)=>e.jsxs("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{p(""),l(Object.assign(Object.assign({},c),{input:e}))})(s)},{children:[e.jsx("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2",style:Object.assign({borderColor:c.input===s?o.accent:o.accent+"80"},c.input===s&&{backgroundColor:o.accent})},{children:e.jsx("div",{className:a.default("h-2 w-2 shrink-0 transition-opacity opacity-0 ease-in-out duration-200 rounded-full",c.input===s&&"opacity-100"),style:{backgroundColor:o.accentText}})})),e.jsx("p",Object.assign({className:a.default(x.b2,"select-none")},{children:s}))]}),t))),c.allowOther&&e.jsxs("div",Object.assign({className:"flex w-full items-center gap-x-3 hover:cursor-pointer",onClick:()=>{p(""),l(Object.assign(Object.assign({},c),{input:g})),setTimeout((()=>{var e;return null===(e=j.current)||void 0===e?void 0:e.focus()}),0)}},{children:[e.jsx("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2",style:Object.assign({borderColor:f?o.accent:o.accent+"80"},f&&{backgroundColor:o.accent})},{children:e.jsx("div",{className:a.default("h-2 w-2 shrink-0 transition-opacity opacity-0 ease-in-out duration-200 rounded-full",f&&"opacity-100"),style:{backgroundColor:o.accentText}})})),e.jsxs("div",Object.assign({className:"flex flex-1 items-center gap-2"},{children:[e.jsxs("p",Object.assign({className:a.default(x.b2,"select-none opacity-80 min-w-fit")},{children:[(null==d?void 0:d.other)||"Other",":"]})),e.jsx("input",{ref:j,type:"text",className:a.default(x.b2,"flex-1 bg-transparent border-b outline-none w-full pb-0.5 transition-colors duration-200","cursor-text"),style:{borderColor:f?o.accent:"rgba(0,0,0,0.2)"},value:g,onChange:e=>{return s=e.target.value,p(""),m(s),void l(Object.assign(Object.assign({},c),{input:s}));var s},onFocus:()=>{f||l(Object.assign(Object.assign({},c),{input:g}))},placeholder:"Type your answer..."})]}))]}))]}))}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../Core/ErrorAlert.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../Core/ErrorAlert.js"),a=require("../../common/PickaxeUpgradeCard.js"),o=require("./Input.js"),u=require("./Option.js"),n=require("./Document.js"),l=require("./Checkbox.js"),d=require("./Submit.js");exports.default=()=>{const{pickaxe:p,translations:c}=r.usePickaxeContext(),{error:x}=s.useResponseContext(),[m,f]=t.useState([]),[j,h]=t.useState([]),g=e=>{f((t=>t.map((t=>t.id===e.id?e:t))))},q=t.useMemo((()=>j),[j]);return t.useEffect((()=>{if(!p)return;if(!p._questions)return;const e=new Date("2025-10-16T23:10:00Z"),t=!p.updatedAt||new Date(p.updatedAt)<e,r=p._questions.map(((e,r)=>{var s;let i="";const a="string"==typeof e.allowOther?"true"===e.allowOther:!!e.allowOther;if("Knowledge Upload"===e.type||"userinput:documentupload"===e.id)i="";else if("Multiple Choice"===e.type||"multiple"===e.type){const t=e.example.split("S3P32X");t.includes(i)||a||(i=t[0])}let o=e.secondary||"";return t&&(o=e.secondary||("Knowledge Upload"===e.type?null!==(s=null==c?void 0:c["form-doc-placeholder"])&&void 0!==s?s:"Paste a website/video link or drag a file":e.example)||""),Object.assign(Object.assign({order:r+1,id:e.id,type:e.type,main:e.main,example:e.example,input:i,length:0,maxLength:parseInt(e.answerlength),placeholder:o,allowOther:a},e.isRequired&&{isRequired:"string"==typeof e.isRequired?"true"===e.isRequired:e.isRequired}),e.isDropdown&&{isDropdown:"string"==typeof e.isDropdown?"true"===e.isDropdown:e.isDropdown})}));f(r),h(r)}),[p]),e.jsxs("div",Object.assign({className:"mt-8 flex flex-col gap-y-8 max-lg:px-4"},{children:[m.map(((r,s)=>"Multiple Choice"===r.type?e.jsx(t.Fragment,{children:e.jsx(u.default,{field:r,update:g})},s):"Checkbox"===r.type?e.jsx(t.Fragment,{children:e.jsx(l.default,{field:r,update:g})},s):"userinput:documentupload"===r.id?e.jsx(t.Fragment,{children:e.jsx(n.default,{field:r,update:g})},s):e.jsx(t.Fragment,{children:e.jsx(o.default,{field:r,update:g})},s))),e.jsx(i.default,{error:x}),e.jsx(a.default,{}),e.jsx(d.default,{questions:m,update:g,resetQuestions:()=>f(q)})]}))};
|
|
@@ -8,6 +8,7 @@ export type PickaxeQuestion = {
|
|
|
8
8
|
type: PickaxeQuestionType;
|
|
9
9
|
isRequired?: boolean;
|
|
10
10
|
isDropdown?: boolean;
|
|
11
|
+
allowOther?: boolean;
|
|
11
12
|
};
|
|
12
13
|
export type MemoryStoredQuestionField = {
|
|
13
14
|
order: number;
|
|
@@ -22,4 +23,5 @@ export type MemoryStoredQuestionField = {
|
|
|
22
23
|
documentId?: string;
|
|
23
24
|
isRequired?: boolean;
|
|
24
25
|
isDropdown?: boolean;
|
|
26
|
+
allowOther?: boolean;
|
|
25
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{usePickaxeContext as s}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import{useRef as r,useMemo as o,useState as a}from"react";import c from"./Dropdown.js";import l from"../../../../common/cn.js";const p=({field:p,update:d})=>{const{colors:u,isRtl:m,translations:b}=s(),{setError:g}=n(),h=i(),f=r(null),x=o((()=>p.example.split("S3P32X")),[p.example]),[j,O]=a((()=>{const e=x.includes(p.input);return p.allowOther&&p.input&&!e?p.input:""})),y=o((()=>!!p.allowOther&&(!x.includes(p.input)&&""!==p.input)),[p.allowOther,p.input,x]);return e("div",Object.assign({className:"flex flex-col gap-y-3",dir:m?"rtl":"ltr"},{children:[e("div",Object.assign({className:"flex items-center gap-1"},{children:[t("p",Object.assign({className:l(h.b3,"font-semibold opacity-70")},{children:p.main})),p.isRequired&&t("span",Object.assign({className:"select-none font-semibold",style:{color:u.error}},{children:"*"}))]})),t(c,Object.assign({id:p.id.replace(/[^A-Za-z]+/g,""),value:p.input,placeholder:"Select an option",closeOnSelect:!1,maxToken:p.maxLength,isDropdown:p.isDropdown},{children:e("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:[x.map(((s,n)=>e("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{g(""),d(Object.assign(Object.assign({},p),{input:e}))})(s)},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2",style:Object.assign({borderColor:p.input===s?u.accent:u.accent+"80"},p.input===s&&{backgroundColor:u.accent})},{children:t("div",{className:l("h-2 w-2 shrink-0 transition-opacity opacity-0 ease-in-out duration-200 rounded-full",p.input===s&&"opacity-100"),style:{backgroundColor:u.accentText}})})),t("p",Object.assign({className:l(h.b2,"select-none")},{children:s}))]}),n))),p.allowOther&&e("div",Object.assign({className:"flex w-full items-center gap-x-3 hover:cursor-pointer",onClick:()=>{g(""),d(Object.assign(Object.assign({},p),{input:j})),setTimeout((()=>{var e;return null===(e=f.current)||void 0===e?void 0:e.focus()}),0)}},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2",style:Object.assign({borderColor:y?u.accent:u.accent+"80"},y&&{backgroundColor:u.accent})},{children:t("div",{className:l("h-2 w-2 shrink-0 transition-opacity opacity-0 ease-in-out duration-200 rounded-full",y&&"opacity-100"),style:{backgroundColor:u.accentText}})})),e("div",Object.assign({className:"flex flex-1 items-center gap-2"},{children:[e("p",Object.assign({className:l(h.b2,"select-none opacity-80 min-w-fit")},{children:[(null==b?void 0:b.other)||"Other",":"]})),t("input",{ref:f,type:"text",className:l(h.b2,"flex-1 bg-transparent border-b outline-none w-full pb-0.5 transition-colors duration-200","cursor-text"),style:{borderColor:y?u.accent:"rgba(0,0,0,0.2)"},value:j,onChange:e=>{return t=e.target.value,g(""),O(t),void d(Object.assign(Object.assign({},p),{input:t}));var t},onFocus:()=>{y||d(Object.assign(Object.assign({},p),{input:j}))},placeholder:"Type your answer..."})]}))]}))]}))}))]}))};export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useMemo as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useMemo as r,useEffect as i,Fragment as p}from"react";import{usePickaxeContext as s}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import a from"../../../Core/ErrorAlert.js";import l from"../../common/PickaxeUpgradeCard.js";import d from"./Input.js";import u from"./Option.js";import m from"./Document.js";import c from"./Checkbox.js";import f from"./Submit.js";const h=()=>{const{pickaxe:h,translations:x}=s(),{error:g}=n(),[w,y]=o([]),[j,k]=o([]),q=e=>{y((t=>t.map((t=>t.id===e.id?e:t))))},C=r((()=>j),[j]);return i((()=>{if(!h)return;if(!h._questions)return;const e=new Date("2025-10-16T23:10:00Z"),t=!h.updatedAt||new Date(h.updatedAt)<e,o=h._questions.map(((e,o)=>{var r;let i="";const p="string"==typeof e.allowOther?"true"===e.allowOther:!!e.allowOther;if("Knowledge Upload"===e.type||"userinput:documentupload"===e.id)i="";else if("Multiple Choice"===e.type||"multiple"===e.type){const t=e.example.split("S3P32X");t.includes(i)||p||(i=t[0])}let s=e.secondary||"";return t&&(s=e.secondary||("Knowledge Upload"===e.type?null!==(r=null==x?void 0:x["form-doc-placeholder"])&&void 0!==r?r:"Paste a website/video link or drag a file":e.example)||""),Object.assign(Object.assign({order:o+1,id:e.id,type:e.type,main:e.main,example:e.example,input:i,length:0,maxLength:parseInt(e.answerlength),placeholder:s,allowOther:p},e.isRequired&&{isRequired:"string"==typeof e.isRequired?"true"===e.isRequired:e.isRequired}),e.isDropdown&&{isDropdown:"string"==typeof e.isDropdown?"true"===e.isDropdown:e.isDropdown})}));y(o),k(o)}),[h]),e("div",Object.assign({className:"mt-8 flex flex-col gap-y-8 max-lg:px-4"},{children:[w.map(((e,o)=>"Multiple Choice"===e.type?t(p,{children:t(u,{field:e,update:q})},o):"Checkbox"===e.type?t(p,{children:t(c,{field:e,update:q})},o):"userinput:documentupload"===e.id?t(p,{children:t(m,{field:e,update:q})},o):t(p,{children:t(d,{field:e,update:q})},o))),t(a,{error:g}),t(l,{}),t(f,{questions:w,update:q,resetQuestions:()=>y(C)})]}))};export{h as default};
|
|
@@ -8,6 +8,7 @@ export type PickaxeQuestion = {
|
|
|
8
8
|
type: PickaxeQuestionType;
|
|
9
9
|
isRequired?: boolean;
|
|
10
10
|
isDropdown?: boolean;
|
|
11
|
+
allowOther?: boolean;
|
|
11
12
|
};
|
|
12
13
|
export type MemoryStoredQuestionField = {
|
|
13
14
|
order: number;
|
|
@@ -22,4 +23,5 @@ export type MemoryStoredQuestionField = {
|
|
|
22
23
|
documentId?: string;
|
|
23
24
|
isRequired?: boolean;
|
|
24
25
|
isDropdown?: boolean;
|
|
26
|
+
allowOther?: boolean;
|
|
25
27
|
};
|