motion-surveyjs-ui 0.1.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.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +87 -0
  3. package/dist/index.cjs +7 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.ts +4 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +1905 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/lib/MotionSurvey.d.ts +25 -0
  10. package/dist/lib/MotionSurvey.d.ts.map +1 -0
  11. package/dist/lib/__tests__/testUtils.d.ts +5 -0
  12. package/dist/lib/__tests__/testUtils.d.ts.map +1 -0
  13. package/dist/lib/elements/getQuestionErrors.d.ts +3 -0
  14. package/dist/lib/elements/getQuestionErrors.d.ts.map +1 -0
  15. package/dist/lib/elements/getQuestionTitle.d.ts +4 -0
  16. package/dist/lib/elements/getQuestionTitle.d.ts.map +1 -0
  17. package/dist/lib/elements/renderElement.d.ts +4 -0
  18. package/dist/lib/elements/renderElement.d.ts.map +1 -0
  19. package/dist/lib/elements/setQuestionValue.d.ts +3 -0
  20. package/dist/lib/elements/setQuestionValue.d.ts.map +1 -0
  21. package/dist/lib/elements/types/BooleanElement.d.ts +7 -0
  22. package/dist/lib/elements/types/BooleanElement.d.ts.map +1 -0
  23. package/dist/lib/elements/types/ButtonGroupElement.d.ts +7 -0
  24. package/dist/lib/elements/types/ButtonGroupElement.d.ts.map +1 -0
  25. package/dist/lib/elements/types/ChoiceElement.d.ts +8 -0
  26. package/dist/lib/elements/types/ChoiceElement.d.ts.map +1 -0
  27. package/dist/lib/elements/types/CommentElement.d.ts +7 -0
  28. package/dist/lib/elements/types/CommentElement.d.ts.map +1 -0
  29. package/dist/lib/elements/types/DropdownElement.d.ts +7 -0
  30. package/dist/lib/elements/types/DropdownElement.d.ts.map +1 -0
  31. package/dist/lib/elements/types/EmptyElement.d.ts +7 -0
  32. package/dist/lib/elements/types/EmptyElement.d.ts.map +1 -0
  33. package/dist/lib/elements/types/ExpressionElement.d.ts +7 -0
  34. package/dist/lib/elements/types/ExpressionElement.d.ts.map +1 -0
  35. package/dist/lib/elements/types/FileElement.d.ts +7 -0
  36. package/dist/lib/elements/types/FileElement.d.ts.map +1 -0
  37. package/dist/lib/elements/types/FlowPanelElement.d.ts +9 -0
  38. package/dist/lib/elements/types/FlowPanelElement.d.ts.map +1 -0
  39. package/dist/lib/elements/types/HtmlElement.d.ts +7 -0
  40. package/dist/lib/elements/types/HtmlElement.d.ts.map +1 -0
  41. package/dist/lib/elements/types/ImageElement.d.ts +7 -0
  42. package/dist/lib/elements/types/ImageElement.d.ts.map +1 -0
  43. package/dist/lib/elements/types/ImagePickerElement.d.ts +7 -0
  44. package/dist/lib/elements/types/ImagePickerElement.d.ts.map +1 -0
  45. package/dist/lib/elements/types/MatrixDropdownElement.d.ts +7 -0
  46. package/dist/lib/elements/types/MatrixDropdownElement.d.ts.map +1 -0
  47. package/dist/lib/elements/types/MatrixDynamicElement.d.ts +7 -0
  48. package/dist/lib/elements/types/MatrixDynamicElement.d.ts.map +1 -0
  49. package/dist/lib/elements/types/MatrixElement.d.ts +7 -0
  50. package/dist/lib/elements/types/MatrixElement.d.ts.map +1 -0
  51. package/dist/lib/elements/types/MultipleTextElement.d.ts +7 -0
  52. package/dist/lib/elements/types/MultipleTextElement.d.ts.map +1 -0
  53. package/dist/lib/elements/types/PanelDynamicElement.d.ts +9 -0
  54. package/dist/lib/elements/types/PanelDynamicElement.d.ts.map +1 -0
  55. package/dist/lib/elements/types/RankingElement.d.ts +7 -0
  56. package/dist/lib/elements/types/RankingElement.d.ts.map +1 -0
  57. package/dist/lib/elements/types/RankingItem.d.ts +15 -0
  58. package/dist/lib/elements/types/RankingItem.d.ts.map +1 -0
  59. package/dist/lib/elements/types/RatingElement.d.ts +7 -0
  60. package/dist/lib/elements/types/RatingElement.d.ts.map +1 -0
  61. package/dist/lib/elements/types/SignaturePadElement.d.ts +7 -0
  62. package/dist/lib/elements/types/SignaturePadElement.d.ts.map +1 -0
  63. package/dist/lib/elements/types/TagboxElement.d.ts +7 -0
  64. package/dist/lib/elements/types/TagboxElement.d.ts.map +1 -0
  65. package/dist/lib/elements/types/TextElement.d.ts +7 -0
  66. package/dist/lib/elements/types/TextElement.d.ts.map +1 -0
  67. package/dist/lib/i18n/messages.d.ts +9 -0
  68. package/dist/lib/i18n/messages.d.ts.map +1 -0
  69. package/dist/lib/ui/BaseElement.d.ts +8 -0
  70. package/dist/lib/ui/BaseElement.d.ts.map +1 -0
  71. package/dist/lib/ui/Checkmark.d.ts +6 -0
  72. package/dist/lib/ui/Checkmark.d.ts.map +1 -0
  73. package/dist/lib/ui/Errors.d.ts +6 -0
  74. package/dist/lib/ui/Errors.d.ts.map +1 -0
  75. package/dist/lib/ui/types.d.ts +18 -0
  76. package/dist/lib/ui/types.d.ts.map +1 -0
  77. package/dist/style.css +1 -0
  78. package/package.json +65 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # motion-surveyjs-ui
2
+
3
+ A modern, TypeScript-first React library for rendering SurveyJS JSON models.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i motion-surveyjs-ui
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Comment question word count:
14
+ - Default max word count is **200**.
15
+ - Override per-question via `maxWordCount` (or `maxWords`) in the Survey JSON.
16
+
17
+
18
+ ```tsx
19
+ import { MotionSurvey } from 'motion-surveyjs-ui'
20
+
21
+ export function App() {
22
+ return (
23
+ <MotionSurvey
24
+ theme="modern"
25
+ animate
26
+ json={{
27
+ title: 'Feedback',
28
+ pages: [
29
+ {
30
+ name: 'page1',
31
+ elements: [{ type: 'text', name: 'name', title: 'Your name' }],
32
+ },
33
+ ],
34
+ }}
35
+ onComplete={(data) => console.log(data)}
36
+ />
37
+ )
38
+ }
39
+ ```
40
+
41
+ - UI primitives: Radix UI
42
+ - Animations/transitions: motion.dev
43
+
44
+ ## Localization
45
+
46
+ All built-in UI strings (buttons, placeholders, counters) can be customized:
47
+
48
+ ```tsx
49
+ <MotionSurvey
50
+ json={...}
51
+ locale="en-US"
52
+ messages={{
53
+ back: '返回',
54
+ next: '下一步',
55
+ complete: '提交',
56
+ selectPlaceholder: '请选择…',
57
+ wordCount: '{count}/{max} 字',
58
+ }}
59
+ />
60
+ ```
61
+
62
+ ## Styling overrides
63
+
64
+ See **[STYLING-CSS-GUIDE.md](./STYLING-CSS-GUIDE.md)** for the full list of supported CSS variables and classnames.
65
+
66
+ Quick example — disable borders on choice options (radio/checkbox items):
67
+
68
+ ```css
69
+ .msj {
70
+ --msj-choice-option-border: none;
71
+ }
72
+ ```
73
+
74
+ > If you prefer explicit CSS loading, you can also import: `motion-surveyjs-ui/styles.css`.
75
+
76
+ ## Development
77
+
78
+ ```bash
79
+ npm install
80
+ npm run dev
81
+ ```
82
+
83
+ ## Build
84
+
85
+ ```bash
86
+ npm run build
87
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),Z=require("survey-core"),x=require("motion/react"),be=require("@radix-ui/react-label"),Ne=require("@radix-ui/react-radio-group"),ke=require("@radix-ui/react-checkbox"),we=require("@radix-ui/react-select");function oe(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const a in n)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(n,a);Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:()=>n[a]})}}return t.default=n,Object.freeze(t)}const he=oe(be),V=oe(Ne),le=oe(ke),M=oe(we);var ie={exports:{}},X={};var xe;function Se(){if(xe)return X;xe=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function a(r,l,o){var c=null;if(o!==void 0&&(c=""+o),l.key!==void 0&&(c=""+l.key),"key"in l){o={};for(var m in l)m!=="key"&&(o[m]=l[m])}else o=l;return l=o.ref,{$$typeof:n,type:r,key:c,ref:l!==void 0?l:null,props:o}}return X.Fragment=t,X.jsx=a,X.jsxs=a,X}var J={};var je;function Re(){return je||(je=1,process.env.NODE_ENV!=="production"&&(function(){function n(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===ce?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case b:return"Fragment";case k:return"Profiler";case y:return"StrictMode";case G:return"Suspense";case I:return"SuspenseList";case Q:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case g:return"Portal";case C:return s.displayName||"Context";case P:return(s._context.displayName||"Context")+".Consumer";case B:var f=s.render;return s=s.displayName,s||(s=f.displayName||f.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case F:return f=s.displayName||null,f!==null?f:n(s.type)||"Memo";case U:f=s._payload,s=s._init;try{return n(s(f))}catch{}}return null}function t(s){return""+s}function a(s){try{t(s);var f=!1}catch{f=!0}if(f){f=console;var p=f.error,N=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return p.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",N),t(s)}}function r(s){if(s===b)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===U)return"<...>";try{var f=n(s);return f?"<"+f+">":"<...>"}catch{return"<...>"}}function l(){var s=W.A;return s===null?null:s.getOwner()}function o(){return Error("react-stack-top-frame")}function c(s){if(ee.call(s,"key")){var f=Object.getOwnPropertyDescriptor(s,"key").get;if(f&&f.isReactWarning)return!1}return s.key!==void 0}function m(s,f){function p(){ne||(ne=!0,console.error("%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://react.dev/link/special-props)",f))}p.isReactWarning=!0,Object.defineProperty(s,"key",{get:p,configurable:!0})}function d(){var s=n(this.type);return ae[s]||(ae[s]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),s=this.props.ref,s!==void 0?s:null}function u(s,f,p,N,O,D){var w=p.ref;return s={$$typeof:v,type:s,key:f,props:p,_owner:N},(w!==void 0?w:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:d}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:O}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:D}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function i(s,f,p,N,O,D){var w=f.children;if(w!==void 0)if(N)if(te(w)){for(N=0;N<w.length;N++)j(w[N]);Object.freeze&&Object.freeze(w)}else console.error("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 j(w);if(ee.call(f,"key")){w=n(s);var Y=Object.keys(f).filter(function(ue){return ue!=="key"});N=0<Y.length?"{key: someKey, "+Y.join(": ..., ")+": ...}":"{key: someKey}",z[w+N]||(Y=0<Y.length?"{"+Y.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,N,w,Y,w),z[w+N]=!0)}if(w=null,p!==void 0&&(a(p),w=""+p),c(f)&&(a(f.key),w=""+f.key),"key"in f){p={};for(var q in f)q!=="key"&&(p[q]=f[q])}else p=f;return w&&m(p,typeof s=="function"?s.displayName||s.name||"Unknown":s),u(s,w,p,l(),O,D)}function j(s){h(s)?s._store&&(s._store.validated=1):typeof s=="object"&&s!==null&&s.$$typeof===U&&(s._payload.status==="fulfilled"?h(s._payload.value)&&s._payload.value._store&&(s._payload.value._store.validated=1):s._store&&(s._store.validated=1))}function h(s){return typeof s=="object"&&s!==null&&s.$$typeof===v}var _=S,v=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),C=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),W=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,te=Array.isArray,H=console.createTask?console.createTask:function(){return null};_={react_stack_bottom_frame:function(s){return s()}};var ne,ae={},se=_.react_stack_bottom_frame.bind(_,o)(),re=H(r(o)),z={};J.Fragment=b,J.jsx=function(s,f,p){var N=1e4>W.recentlyCreatedOwnerStacks++;return i(s,f,p,!1,N?Error("react-stack-top-frame"):se,N?H(r(s)):re)},J.jsxs=function(s,f,p){var N=1e4>W.recentlyCreatedOwnerStacks++;return i(s,f,p,!0,N?Error("react-stack-top-frame"):se,N?H(r(s)):re)}})()),J}var _e;function Te(){return _e||(_e=1,process.env.NODE_ENV==="production"?ie.exports=Se():ie.exports=Re()),ie.exports}var e=Te();function T({element:n,opts:t,children:a}){const l=n instanceof Z.Question?n:null,o=t.validationSeq>0&&l&&typeof l.hasErrors=="function"?l.hasErrors():!1,c=x.useAnimationControls();S.useEffect(()=>{t.animate&&o&&c.start({x:[0,-6,6,-4,0],transition:{duration:.32,ease:"easeInOut"}})},[c,o,t.animate,t.validationSeq]);const m=n.name;return e.jsx(x.motion.div,{className:o?"msj__question msj__question--invalid":"msj__question","data-msj-element":m,"data-msj-question":l?.name,initial:t.animate?{opacity:.85,y:12}:!1,whileInView:t.animate?{opacity:1,y:0}:void 0,viewport:{amount:.25,once:!0},transition:{duration:t.duration},children:e.jsx(x.motion.div,{className:"msj__questionInner",animate:c,children:a})})}function A({errors:n,opts:t}){return n.length===0?null:e.jsx(x.AnimatePresence,{initial:!1,children:n.map(a=>e.jsx(x.motion.div,{className:"msj__error",layout:!0,initial:t.animate?{opacity:0,y:-2}:!1,animate:t.animate?{opacity:1,y:0}:void 0,exit:t.animate?{opacity:0,y:-2}:void 0,transition:{duration:t.duration*.75},children:a},a))})}function E(n,t){const a=(n.title??"")||n.name;return t.showQuestionNumbers==="off"||t.showQuestionNumbers==="on"&&t.globalQuestionIndex<0||t.showQuestionNumbers==="onPage"&&t.questionIndex<0?a:`${t.showQuestionNumbers==="on"?t.globalQuestionIndex+1:t.questionIndex+1}. ${a}`}function Ce(n){const t=n;return(typeof t.getText=="function"?t.getText():t.text)??""}function L(n){return(n.errors??[]).map(Ce).filter(Boolean)}function R(n,t){if(n instanceof Z.Question){const a=n,r=a.survey;if(r&&typeof r.setValue=="function"&&a.name){r.setValue(a.name,t);return}}Reflect.set(n,"value",t)}function Ee({question:n,opts:t}){const a=n,r=E(a,t),l=t.validationSeq>0?L(a):[],[o,c]=S.useState(!1);return e.jsxs(T,{element:a,opts:t,children:[e.jsxs(he.Root,{className:"msj__label",htmlFor:a.id,children:[r,a.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx(x.motion.div,{className:"msj__inputWrap",initial:!1,animate:o?{scale:1.01}:{scale:1},transition:{type:"spring",stiffness:400,damping:30},children:e.jsx("input",{id:a.id,className:"msj__input",value:a.value??"",onChange:m=>R(a,m.currentTarget.value),onFocus:()=>c(!0),onBlur:()=>c(!1)})}),e.jsx(A,{errors:l,opts:t})]})}function Pe({question:n,opts:t}){const a=n,r=E(a,t),l=t.validationSeq>0?L(a):[],[o,c]=S.useState(!1),m=String(a.value??""),d=a.maxWordCount??a.maxWords??200,i=(m.trim()?m.trim().split(/\s+/).filter(Boolean):[]).length,j=i>=d*.9;return e.jsxs(T,{element:a,opts:t,children:[e.jsxs(he.Root,{className:"msj__label",htmlFor:a.id,children:[r,a.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(x.motion.div,{className:"msj__textareaWrap",initial:!1,animate:o?{scale:1.005}:{scale:1},transition:{type:"spring",stiffness:400,damping:30},children:[e.jsx("textarea",{id:a.id,className:"msj__textarea",value:m,onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:h=>{const _=h.currentTarget.value,v=_.trim()?_.trim().split(/\s+/).filter(Boolean):[];if(v.length<=d){R(a,_);return}R(a,`${v.slice(0,d).join(" ")} `)}}),e.jsx(x.motion.div,{className:"msj__counter",initial:!1,animate:j?{scale:1.05,color:"#dc2626"}:{scale:1,color:"#64748b"},transition:{type:"spring",stiffness:400,damping:25},children:t.t("wordCount",{count:i,max:d})})]}),e.jsx(A,{errors:l,opts:t})]})}function Ie({question:n,opts:t}){const a=n,r=E(a,t),l=t.validationSeq>0?L(a):[],o=a.labelTrue||"Yes",c=a.labelFalse||"No",m=a.valueTrue??!0,d=a.valueFalse??!1,u=a.swapOrder===!0;let i;a.value===m?i="true":a.value===d?i="false":a.value===!0?i="true":a.value===!1&&(i="false");const j=P=>{R(a,P==="true"?m:d)};let h="50%",_="-50%",v="40px";i==="true"?(v="calc(50% - 6px)",u?(h="0%",_="4px"):(h="100%",_="calc(-100% - 4px)")):i==="false"&&(v="calc(50% - 6px)",u?(h="100%",_="calc(-100% - 4px)"):(h="0%",_="4px"));const g=u?o:c,b=u?c:o,y=u?"true":"false",k=u?"false":"true";return e.jsxs(T,{element:a,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,a.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(V.Root,{className:"msj__toggleSwitch",value:i,onValueChange:j,children:[e.jsxs("div",{className:"msj__toggleTrack","aria-hidden":"true",children:[e.jsx("div",{className:"msj__toggleTrackLabel msj__toggleTrackLabel--left",children:g}),e.jsx("div",{className:"msj__toggleTrackLabel msj__toggleTrackLabel--right",children:b}),e.jsx(x.motion.div,{className:`msj__toggleHandle ${i==="true"?"msj__toggleHandle--true":i==="false"?"msj__toggleHandle--false":""}`,initial:!1,animate:{left:h,x:_,width:v},transition:{type:"spring",stiffness:500,damping:30},children:e.jsx(x.motion.span,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},children:i==="true"?o:i==="false"?c:""},i||"empty")})]}),e.jsxs("div",{className:"msj__toggleInputs",children:[e.jsx(V.Item,{value:y,className:"msj__toggleInput","aria-label":g}),e.jsx(V.Item,{value:k,className:"msj__toggleInput","aria-label":b})]})]}),e.jsx(A,{errors:l,opts:t})]})}function ge({active:n,duration:t,size:a=14}){return e.jsx(x.motion.svg,{className:"msj__checkmark",width:a,height:a,viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:e.jsx(x.motion.path,{d:"M3.2 8.4 6.6 11.8 12.8 4.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",pathLength:1,initial:!1,animate:n?{pathLength:1,opacity:1}:{pathLength:0,opacity:0},transition:{duration:t}})})}function fe({question:n,isMulti:t,opts:a}){const r=n,l=E(r,a),o=a.validationSeq>0?L(r):[],c=r.visibleChoices??[];if(!t){const d=r.value==null?"":String(r.value);return e.jsxs(T,{element:r,opts:a,children:[e.jsxs("div",{className:"msj__label",children:[l,r.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx(V.Root,{className:"msj__choiceList",value:d,onValueChange:u=>{const i=c.find(j=>String(j.value)===u);R(r,i?i.value:void 0)},children:c.map(u=>{const i=String(u.value),j=u.text??i,h=d===i,_=`msj-radio-bg-${r.id}`;return e.jsx(V.Item,{value:i,asChild:!0,children:e.jsxs(x.motion.button,{type:"button",className:"msj__choiceOption",layout:!0,transition:{duration:a.duration},children:[h?e.jsx(x.motion.span,{className:"msj__choiceOptionBg",layoutId:_,transition:{type:"spring",stiffness:700,damping:40}}):null,e.jsxs("span",{className:"msj__choiceOptionContent",children:[e.jsxs("span",{className:"msj__radioItem",children:[e.jsx(V.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(x.motion.span,{className:"msj__radioIndicator",initial:!1,animate:h?{scale:1,opacity:1}:{scale:0,opacity:0},transition:h?{type:"spring",stiffness:900,damping:45}:{duration:Math.max(.12,a.duration*.4)}})}),h?e.jsx(x.motion.span,{className:"msj__radioPulse",initial:{scale:.8,opacity:.28},animate:{scale:2.2,opacity:0},transition:{duration:Math.max(.22,a.duration*1.4)}},`${i}-pulse`):null]}),e.jsx("span",{children:j})]})]})},i)})}),e.jsx(A,{errors:o,opts:a})]})}const m=new Set(Array.isArray(r.value)?r.value:[]);return e.jsxs(T,{element:r,opts:a,children:[e.jsxs("div",{className:"msj__label",children:[l,r.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__choiceList",children:c.map(d=>{const u=d.value,i=String(u),j=d.text??i,h=m.has(u);return e.jsxs("label",{className:"msj__choiceOption","data-state":h?"checked":"unchecked",children:[e.jsx(x.motion.span,{className:"msj__choiceOptionBg","aria-hidden":!0,animate:{opacity:h?1:0},transition:{duration:a.duration}}),e.jsxs("span",{className:"msj__choiceOptionContent",children:[e.jsx(le.Root,{className:"msj__checkbox",checked:h,onCheckedChange:_=>{const v=new Set(Array.isArray(r.value)?r.value:[]);_===!0?v.add(u):v.delete(u),R(r,Array.from(v))},children:e.jsx(le.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(x.motion.span,{className:"msj__checkboxIndicator",initial:!1,animate:h?{opacity:1,scale:1}:{opacity:0,scale:.9},transition:{duration:Math.max(.12,a.duration*.5)},children:e.jsx(ge,{active:h,duration:Math.max(.22,a.duration*1.2)})})})}),e.jsx("span",{children:j})]})]},i)})}),e.jsx(A,{errors:o,opts:a})]})}function Ae({question:n,opts:t}){const a=n,r=E(a,t),l=t.validationSeq>0?L(a):[],o=a.visibleChoices??[],c="__msj-empty__",m=a.value==null?c:String(a.value),d=o.find(h=>String(h.value)===m),u=m===c?t.t("selectPlaceholder"):d?.text??m,[i,j]=S.useState(!1);return e.jsxs(T,{element:a,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,a.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(M.Root,{open:i,onOpenChange:j,value:m,onValueChange:h=>{if(h===c){R(a,void 0);return}const _=o.find(v=>String(v.value)===h);R(a,_?_.value:h)},children:[e.jsxs(M.Trigger,{className:"msj__selectTrigger","aria-label":r,children:[e.jsx(M.Value,{className:m===c?"msj__selectValue msj__selectValue--placeholder":"msj__selectValue",children:u}),e.jsx(M.Icon,{className:"msj__selectIcon",children:"▾"})]}),e.jsx(M.Portal,{container:t.portalContainer??void 0,children:e.jsx(x.AnimatePresence,{children:i?e.jsx(M.Content,{className:"msj__selectContent",position:"popper",asChild:!0,children:e.jsx(x.motion.div,{initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{type:"spring",stiffness:650,damping:40},children:e.jsxs(M.Viewport,{className:"msj__selectViewport",children:[e.jsx(M.Item,{value:c,className:"msj__selectItem",children:e.jsx(M.ItemText,{children:t.t("selectPlaceholder")})}),o.map(h=>{const _=String(h.value);return e.jsx(M.Item,{value:_,className:"msj__selectItem",children:e.jsx(M.ItemText,{children:h.text??_})},_)})]})})}):null})})]}),e.jsx(A,{errors:l,opts:t})]})}function Le({question:n,opts:t}){const a=n,r=a.html??"";return e.jsxs(T,{element:n,opts:t,children:[a.title?e.jsx("div",{className:"msj__label",children:E(n,t)}):null,e.jsx("div",{className:"msj__html",dangerouslySetInnerHTML:{__html:r}})]})}function Oe({question:n,opts:t}){const a=n,r=a.imageLink??"",l=a.title??a.name;return e.jsxs(T,{element:n,opts:t,children:[a.title?e.jsx("div",{className:"msj__label",children:E(n,t)}):null,r?e.jsx("img",{className:"msj__image",src:r,alt:l}):null]})}function Me({question:n,opts:t}){const a=n,r=E(n,t),l=a.displayValue??a.value;return e.jsxs(T,{element:n,opts:t,children:[e.jsx("div",{className:"msj__label",children:r}),e.jsx("div",{className:"msj__expression",children:l==null?"":String(l)})]})}function $e({question:n,opts:t}){return null}const De=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ve=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,r)=>r?r.toUpperCase():a.toLowerCase()),pe=n=>{const t=Ve(n);return t.charAt(0).toUpperCase()+t.slice(1)},ye=(...n)=>n.filter((t,a,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===a).join(" ").trim(),Be=n=>{for(const t in n)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Fe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Qe=S.forwardRef(({color:n="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:r,className:l="",children:o,iconNode:c,...m},d)=>S.createElement("svg",{ref:d,...Fe,width:t,height:t,stroke:n,strokeWidth:r?Number(a)*24/Number(t):a,className:ye("lucide",l),...!o&&!Be(m)&&{"aria-hidden":"true"},...m},[...c.map(([u,i])=>S.createElement(u,i)),...Array.isArray(o)?o:[o]]));const $=(n,t)=>{const a=S.forwardRef(({className:r,...l},o)=>S.createElement(Qe,{ref:o,iconNode:t,className:ye(`lucide-${De(pe(n))}`,`lucide-${n}`,r),...l}));return a.displayName=pe(n),a};const Ye=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["path",{d:"M7.5 8 10 9",key:"olxxln"}],["path",{d:"m14 9 2.5-1",key:"1j6cij"}],["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}]],He=$("angry",Ye);const Ue=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],We=$("arrow-down",Ue);const Ge=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ze=$("arrow-up",Ge);const qe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],Xe=$("frown",qe);const Je=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Ke=$("grip-vertical",Je);const Ze=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12Z",key:"b2q4dd"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],et=$("laugh",Ze);const tt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"8",x2:"16",y1:"15",y2:"15",key:"1xb1d9"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],nt=$("meh",tt);const at=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],st=$("plus",at);const rt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],it=$("smile",rt);const lt=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],ot=$("star",lt);const ct=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ut=$("x",ct);function dt({active:n}){return e.jsx(ot,{size:24,fill:n?"currentColor":"none",strokeWidth:2})}function mt({idx:n,total:t}){const a=t>1?n/(t-1):.5;return a<.2?e.jsx(He,{size:24}):a<.4?e.jsx(Xe,{size:24}):a<.6?e.jsx(nt,{size:24}):a<.8?e.jsx(it,{size:24}):e.jsx(et,{size:24})}function ht({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.visibleRateValues??[],c=n.value==null?"":String(n.value),m=`msj-rating-bg-${n.id}`,d=a.rateType??"labels",u=a.scaleColorMode,i=a.minRateDescription,j=a.maxRateDescription,h=a.displayRateDescriptionsAsExtremeItems,_=o.findIndex(v=>String(v.value)===c);return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs("div",{className:"msj__rating","data-type":d,"data-color-mode":u,children:[i&&!h?e.jsx("span",{className:"msj__ratingDescription msj__ratingDescription--min",children:i}):null,o.map((v,g)=>{const b=String(v.value);let y=v.text??b;h&&(g===0&&i&&(y=i),g===o.length-1&&j&&(y=j));const k=c===b,P=d==="stars"&&_>=0?g<=_:k;let C;return u==="colored"&&(C={"--msj-rating-color":`hsl(${o.length>1?g/(o.length-1)*120:60}, 70%, 50%)`}),e.jsxs(x.motion.button,{type:"button",className:"msj__ratingItem",onClick:()=>R(n,v.value),layout:!0,transition:{duration:t.duration},"aria-label":y,style:C,children:[k?e.jsx(x.motion.span,{className:"msj__ratingItemBg",layoutId:m,transition:{type:"spring",stiffness:700,damping:40}}):null,e.jsxs("span",{className:"msj__ratingItemContent",children:[d==="stars"?e.jsx(dt,{active:P}):null,d==="smileys"?e.jsx(mt,{idx:g,total:o.length}):null,d==="labels"?y:null]})]},b)}),j&&!h?e.jsx("span",{className:"msj__ratingDescription msj__ratingDescription--max",children:j}):null]}),e.jsx(A,{errors:l,opts:t})]})}function xt({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.items??[],c=n.value??{};return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__multipleText",children:o.map((m,d)=>{const u=`${n.id}-${m.name}`;return e.jsxs(x.motion.div,{className:"msj__multipleTextRow",initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:d*.05,duration:t.duration},children:[e.jsx(he.Root,{className:"msj__labelInline",htmlFor:u,children:m.title??m.name}),e.jsx("input",{id:u,className:"msj__input",value:c[m.name]??"",onChange:i=>{R(n,{...c,[m.name]:i.currentTarget.value})}})]},m.name)})}),e.jsx(A,{errors:l,opts:t})]})}function jt({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.visibleChoices??[],c=!!a.multiSelect,m=new Set(c?Array.isArray(n.value)?n.value:[]:[n.value]),d={rest:{opacity:0},hover:{opacity:1}};return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__imagePicker",children:o.map(u=>{const i=String(u.value),j=m.has(u.value),h=`msj-imagePicker-bg-${n.id}`;return e.jsxs(x.motion.button,{type:"button",className:j?"msj__imagePickerItem msj__imagePickerItem--active":"msj__imagePickerItem",onClick:()=>{if(!c){R(n,u.value);return}const _=new Set(Array.isArray(n.value)?n.value:[]);_.has(u.value)?_.delete(u.value):_.add(u.value),R(n,Array.from(_))},layout:!0,initial:"rest",whileHover:j?void 0:"hover",transition:{duration:t.duration},children:[j?null:e.jsx(x.motion.span,{className:"msj__imagePickerHoverBg",variants:d,transition:{type:"spring",stiffness:700,damping:45}}),j?e.jsx(x.motion.span,{className:"msj__imagePickerItemBg",layoutId:h,transition:{type:"spring",stiffness:700,damping:40}}):null,u.imageLink?e.jsx("img",{className:"msj__imagePickerImg",src:u.imageLink,alt:u.text??i}):null,u.text?e.jsx("span",{className:"msj__imagePickerLabel",children:u.text}):null]},i)})}),e.jsx(A,{errors:l,opts:t})]})}function _t({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.visibleChoices??[],c=n.value==null?"":String(n.value),m=`msj-btnGroup-bg-${n.id}`;return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__buttonGroup",children:o.map(d=>{const u=String(d.value),i=c===u;return e.jsxs(x.motion.button,{type:"button",className:i?"msj__buttonGroupItem msj__buttonGroupItem--active":"msj__buttonGroupItem",onClick:()=>R(n,d.value),layout:!0,transition:{duration:t.duration},children:[i?e.jsx(x.motion.span,{className:"msj__buttonGroupItemBg",layoutId:m,transition:{type:"spring",stiffness:700,damping:40}}):null,e.jsx("span",{className:"msj__buttonGroupItemContent",children:d.text??u})]},u)})}),e.jsx(A,{errors:l,opts:t})]})}function ft({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.visibleChoices??[],c=new Set(Array.isArray(n.value)?n.value:[]);return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsx("div",{className:"msj__tagbox",children:o.map(m=>{const d=m.value,u=String(d),i=c.has(d);return e.jsxs(x.motion.button,{type:"button",className:i?"msj__tag msj__tag--active":"msj__tag",onClick:()=>{const j=new Set(Array.isArray(n.value)?n.value:[]);j.has(d)?j.delete(d):j.add(d),R(n,Array.from(j))},initial:!1,animate:i?{scale:1.02}:{scale:1},whileHover:{scale:1.04},whileTap:{scale:.97},transition:{type:"spring",stiffness:500,damping:30},children:[i?e.jsx(x.motion.span,{className:"msj__tagBg",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{type:"spring",stiffness:500,damping:35}}):null,e.jsx("span",{className:"msj__tagContent",children:m.text??u})]},u)})}),e.jsx(A,{errors:l,opts:t})]})}const de=({value:n,text:t,index:a,total:r,onClick:l,onMoveUp:o,onMoveDown:c,isRanked:m,longTap:d,enableDrag:u=!0})=>{const i=x.useDragControls(),j=S.useRef(null),h=b=>{d&&!l?(j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{i.start(b),navigator.vibrate&&navigator.vibrate(50)},500)):l||i.start(b)},_=()=>{j.current&&(clearTimeout(j.current),j.current=null)},v=b=>{l&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),l())},g=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"msj__rankingLabel",style:{flex:1},children:t}),e.jsxs("span",{className:"msj__rankingControls",style:{display:"flex",alignItems:"center",gap:"8px"},children:[l&&(m?e.jsx(ut,{size:16}):e.jsx(st,{size:16})),!l&&e.jsxs(e.Fragment,{children:[o&&a!==void 0&&a>0&&e.jsx("button",{type:"button",className:"msj__miniButton",onClick:b=>{b.stopPropagation(),o()},"aria-label":"Move up",children:e.jsx(ze,{size:16})}),c&&a!==void 0&&r!==void 0&&a<r-1&&e.jsx("button",{type:"button",className:"msj__miniButton",onClick:b=>{b.stopPropagation(),c()},"aria-label":"Move down",children:e.jsx(We,{size:16})}),e.jsx("div",{className:"msj__dragHandle",onPointerDown:h,onPointerUp:_,onPointerLeave:_,style:{cursor:d?"context-menu":"grab",display:"flex",alignItems:"center",padding:"4px"},children:e.jsx(Ke,{size:16,className:"msj__muted"})})]})]})]});return u?e.jsx(x.Reorder.Item,{value:n,className:"msj__rankingItem",dragListener:!1,dragControls:i,onClick:l,onKeyDown:v,tabIndex:l?0:void 0,role:l?"button":void 0,"aria-label":l?`${m?"Remove":"Add"} ${t}`:void 0,style:{cursor:l?"pointer":"default",touchAction:"none"},children:g}):e.jsx("li",{className:"msj__rankingItem",onClick:l,onKeyDown:v,tabIndex:l?0:void 0,role:l?"button":void 0,"aria-label":l?`${m?"Remove":"Add"} ${t}`:void 0,style:{cursor:l?"pointer":"default",touchAction:"none"},children:g})};function pt({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.visibleChoices??[],c=Array.isArray(n.value)?n.value:[],m=a.selectToRankEnabled===!0,d=a.selectToRankAreasLayout||"horizontal",u=a.selectToRankEmptyRankedAreaText||"Drag items here to rank them",i=a.selectToRankEmptyUnrankedAreaText||"All items ranked",j=a.longTap===!0,h=m?c:[...new Set([...c,...o.map(y=>y.value)])],_=m?o.filter(y=>!c.includes(y.value)).map(y=>y.value):[],v=y=>{R(n,y)},g=y=>{const k=[...c,y];R(n,k)},b=y=>{const k=c.filter(P=>P!==y);R(n,k)};return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),m?e.jsxs("div",{className:`msj__rankingContainer msj__rankingContainer--${d}`,children:[e.jsxs("div",{className:"msj__rankingArea",children:[e.jsx("div",{className:"msj__rankingAreaTitle",children:"Choices"}),_.length===0&&e.jsx("div",{className:"msj__rankingEmpty",children:i}),e.jsx(x.motion.ul,{className:"msj__ranking",layout:!0,children:e.jsx(x.AnimatePresence,{initial:!1,children:_.map(y=>{const k=String(y),P=o.find(C=>C.value===y)?.text??k;return e.jsx(x.motion.div,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},children:e.jsx(de,{value:y,text:P,onClick:()=>g(y),isRanked:!1,longTap:j,enableDrag:!1})},k)})})})]}),e.jsxs("div",{className:"msj__rankingArea",children:[e.jsx("div",{className:"msj__rankingAreaTitle",children:"Ranked"}),h.length===0&&e.jsx("div",{className:"msj__rankingEmpty",children:u}),e.jsx(x.Reorder.Group,{axis:"y",values:h,onReorder:v,className:"msj__ranking",children:e.jsx(x.AnimatePresence,{initial:!1,children:h.map(y=>{const k=String(y),P=o.find(C=>C.value===y)?.text??k;return e.jsx(de,{value:y,text:P,onClick:()=>b(y),isRanked:!0,longTap:j},k)})})})]})]}):e.jsx(x.Reorder.Group,{axis:"y",values:h,onReorder:v,className:"msj__ranking",children:h.map((y,k)=>{const P=String(y),C=o.find(I=>I.value===y)?.text??P,B=()=>{if(k>0){const I=[...h],F=I[k];I[k]=I[k-1],I[k-1]=F,v(I)}},G=()=>{if(k<h.length-1){const I=[...h],F=I[k];I[k]=I[k+1],I[k+1]=F,v(I)}};return e.jsx(de,{value:y,text:C,index:k,total:h.length,onMoveUp:B,onMoveDown:G,longTap:j},P)})}),e.jsx(A,{errors:l,opts:t})]})}async function vt(n){const t=await new Promise(a=>{const r=new FileReader;r.onload=()=>a(String(r.result??"")),r.readAsDataURL(n)});return{name:n.name,type:n.type,content:t}}function gt({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],[o,c]=S.useState(!1),m=async d=>{const u=await Promise.all(d.map(vt));R(n,a.allowMultiple===!0?u:u[0]??void 0)};return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs(x.motion.div,{className:"msj__fileDropZone",initial:!1,animate:o?{scale:1.02,borderColor:"var(--msj-primary)"}:{scale:1,borderColor:"var(--msj-border)"},transition:{type:"spring",stiffness:400,damping:25},onDragOver:d=>{d.preventDefault(),c(!0)},onDragLeave:()=>c(!1),onDrop:async d=>{d.preventDefault(),c(!1);const u=Array.from(d.dataTransfer.files);u.length>0&&await m(u)},children:[e.jsx("input",{className:"msj__fileInput",type:"file",multiple:a.allowMultiple===!0,onChange:async d=>{const u=Array.from(d.currentTarget.files??[]);await m(u)}}),e.jsx("span",{className:"msj__fileDropText",children:o?"Drop files here":"Click or drag files here"})]}),e.jsx(A,{errors:l,opts:t})]})}function yt({question:n,opts:t}){const a=E(n,t),r=t.validationSeq>0?L(n):[],l=S.useRef(null),o=S.useRef(!1),[c,m]=S.useState(0);return S.useEffect(()=>{const d=l.current;if(!d)return;let u=null;try{u=d.getContext("2d")}catch{return}if(!u)return;u.lineWidth=2,u.lineCap="round",u.strokeStyle="rgba(15, 23, 42, 0.9)";const i=v=>{const g=d.getBoundingClientRect(),b=d.width/g.width,y=d.height/g.height;return{x:(v.clientX-g.left)*b,y:(v.clientY-g.top)*y}},j=v=>{o.current=!0;try{d.setPointerCapture(v.pointerId)}catch{}const g=i(v);u.beginPath(),u.moveTo(g.x,g.y)},h=v=>{if(!o.current)return;const g=i(v);u.lineTo(g.x,g.y),u.stroke()},_=()=>{if(o.current){o.current=!1;try{R(n,d.toDataURL("image/png"))}catch{}}};return d.addEventListener("pointerdown",j),d.addEventListener("pointermove",h),window.addEventListener("pointerup",_),()=>{d.removeEventListener("pointerdown",j),d.removeEventListener("pointermove",h),window.removeEventListener("pointerup",_)}},[n,c]),e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[a,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs("div",{className:"msj__signaturePadWrap",children:[e.jsx(x.motion.canvas,{ref:l,className:"msj__signaturePad",width:560,height:160,initial:{opacity:0},animate:{opacity:1},transition:{duration:.2}},c),e.jsx(x.motion.button,{type:"button",className:"msj__miniButton",whileHover:{scale:1.05},whileTap:{scale:.95},onClick:()=>{m(d=>d+1),R(n,void 0)},children:"Clear"})]}),e.jsx(A,{errors:r,opts:t})]})}function bt({question:n,opts:t,render:a}){const r=n,l=E(n,t),o=r.panels??[];return e.jsxs(T,{element:n,opts:t,children:[e.jsx("div",{className:"msj__label",children:l}),e.jsxs("div",{className:"msj__panelDynamic",children:[e.jsx(x.AnimatePresence,{mode:"popLayout",children:o.map((c,m)=>e.jsxs(x.motion.div,{className:"msj__panelDynamicItem",initial:{opacity:0,y:-10,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.98},transition:{type:"spring",stiffness:500,damping:35},children:[e.jsxs("div",{className:"msj__panelDynamicHeader",children:[e.jsxs("div",{className:"msj__panelDynamicTitle",children:["Item ",m+1]}),r.removePanel?e.jsx(x.motion.button,{type:"button",className:"msj__miniButton",onClick:()=>r.removePanel?.(c),whileHover:{scale:1.05},whileTap:{scale:.95},children:"Remove"}):null]}),a(c,t)]},c.name??m))}),r.addPanel?e.jsx(x.motion.button,{type:"button",className:"msj__button",onClick:()=>r.addPanel?.(),whileHover:{scale:1.02},whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:25},children:"Add item"}):null]})]})}function Nt({question:n,opts:t}){const a=n,r=E(n,t),l=t.validationSeq>0?L(n):[],o=a.rows??a.visibleRows??[],c=a.columns??a.visibleColumns??[],m=n.value??{},d=a.cellType==="checkbox";return e.jsxs(T,{element:n,opts:t,children:[e.jsxs("div",{className:"msj__label",children:[r,n.isRequired?e.jsx("span",{"aria-hidden":!0,children:" *"}):null]}),e.jsxs("div",{className:"msj__matrix",style:{"--msj-matrix-cols":String(c.length)},children:[e.jsxs("div",{className:"msj__matrixHeader","aria-hidden":!0,children:[e.jsx("div",{className:"msj__matrixHeaderCell msj__matrixCorner"}),c.map(u=>{const i=String(u.value);return e.jsx("div",{className:"msj__matrixHeaderCell",children:u.text??i},i)})]}),o.map(u=>{const i=String(u.value),j=u.text??i;return e.jsxs("div",{className:"msj__matrixRow",children:[e.jsx("div",{className:"msj__matrixRowTitle",children:j}),d?e.jsx("div",{className:"msj__matrixRowChoices",children:c.map(h=>{const _=String(h.value),v=Array.isArray(m[i])?m[i]:[],g=v.includes(h.value);return e.jsx("label",{className:"msj__matrixCell","data-state":g?"checked":"unchecked",children:e.jsx(le.Root,{className:"msj__checkbox",checked:g,onCheckedChange:b=>{const y=new Set(v);b===!0?y.add(h.value):y.delete(h.value),R(n,{...m,[i]:Array.from(y)})},children:e.jsx(le.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(x.motion.span,{className:"msj__checkboxIndicator",initial:!1,animate:g?{opacity:1,scale:1}:{opacity:0,scale:.9},transition:{duration:Math.max(.12,t.duration*.5)},children:e.jsx(ge,{active:g,duration:Math.max(.22,t.duration*1.2)})})})})},_)})}):e.jsx(V.Root,{className:"msj__matrixRowChoices",value:m[i]==null?"":String(m[i]),onValueChange:h=>{R(n,{...m,[i]:h})},children:c.map(h=>{const _=String(h.value),v=h.text??_,g=String(m[i]??"")===_;return e.jsx(V.Item,{value:_,asChild:!0,children:e.jsx("button",{type:"button",className:"msj__matrixCell","aria-label":`${j}: ${v}`,"data-state":g?"checked":"unchecked",children:e.jsxs("span",{className:"msj__radioItem","aria-hidden":!0,children:[e.jsx(V.Indicator,{forceMount:!0,asChild:!0,children:e.jsx(x.motion.span,{className:"msj__radioIndicator",initial:!1,animate:g?{scale:1,opacity:1}:{scale:0,opacity:0},transition:g?{type:"spring",stiffness:900,damping:45}:{duration:Math.max(.12,t.duration*.4)}})}),g?e.jsx(x.motion.span,{className:"msj__radioPulse",initial:{scale:.8,opacity:.28},animate:{scale:2.2,opacity:0},transition:{duration:Math.max(.22,t.duration*1.4)}}):null]})})},`${i}:${_}`)})})]},i)})]}),e.jsx(A,{errors:l,opts:t})]})}function kt({question:n,opts:t}){const a=E(n,t);return e.jsxs(T,{element:n,opts:t,children:[e.jsx("div",{className:"msj__label",children:a}),e.jsx("div",{className:"msj__unsupported",children:"Matrix Dropdown is not yet fully supported."})]})}function wt({question:n,opts:t}){const a=E(n,t);return e.jsxs(T,{element:n,opts:t,children:[e.jsx("div",{className:"msj__label",children:a}),e.jsx("div",{className:"msj__unsupported",children:"Matrix Dynamic is not yet fully supported."})]})}function me({element:n,opts:t,render:a}){const r=n,l=r.elements??[];return e.jsxs(T,{element:n,opts:t,children:[r.title?e.jsx("div",{className:"msj__label",children:r.title}):null,e.jsx("div",{className:"msj__panel",children:l.map((o,c)=>{const m=typeof o.getType=="function"?o.getType():"unknown",d=o.name??`${m}-${c}`;return e.jsx("div",{children:a(o,t)},d)})})]})}function K(n,t){const a=typeof n.getType=="function"?n.getType():"unknown";if(!(n instanceof Z.Question))switch(a){case"flowpanel":return e.jsx(me,{element:n,opts:t,render:K});case"page":return e.jsx(me,{element:n,opts:t,render:K});default:return e.jsx(me,{element:n,opts:t,render:K})}const r=n;switch(a){case"comment":return e.jsx(Pe,{question:r,opts:t});case"boolean":return e.jsx(Ie,{question:r,opts:t});case"radiogroup":return e.jsx(fe,{question:r,isMulti:!1,opts:t});case"checkbox":return e.jsx(fe,{question:r,isMulti:!0,opts:t});case"dropdown":return e.jsx(Ae,{question:r,opts:t});case"tagbox":return e.jsx(ft,{question:r,opts:t});case"buttongroup":return e.jsx(_t,{question:r,opts:t});case"ranking":return e.jsx(pt,{question:r,opts:t});case"imagepicker":return e.jsx(jt,{question:r,opts:t});case"file":return e.jsx(gt,{question:r,opts:t});case"signaturepad":return e.jsx(yt,{question:r,opts:t});case"paneldynamic":return e.jsx(bt,{question:r,opts:t,render:K});case"matrix":return e.jsx(Nt,{question:r,opts:t});case"matrixdropdown":return e.jsx(kt,{question:r,opts:t});case"matrixdynamic":return e.jsx(wt,{question:r,opts:t});case"html":return e.jsx(Le,{question:r,opts:t});case"image":return e.jsx(Oe,{question:r,opts:t});case"expression":return e.jsx(Me,{question:r,opts:t});case"empty":return e.jsx($e,{question:r,opts:t});case"rating":return e.jsx(ht,{question:r,opts:t});case"multipletext":return e.jsx(xt,{question:r,opts:t});case"text":default:return e.jsx(Ee,{question:r,opts:t})}}const St="Previous",Rt="Next",Tt="Complete",Ct="Thanks!",Et="Your responses have been recorded.",Pt="Select…",It="{count}/{max} words",At="Page {current} of {total}",Lt={back:St,next:Rt,complete:Tt,thanksTitle:Ct,thanksHint:Et,selectPlaceholder:Pt,wordCount:It,pageXofY:At},Ot="Previous",Mt="Next",$t="Complete",Dt="Thanks!",Vt="Your responses have been recorded.",Bt="Select…",Ft="{count}/{max} words",Qt="Page {current} of {total}",Yt={back:Ot,next:Mt,complete:$t,thanksTitle:Dt,thanksHint:Vt,selectPlaceholder:Bt,wordCount:Ft,pageXofY:Qt},ve={"en-US":Yt,"en-GB":Lt};function Ht(n){return ve[n??"en-US"]??ve["en-US"]}function Ut({locale:n,messages:t}){const r={...Ht(n),...t??{}};return(l,o)=>{let c=r[l]??l;if(o)for(const[m,d]of Object.entries(o))c=c.replaceAll(`{${m}}`,String(d));return c}}function Wt(){return e.jsx("svg",{className:"msj__navIcon",width:"18",height:"18",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,focusable:"false",children:e.jsx("path",{d:"M10 3.5 6 8l4 4.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Gt(){return e.jsx("svg",{className:"msj__navIcon",width:"18",height:"18",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,focusable:"false",children:e.jsx("path",{d:"M6 3.5 10 8l-4 4.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function zt({json:n,model:t,data:a,onComplete:r,animate:l=!0,animationDurationMs:o=180,theme:c="modern",locale:m="en-US",messages:d,className:u}){const i=S.useMemo(()=>{if(t)return t;const s=n??{},f=s.showQuestionNumbers===void 0?{...s,showQuestionNumbers:"onPage"}:s,p=new Z.Model(f);return a&&(p.data=a),p},[t,n,a]),[,j]=S.useReducer(s=>s+1,0),[h,_]=S.useReducer((s,f)=>f.type==="setPage"?{pageName:f.pageName,seq:0}:s.pageName!==f.pageName?{pageName:f.pageName,seq:1}:{pageName:s.pageName,seq:s.seq+1},{pageName:null,seq:0}),v=S.useRef(null),g=o/1e3,b=S.useMemo(()=>Ut({locale:m,messages:d}),[m,d]),[y,k]=S.useState(null),P=["msj",c?`msj--theme-${c}`:null,u].filter(Boolean).join(" ");if(S.useEffect(()=>{const s=()=>j(),f=()=>{_({type:"setPage",pageName:i.currentPage?.name??null}),s()},p=()=>{r?.(i.data,i),s()};return i.onValueChanged.add(s),i.onCurrentPageChanged.add(f),i.onComplete.add(p),()=>{i.onValueChanged.remove(s),i.onCurrentPageChanged.remove(f),i.onComplete.remove(p)}},[i,r]),S.useEffect(()=>{const s=v.current;if(!s)return;v.current=null;const f=typeof window<"u"&&window.CSS&&typeof window.CSS.escape=="function"?window.CSS.escape:O=>O.replaceAll('"','\\"'),p=document.querySelector(`[data-msj-question="${f(s)}"]`);if(!p)return;const N=p.querySelector('input, textarea, select, button, [tabindex]:not([tabindex="-1"])');try{p.scrollIntoView({behavior:"smooth",block:"center"})}catch{p.scrollIntoView()}N?.focus({preventScroll:!0})}),i.state==="completed")return e.jsx("div",{className:P,children:e.jsxs("div",{className:"msj__card",children:[e.jsx("h2",{className:"msj__title",children:b("thanksTitle")}),e.jsx("div",{className:"msj__hint",children:b("thanksHint")})]})});const C=i.currentPage,B=C?.questions??[],G=C?.elements??B,I=h.pageName===(C?.name??null)?h.seq:0,F=i.showPageTitles!==!1,U=i.showPageNumbers===!0,Q=i.showQuestionNumbers,ce=Q===!0?"on":Q===!1?"off":Q==="off"||Q==="on"||Q==="onPage"?Q:"onPage",W=i.navigationButtonsLocation??"bottom",ee=i.showNavigationButtons!==!1,te=C?.navigationButtonsVisibility??"inherit",H=te==="hide"?!1:te==="show"?!0:ee,ne=i.showPrevButton!==!1,ae=H&&ne&&!i.isFirstPage,se=H&&!i.isLastPage,re=H&&i.isLastPage,z=s=>W==="topBottom"||W===s?e.jsxs("div",{className:s==="top"?"msj__nav msj__nav--top":"msj__nav",children:[e.jsx("div",{className:"msj__navSlot msj__navSlot--left",children:e.jsx(x.AnimatePresence,{initial:!1,children:ae?e.jsxs(x.motion.button,{type:"button",className:"msj__button msj__button--nav",onClick:()=>{i.prevPage(),j()},initial:l?{opacity:0,x:-6}:!1,animate:l?{opacity:1,x:0}:void 0,exit:l?{opacity:0,x:-6}:void 0,transition:{duration:g},whileHover:l?{x:-2}:void 0,whileTap:l?{scale:.98}:void 0,children:[e.jsx(Wt,{}),b("back")]},"prev"):null})}),e.jsx("div",{className:"msj__navSlot msj__navSlot--center",children:e.jsx(x.AnimatePresence,{initial:!1,children:re?e.jsx(x.motion.button,{type:"button",className:"msj__button msj__button--primary msj__button--complete",onClick:()=>{let p=!1;try{p=i.validateCurrentPage()}catch{p=!1}if(!p){const N=B.find(O=>O.hasErrors());v.current=N?.name??null,_({type:"bump",pageName:C?.name??null}),j();return}i.tryComplete(),j()},initial:l?{opacity:0,y:6,scale:.98}:!1,animate:l?{opacity:1,y:0,scale:1}:void 0,exit:l?{opacity:0,y:6,scale:.98}:void 0,transition:{duration:g,x:{type:"tween",duration:.32,ease:"easeInOut"},rotate:{type:"tween",duration:.32,ease:"easeInOut"}},whileHover:l?{x:[0,-2,2,-2,0],rotate:[0,-1.2,1.2,-1.2,0]}:void 0,whileTap:l?{scale:.98}:void 0,children:b("complete")},"complete"):null})}),e.jsx("div",{className:"msj__navSlot msj__navSlot--right",children:e.jsx(x.AnimatePresence,{initial:!1,children:se?e.jsxs(x.motion.button,{type:"button",className:"msj__button msj__button--primary msj__button--navPrimary",onClick:()=>{let p=!1;try{p=i.validateCurrentPage()}catch{p=!1}if(!p){const N=B.find(O=>O.hasErrors());v.current=N?.name??null,_({type:"bump",pageName:C?.name??null}),j();return}i.nextPage(),j()},initial:l?{opacity:0,x:6}:!1,animate:l?{opacity:1,x:0}:void 0,exit:l?{opacity:0,x:6}:void 0,transition:{duration:g},whileHover:l?{x:2}:void 0,whileTap:l?{scale:.98}:void 0,children:[b("next"),e.jsx(Gt,{})]},"next"):null})})]}):null;return e.jsx("div",{className:P,ref:k,children:e.jsxs("div",{className:"msj__card",children:[i.title?e.jsx("h2",{className:"msj__title",children:i.title}):null,z("top"),e.jsx(x.AnimatePresence,{mode:"wait",initial:!1,children:e.jsxs(x.motion.div,{initial:l?{opacity:0,y:8}:!1,animate:l?{opacity:1,y:0}:void 0,exit:l?{opacity:0,y:-8}:void 0,transition:{duration:g},children:[F||U?e.jsxs("div",{className:"msj__pageHeader",children:[F&&C?.title?e.jsx("div",{className:"msj__pageTitle",children:C.title}):null,U?e.jsx("div",{className:"msj__pageNumber",children:b("pageXofY",{current:(i.currentPageNo??0)+1,total:i.pages?.length??0})}):null]}):null,(()=>{const s=(i.pages??[]).slice(0,i.currentPageNo??0).reduce((p,N)=>p+(N.questions??[]).length,0);return G.reduce((p,N,O)=>{const D=typeof N.getType=="function"?N.getType():"unknown",w=N instanceof Z.Question&&D!=="html"&&D!=="image"&&D!=="expression"&&D!=="empty",Y=w?p.pageQuestionIndex:-1,q=w?p.globalQuestionIndex:-1,ue=N.name??`${D}-${O}`;return{items:[...p.items,e.jsx("div",{children:K(N,{animate:l,duration:g,t:b,validationSeq:I,questionIndex:Y,globalQuestionIndex:q,showQuestionNumbers:ce,portalContainer:y})},ue)],pageQuestionIndex:w?p.pageQuestionIndex+1:p.pageQuestionIndex,globalQuestionIndex:w?p.globalQuestionIndex+1:p.globalQuestionIndex}},{items:[],pageQuestionIndex:0,globalQuestionIndex:s}).items})()]},C?.name??"page")}),z("bottom")]})})}exports.MotionSurvey=zt;
7
+ //# sourceMappingURL=index.cjs.map