@landform.io/sdk 0.1.2
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/api/index.cjs +17 -0
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/index.d.cts +48 -0
- package/dist/api/index.d.ts +48 -0
- package/dist/api/index.js +4 -0
- package/dist/api/index.js.map +1 -0
- package/dist/chunk-52W6RI6C.cjs +4 -0
- package/dist/chunk-52W6RI6C.cjs.map +1 -0
- package/dist/chunk-DASQI7IA.cjs +4 -0
- package/dist/chunk-DASQI7IA.cjs.map +1 -0
- package/dist/chunk-EL7YGOTY.js +3 -0
- package/dist/chunk-EL7YGOTY.js.map +1 -0
- package/dist/chunk-GVOTY5NG.js +3 -0
- package/dist/chunk-GVOTY5NG.js.map +1 -0
- package/dist/chunk-HUIMGLDC.js +488 -0
- package/dist/chunk-HUIMGLDC.js.map +1 -0
- package/dist/chunk-I6L5OCM3.js +1657 -0
- package/dist/chunk-I6L5OCM3.js.map +1 -0
- package/dist/chunk-IQXKFO6Q.cjs +55 -0
- package/dist/chunk-IQXKFO6Q.cjs.map +1 -0
- package/dist/chunk-P2GUKJHH.cjs +117 -0
- package/dist/chunk-P2GUKJHH.cjs.map +1 -0
- package/dist/chunk-PDUJU32P.js +687 -0
- package/dist/chunk-PDUJU32P.js.map +1 -0
- package/dist/chunk-PKHTPGWQ.js +114 -0
- package/dist/chunk-PKHTPGWQ.js.map +1 -0
- package/dist/chunk-V7WAYO2Q.js +48 -0
- package/dist/chunk-V7WAYO2Q.js.map +1 -0
- package/dist/chunk-WHV333XL.cjs +1684 -0
- package/dist/chunk-WHV333XL.cjs.map +1 -0
- package/dist/chunk-WIFNU3FA.cjs +497 -0
- package/dist/chunk-WIFNU3FA.cjs.map +1 -0
- package/dist/chunk-ZLOP4BTK.cjs +695 -0
- package/dist/chunk-ZLOP4BTK.cjs.map +1 -0
- package/dist/components/index.cjs +99 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.cts +166 -0
- package/dist/components/index.d.ts +166 -0
- package/dist/components/index.js +6 -0
- package/dist/components/index.js.map +1 -0
- package/dist/hooks/index.cjs +35 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +75 -0
- package/dist/hooks/index.d.ts +75 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index-DoRZImTl.d.cts +590 -0
- package/dist/index-DoRZImTl.d.ts +590 -0
- package/dist/index.cjs +186 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/theme/index.cjs +61 -0
- package/dist/theme/index.cjs.map +1 -0
- package/dist/theme/index.d.cts +65 -0
- package/dist/theme/index.d.ts +65 -0
- package/dist/theme/index.js +4 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/useForm-D1mB6REv.d.ts +48 -0
- package/dist/useForm-kF8xK1mJ.d.cts +48 -0
- package/package.json +101 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theme/generateCSS.ts","../src/theme/injection.ts"],"names":[],"mappings":";AAKO,SAAS,YAAY,MAAA,EAAgD;AAC3E,EAAA,QAAQ,MAAA;AAAQ,IACf,KAAK,MAAA;AACJ,MAAA,OAAO,GAAA;AAAA,IACR,KAAK,OAAA;AACJ,MAAA,OAAO,KAAA;AAAA,IACR,KAAK,QAAA;AACJ,MAAA,OAAO,KAAA;AAAA,IACR,KAAK,OAAA;AACJ,MAAA,OAAO,MAAA;AAAA,IACR,KAAK,MAAA;AACJ,MAAA,OAAO,QAAA;AAAA,IACR;AACC,MAAA,OAAO,GAAA;AAAA;AAEV;AAMO,SAAS,iBAAiB,KAAA,EAA0B;AAC1D,EAAA,MAAM,CAAA,GAAI,KAAA;AAEV,EAAA,OAAO;AAAA;AAAA;AAAA,qBAAA,EAGe,CAAA,CAAE,O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,CAAS,cAAA,CAAe,QAAQ,CAAA;AAE9C,EAAA,IAAI,CAAC,OAAA,EAAS;AACb,IAAA,OAAA,GAAU,QAAA,CAAS,cAAc,OAAO,CAAA;AACxC,IAAA,OAAA,CAAQ,EAAA,GAAK,QAAA;AACb,IAAA,QAAA,CAAS,IAAA,CAAK,YAAY,OAAO,CAAA;AAAA,EAClC;AAEA,EAAA,OAAA,CAAQ,WAAA,GAAc,sBAAsB,KAAK,CAAA;AAGjD,EAAA,IAAI,MAAM,SAAA,EAAW;AACpB,IAAA,IAAI,gBAAgB,QAAA,CAAS,cAAA;AAAA,MAC5B;AAAA,KACD;AACA,IAAA,IAAI,CAAC,aAAA,EAAe;AACnB,MAAA,aAAA,GAAgB,QAAA,CAAS,cAAc,OAAO,CAAA;AAC9C,MAAA,aAAA,CAAc,EAAA,GAAK,eAAA;AACnB,MAAA,QAAA,CAAS,IAAA,CAAK,YAAY,aAAa,CAAA;AAAA,IACxC;AACA,IAAA,aAAA,CAAc,cAAc,KAAA,CAAM,SAAA;AAAA,EACnC;AAGA,EAAA,OAAO,MAAM;AACZ,IAAA,MAAM,EAAA,GAAK,QAAA,CAAS,cAAA,CAAe,QAAQ,CAAA;AAC3C,IAAA,IAAI,EAAA,KAAO,MAAA,EAAO;AAClB,IAAA,MAAM,QAAA,GAAW,QAAA,CAAS,cAAA,CAAe,eAAe,CAAA;AACxD,IAAA,IAAI,QAAA,WAAmB,MAAA,EAAO;AAAA,EAC/B,CAAA;AACD;AAKO,SAAS,kBAAkB,KAAA,EAA0B;AAC3D,EAAA,OAAO,sBAAsB,KAAK,CAAA;AACnC","file":"chunk-PDUJU32P.js","sourcesContent":["import type { FormTheme } from \"../types\";\n\n/**\n * Convert border radius enum to CSS value\n */\nexport function radiusToCSS(radius: FormTheme[\"borders\"][\"radius\"]): string {\n\tswitch (radius) {\n\t\tcase \"none\":\n\t\t\treturn \"0\";\n\t\tcase \"small\":\n\t\t\treturn \"4px\";\n\t\tcase \"medium\":\n\t\t\treturn \"8px\";\n\t\tcase \"large\":\n\t\t\treturn \"12px\";\n\t\tcase \"full\":\n\t\t\treturn \"9999px\";\n\t\tdefault:\n\t\t\treturn \"0\";\n\t}\n}\n\n/**\n * Generate CSS custom properties from theme\n * These variables use the --lf- prefix (Landform)\n */\nexport function generateThemeCSS(theme: FormTheme): string {\n\tconst t = theme;\n\n\treturn `\n:root {\n\t/* Colors - Base */\n\t--lf-color-primary: ${t.colors.primary};\n\t--lf-color-secondary: ${t.colors.secondary};\n\t--lf-color-accent: ${t.colors.accent};\n\n\t/* Colors - Backgrounds */\n\t--lf-color-background: ${t.colors.background};\n\t--lf-color-surface: ${t.colors.surfaceBackground};\n\t--lf-color-input-bg: ${t.colors.inputBackground};\n\t--lf-color-input-border: ${t.colors.inputBorder};\n\n\t/* Colors - Text */\n\t--lf-color-question: ${t.colors.questionText};\n\t--lf-color-answer: ${t.colors.answerText};\n\t--lf-color-placeholder: ${t.colors.placeholderText};\n\n\t/* Colors - Buttons */\n\t--lf-color-button-bg: ${t.colors.buttonBackground};\n\t--lf-color-button-text: ${t.colors.buttonText};\n\t--lf-color-button-hover: ${t.colors.buttonHoverBackground};\n\n\t/* Colors - Selection */\n\t--lf-color-selected-bg: ${t.colors.selectedBackground};\n\t--lf-color-selected-border: ${t.colors.selectedBorder};\n\n\t/* Colors - Feedback */\n\t--lf-color-error: ${t.colors.errorColor};\n\t--lf-color-success: ${t.colors.successColor};\n\n\t/* Colors - Progress */\n\t--lf-color-progress-bg: ${t.colors.progressBackground};\n\t--lf-color-progress-fill: ${t.colors.progressFill};\n\n\t/* Typography - Question */\n\t--lf-font-question: ${t.typography.questionFont.family};\n\t--lf-font-size-question: ${t.typography.questionFont.size};\n\t--lf-font-weight-question: ${t.typography.questionFont.weight};\n\t--lf-line-height-question: ${t.typography.questionFont.lineHeight};\n\t${t.typography.questionFont.letterSpacing ? `--lf-letter-spacing-question: ${t.typography.questionFont.letterSpacing};` : \"\"}\n\n\t/* Typography - Answer */\n\t--lf-font-answer: ${t.typography.answerFont.family};\n\t--lf-font-size-answer: ${t.typography.answerFont.size};\n\t--lf-font-weight-answer: ${t.typography.answerFont.weight};\n\t--lf-line-height-answer: ${t.typography.answerFont.lineHeight};\n\t${t.typography.answerFont.letterSpacing ? `--lf-letter-spacing-answer: ${t.typography.answerFont.letterSpacing};` : \"\"}\n\n\t/* Typography - Button */\n\t--lf-font-button: ${t.typography.buttonFont.family};\n\t--lf-font-size-button: ${t.typography.buttonFont.size};\n\t--lf-font-weight-button: ${t.typography.buttonFont.weight};\n\t--lf-line-height-button: ${t.typography.buttonFont.lineHeight};\n\n\t/* Spacing */\n\t--lf-spacing-question: ${t.spacing.questionGap};\n\t--lf-spacing-option: ${t.spacing.optionGap};\n\t--lf-spacing-container: ${t.spacing.containerPadding};\n\n\t/* Borders */\n\t--lf-border-width: ${t.borders.inputBorderWidth};\n\t--lf-border-style: ${t.borders.inputBorderStyle};\n\t--lf-border-radius: ${radiusToCSS(t.borders.radius)};\n\n\t/* Animations */\n\t--lf-transition-duration: ${t.animations.transitionDuration};\n\t--lf-transition-easing: ${t.animations.transitionEasing};\n}\n`.trim();\n}\n\n/**\n * Generate component-level CSS classes\n */\nexport function generateComponentStyles(): string {\n\treturn `\n/* ============================================================================\n Landform SDK - Component Styles\n ============================================================================ */\n\n/* Form Container */\n.lf-form {\n\tmin-height: 100vh;\n\tdisplay: flex;\n\tflex-direction: column;\n\tbackground-color: var(--lf-color-background);\n\tfont-family: var(--lf-font-answer);\n\tcolor: var(--lf-color-answer);\n}\n\n/* Question Container */\n.lf-question-container {\n\tflex: 1;\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: center;\n\tpadding: var(--lf-spacing-container);\n\tmax-width: 720px;\n\tmargin: 0 auto;\n\twidth: 100%;\n}\n\n/* Question Title */\n.lf-question-title {\n\tfont-family: var(--lf-font-question);\n\tfont-size: var(--lf-font-size-question);\n\tfont-weight: var(--lf-font-weight-question);\n\tline-height: var(--lf-line-height-question);\n\tcolor: var(--lf-color-question);\n\tmargin: 0 0 0.5rem 0;\n}\n\n/* Question Description */\n.lf-question-description {\n\tcolor: var(--lf-color-answer);\n\topacity: 0.8;\n\tmargin: 0;\n}\n\n/* Required Indicator */\n.lf-required {\n\tcolor: var(--lf-color-error);\n}\n\n/* Input Base */\n.lf-input {\n\twidth: 100%;\n\tpadding: 0.75rem 1rem;\n\tfont-family: var(--lf-font-answer);\n\tfont-size: var(--lf-font-size-answer);\n\tcolor: var(--lf-color-answer);\n\tbackground-color: var(--lf-color-input-bg);\n\tborder: var(--lf-border-width) var(--lf-border-style) var(--lf-color-input-border);\n\tborder-radius: var(--lf-border-radius);\n\toutline: none;\n\ttransition: border-color var(--lf-transition-duration) var(--lf-transition-easing);\n}\n\n.lf-input:focus {\n\tborder-color: var(--lf-color-primary);\n}\n\n.lf-input::placeholder {\n\tcolor: var(--lf-color-placeholder);\n}\n\n/* Input Underline Style */\n.lf-input-underline {\n\twidth: 100%;\n\tpadding: 0.75rem 0;\n\tfont-family: var(--lf-font-answer);\n\tfont-size: var(--lf-font-size-answer);\n\tcolor: var(--lf-color-answer);\n\tbackground-color: transparent;\n\tborder: none;\n\tborder-bottom: var(--lf-border-width) var(--lf-border-style) var(--lf-color-input-border);\n\tborder-radius: 0;\n\toutline: none;\n\ttransition: border-color var(--lf-transition-duration) var(--lf-transition-easing);\n}\n\n.lf-input-underline:focus {\n\tborder-bottom-color: var(--lf-color-primary);\n}\n\n.lf-input-underline::placeholder {\n\tcolor: var(--lf-color-placeholder);\n}\n\n/* Choice Button */\n.lf-choice {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 0.75rem;\n\twidth: 100%;\n\tpadding: 1rem 1.25rem;\n\tfont-family: var(--lf-font-answer);\n\tfont-size: var(--lf-font-size-answer);\n\tcolor: var(--lf-color-answer);\n\tbackground-color: var(--lf-color-surface);\n\tborder: var(--lf-border-width) var(--lf-border-style) var(--lf-color-input-border);\n\tborder-radius: var(--lf-border-radius);\n\tcursor: pointer;\n\ttransition: all var(--lf-transition-duration) var(--lf-transition-easing);\n\ttext-align: left;\n}\n\n.lf-choice:hover {\n\tborder-color: var(--lf-color-primary);\n}\n\n.lf-choice-selected {\n\tbackground-color: var(--lf-color-selected-bg);\n\tborder-color: var(--lf-color-selected-border);\n}\n\n/* Key Hint */\n.lf-key-hint {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tmin-width: 1.75rem;\n\theight: 1.75rem;\n\tpadding: 0 0.5rem;\n\tfont-size: 0.875rem;\n\tfont-weight: 500;\n\tcolor: var(--lf-color-answer);\n\tbackground-color: var(--lf-color-background);\n\tborder: 1px solid var(--lf-color-input-border);\n\tborder-radius: var(--lf-border-radius);\n}\n\n.lf-choice-selected .lf-key-hint {\n\tbackground-color: var(--lf-color-primary);\n\tborder-color: var(--lf-color-primary);\n\tcolor: var(--lf-color-button-text);\n}\n\n/* Button */\n.lf-button {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tgap: 0.5rem;\n\tpadding: 0.75rem 1.5rem;\n\tfont-family: var(--lf-font-button);\n\tfont-size: var(--lf-font-size-button);\n\tfont-weight: var(--lf-font-weight-button);\n\tline-height: var(--lf-line-height-button);\n\tcolor: var(--lf-color-button-text);\n\tbackground-color: var(--lf-color-button-bg);\n\tborder: none;\n\tborder-radius: var(--lf-border-radius);\n\tcursor: pointer;\n\ttransition: background-color var(--lf-transition-duration) var(--lf-transition-easing);\n}\n\n.lf-button:hover {\n\tbackground-color: var(--lf-color-button-hover);\n}\n\n.lf-button:disabled {\n\topacity: 0.5;\n\tcursor: not-allowed;\n}\n\n/* Progress Bar */\n.lf-progress {\n\tbackground-color: var(--lf-color-progress-bg);\n\toverflow: hidden;\n}\n\n.lf-progress-fill {\n\tbackground-color: var(--lf-color-progress-fill);\n\ttransition: width var(--lf-transition-duration) var(--lf-transition-easing);\n}\n\n/* Rating Stars */\n.lf-rating-star {\n\tcursor: pointer;\n\tcolor: var(--lf-color-input-border);\n\ttransition: color var(--lf-transition-duration) var(--lf-transition-easing);\n}\n\n.lf-rating-star-active {\n\tcolor: var(--lf-color-primary);\n}\n\n.lf-rating-star:hover {\n\tcolor: var(--lf-color-primary);\n}\n\n/* Scale Button (Opinion Scale, NPS) */\n.lf-scale-button {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tmin-width: 2.5rem;\n\theight: 2.5rem;\n\tpadding: 0.5rem;\n\tfont-family: var(--lf-font-answer);\n\tfont-size: var(--lf-font-size-answer);\n\tcolor: var(--lf-color-answer);\n\tbackground-color: var(--lf-color-surface);\n\tborder: var(--lf-border-width) var(--lf-border-style) var(--lf-color-input-border);\n\tborder-radius: var(--lf-border-radius);\n\tcursor: pointer;\n\ttransition: all var(--lf-transition-duration) var(--lf-transition-easing);\n}\n\n.lf-scale-button:hover {\n\tborder-color: var(--lf-color-primary);\n}\n\n.lf-scale-button-selected {\n\tbackground-color: var(--lf-color-primary);\n\tborder-color: var(--lf-color-primary);\n\tcolor: var(--lf-color-button-text);\n}\n\n/* Navigation */\n.lf-navigation {\n\tposition: fixed;\n\tbottom: 0;\n\tleft: 0;\n\tright: 0;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tpadding: 1rem var(--lf-spacing-container);\n\tbackground-color: var(--lf-color-background);\n\tborder-top: 1px solid var(--lf-color-input-border);\n}\n\n.lf-navigation-button {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 0.5rem;\n\tpadding: 0.5rem 1rem;\n\tfont-family: var(--lf-font-button);\n\tfont-size: 0.875rem;\n\tcolor: var(--lf-color-answer);\n\tbackground-color: transparent;\n\tborder: 1px solid var(--lf-color-input-border);\n\tborder-radius: var(--lf-border-radius);\n\tcursor: pointer;\n\ttransition: all var(--lf-transition-duration) var(--lf-transition-easing);\n}\n\n.lf-navigation-button:hover {\n\tborder-color: var(--lf-color-primary);\n\tcolor: var(--lf-color-primary);\n}\n\n.lf-navigation-button:disabled {\n\topacity: 0.3;\n\tcursor: not-allowed;\n}\n\n/* Error Message */\n.lf-error {\n\tcolor: var(--lf-color-error);\n\tfont-size: 0.875rem;\n\tmargin-top: 0.5rem;\n}\n\n/* Branding */\n.lf-branding {\n\tpadding: 1rem;\n\ttext-align: center;\n\tfont-size: 0.75rem;\n\tcolor: var(--lf-color-placeholder);\n}\n\n.lf-branding a {\n\tcolor: var(--lf-color-primary);\n\ttext-decoration: none;\n}\n\n.lf-branding a:hover {\n\ttext-decoration: underline;\n}\n\n/* Picture Choice Grid */\n.lf-picture-grid {\n\tdisplay: grid;\n\tgrid-template-columns: repeat(auto-fit, minmax(140px, 1fr));\n\tgap: var(--lf-spacing-option);\n}\n\n.lf-picture-card {\n\tdisplay: flex;\n\tflex-direction: column;\n\toverflow: hidden;\n\tbackground-color: var(--lf-color-surface);\n\tborder: var(--lf-border-width) var(--lf-border-style) var(--lf-color-input-border);\n\tborder-radius: var(--lf-border-radius);\n\tcursor: pointer;\n\ttransition: all var(--lf-transition-duration) var(--lf-transition-easing);\n}\n\n.lf-picture-card:hover {\n\tborder-color: var(--lf-color-primary);\n}\n\n.lf-picture-card-selected {\n\tborder-color: var(--lf-color-selected-border);\n\tbackground-color: var(--lf-color-selected-bg);\n}\n\n.lf-picture-card img {\n\twidth: 100%;\n\taspect-ratio: 4/3;\n\tobject-fit: cover;\n}\n\n.lf-picture-card-label {\n\tpadding: 0.75rem;\n\ttext-align: center;\n\tfont-size: 0.875rem;\n}\n\n/* Welcome & Thank You Screens */\n.lf-screen {\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n\ttext-align: center;\n\tmin-height: 100vh;\n\tpadding: var(--lf-spacing-container);\n}\n\n.lf-screen-title {\n\tfont-family: var(--lf-font-question);\n\tfont-size: calc(var(--lf-font-size-question) * 1.25);\n\tfont-weight: var(--lf-font-weight-question);\n\tcolor: var(--lf-color-question);\n\tmargin: 0 0 1rem 0;\n}\n\n.lf-screen-description {\n\tfont-size: var(--lf-font-size-answer);\n\tcolor: var(--lf-color-answer);\n\topacity: 0.8;\n\tmargin: 0 0 2rem 0;\n\tmax-width: 480px;\n}\n\n/* Slider */\n.lf-slider {\n\twidth: 100%;\n\theight: 8px;\n\tappearance: none;\n\tbackground: var(--lf-color-progress-bg);\n\tborder-radius: var(--lf-border-radius);\n\toutline: none;\n}\n\n.lf-slider::-webkit-slider-thumb {\n\tappearance: none;\n\twidth: 24px;\n\theight: 24px;\n\tbackground: var(--lf-color-primary);\n\tborder-radius: 50%;\n\tcursor: pointer;\n}\n\n.lf-slider::-moz-range-thumb {\n\twidth: 24px;\n\theight: 24px;\n\tbackground: var(--lf-color-primary);\n\tborder-radius: 50%;\n\tcursor: pointer;\n\tborder: none;\n}\n\n/* Signature Canvas */\n.lf-signature-canvas {\n\tborder: var(--lf-border-width) var(--lf-border-style) var(--lf-color-input-border);\n\tborder-radius: var(--lf-border-radius);\n\tbackground-color: var(--lf-color-input-bg);\n\tcursor: crosshair;\n}\n\n/* ============================================================================\n Component Variants - Card Style Choices (Quiz Template)\n ============================================================================ */\n\n.lf-choice-card {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\twidth: 100%;\n\tpadding: 1rem 1.25rem;\n\tfont-family: var(--lf-font-answer);\n\tfont-size: var(--lf-font-size-answer);\n\tcolor: var(--lf-color-answer);\n\tbackground-color: var(--lf-color-surface);\n\tborder: none;\n\tborder-radius: var(--lf-border-radius);\n\tcursor: pointer;\n\ttransition: all var(--lf-transition-duration) var(--lf-transition-easing);\n\ttext-align: left;\n}\n\n.lf-choice-card:hover {\n\tbackground-color: var(--lf-color-input-bg);\n\ttransform: translateY(-1px);\n}\n\n.lf-choice-card-selected {\n\tbackground-color: var(--lf-color-selected-bg);\n\tcolor: var(--lf-color-button-text);\n}\n\n.lf-choice-card-selected:hover {\n\tbackground-color: var(--lf-color-selected-bg);\n\ttransform: none;\n}\n\n/* Circular indicator for card choices */\n.lf-choice-indicator {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\twidth: 24px;\n\theight: 24px;\n\tflex-shrink: 0;\n\ttransition: all var(--lf-transition-duration) var(--lf-transition-easing);\n}\n\n/* Checkmark indicator style (default) */\n.lf-choice-indicator-checkmark {\n\tborder-radius: 50%;\n\tborder: 2px solid var(--lf-color-input-border);\n}\n\n.lf-choice-card-selected .lf-choice-indicator-checkmark {\n\tbackground-color: var(--lf-color-button-text);\n\tborder-color: var(--lf-color-button-text);\n\tcolor: var(--lf-color-selected-bg);\n}\n\n/* Arrow indicator style - no border, SVG handles circle */\n.lf-choice-indicator svg {\n\twidth: 18px;\n\theight: 18px;\n}\n\n/* ============================================================================\n Component Variants - Bottom Bar Navigation (Quiz Template)\n ============================================================================ */\n\n.lf-navigation-bottom-bar {\n\tposition: fixed;\n\tbottom: 0;\n\tleft: 0;\n\tright: 0;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tgap: 1rem;\n\tpadding: 1.5rem var(--lf-spacing-container);\n\tbackground-color: var(--lf-color-background);\n}\n\n.lf-nav-btn-back {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 0.5rem;\n\tpadding: 0.875rem 1.5rem;\n\tfont-family: var(--lf-font-button);\n\tfont-size: var(--lf-font-size-button);\n\tfont-weight: var(--lf-font-weight-button);\n\tcolor: var(--lf-color-answer);\n\tbackground-color: var(--lf-color-background);\n\tborder: 1px solid var(--lf-color-input-border);\n\tborder-radius: var(--lf-border-radius);\n\tcursor: pointer;\n\ttransition: all var(--lf-transition-duration) var(--lf-transition-easing);\n}\n\n.lf-nav-btn-back:hover {\n\tbackground-color: var(--lf-color-surface);\n}\n\n.lf-nav-btn-back:disabled {\n\topacity: 0.4;\n\tcursor: not-allowed;\n}\n\n.lf-nav-btn-next {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 0.5rem;\n\tpadding: 0.875rem 2rem;\n\tfont-family: var(--lf-font-button);\n\tfont-size: var(--lf-font-size-button);\n\tfont-weight: var(--lf-font-weight-button);\n\tcolor: var(--lf-color-button-text);\n\tbackground-color: var(--lf-color-button-bg);\n\tborder: none;\n\tborder-radius: var(--lf-border-radius);\n\tcursor: pointer;\n\ttransition: all var(--lf-transition-duration) var(--lf-transition-easing);\n}\n\n.lf-nav-btn-next:hover {\n\tbackground-color: var(--lf-color-button-hover);\n}\n\n.lf-nav-btn-next:disabled {\n\topacity: 0.5;\n\tcursor: not-allowed;\n}\n\n/* ============================================================================\n Component Variants - Centered Header (Quiz Template)\n ============================================================================ */\n\n.lf-header-centered {\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tpadding: 1.5rem var(--lf-spacing-container);\n}\n\n.lf-header-logo {\n\tmax-height: 48px;\n\twidth: auto;\n}\n\n.lf-header-brand {\n\tmargin-top: 0.5rem;\n\tfont-size: 0.875rem;\n\tcolor: var(--lf-color-placeholder);\n}\n`.trim();\n}\n\n/**\n * Generate inline CSS string for SSR\n * Returns complete CSS that can be embedded in HTML\n */\nexport function generateThemeStyleTag(theme: FormTheme): string {\n\tconst cssVariables = generateThemeCSS(theme);\n\tconst componentStyles = generateComponentStyles();\n\n\treturn `${cssVariables}\\n\\n${componentStyles}`;\n}\n","import { generateThemeStyleTag } from \"./generateCSS\";\nimport type { FormTheme } from \"../types\";\n\nconst STYLE_ID = \"lf-form-theme-variables\";\nconst CUSTOM_STYLE_ID = \"lf-form-custom-css\";\n\n/**\n * SSR-safe check if we're in browser\n */\nexport function isBrowser(): boolean {\n\treturn typeof window !== \"undefined\" && typeof document !== \"undefined\";\n}\n\n/**\n * Inject theme CSS into document head (client-side only)\n * Returns a cleanup function\n */\nexport function injectThemeCSS(theme: FormTheme): () => void {\n\tif (!isBrowser()) {\n\t\treturn () => {}; // No-op for SSR\n\t}\n\n\tlet styleEl = document.getElementById(STYLE_ID) as HTMLStyleElement | null;\n\n\tif (!styleEl) {\n\t\tstyleEl = document.createElement(\"style\");\n\t\tstyleEl.id = STYLE_ID;\n\t\tdocument.head.appendChild(styleEl);\n\t}\n\n\tstyleEl.textContent = generateThemeStyleTag(theme);\n\n\t// Handle custom CSS\n\tif (theme.customCSS) {\n\t\tlet customStyleEl = document.getElementById(\n\t\t\tCUSTOM_STYLE_ID\n\t\t) as HTMLStyleElement | null;\n\t\tif (!customStyleEl) {\n\t\t\tcustomStyleEl = document.createElement(\"style\");\n\t\t\tcustomStyleEl.id = CUSTOM_STYLE_ID;\n\t\t\tdocument.head.appendChild(customStyleEl);\n\t\t}\n\t\tcustomStyleEl.textContent = theme.customCSS;\n\t}\n\n\t// Return cleanup function\n\treturn () => {\n\t\tconst el = document.getElementById(STYLE_ID);\n\t\tif (el) el.remove();\n\t\tconst customEl = document.getElementById(CUSTOM_STYLE_ID);\n\t\tif (customEl) customEl.remove();\n\t};\n}\n\n/**\n * Get theme CSS as a string for SSR injection\n */\nexport function getThemeCSSForSSR(theme: FormTheme): string {\n\treturn generateThemeStyleTag(theme);\n}\n"]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// src/api/client.ts
|
|
2
|
+
var LandformClient = class {
|
|
3
|
+
constructor(config) {
|
|
4
|
+
this.baseUrl = config.baseUrl || "";
|
|
5
|
+
this.projectId = config.projectId;
|
|
6
|
+
this.onError = config.onError;
|
|
7
|
+
}
|
|
8
|
+
async startResponse(params = {}) {
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch(`${this.baseUrl}/api/responses`, {
|
|
11
|
+
method: "POST",
|
|
12
|
+
headers: { "Content-Type": "application/json" },
|
|
13
|
+
body: JSON.stringify({
|
|
14
|
+
projectId: this.projectId,
|
|
15
|
+
sessionId: params.sessionId,
|
|
16
|
+
metadata: params.metadata,
|
|
17
|
+
hiddenFields: params.hiddenFields
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
const errorText = await response.text();
|
|
22
|
+
throw new Error(
|
|
23
|
+
`Failed to start response: ${response.status} ${errorText}`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return response.json();
|
|
27
|
+
} catch (error) {
|
|
28
|
+
this.onError?.(error);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async updateAnswers(params) {
|
|
33
|
+
try {
|
|
34
|
+
const response = await fetch(
|
|
35
|
+
`${this.baseUrl}/api/responses/${params.responseId}`,
|
|
36
|
+
{
|
|
37
|
+
method: "PATCH",
|
|
38
|
+
headers: {
|
|
39
|
+
"Content-Type": "application/json",
|
|
40
|
+
"x-session-id": params.sessionId
|
|
41
|
+
},
|
|
42
|
+
body: JSON.stringify({
|
|
43
|
+
answers: params.answers,
|
|
44
|
+
lastFieldRef: params.lastFieldRef,
|
|
45
|
+
calculatedValues: params.calculatedValues
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
const errorText = await response.text();
|
|
51
|
+
throw new Error(
|
|
52
|
+
`Failed to update answers: ${response.status} ${errorText}`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
this.onError?.(error);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async completeResponse(params) {
|
|
61
|
+
try {
|
|
62
|
+
const response = await fetch(
|
|
63
|
+
`${this.baseUrl}/api/responses/${params.responseId}/complete`,
|
|
64
|
+
{
|
|
65
|
+
method: "POST",
|
|
66
|
+
headers: {
|
|
67
|
+
"Content-Type": "application/json",
|
|
68
|
+
"x-session-id": params.sessionId
|
|
69
|
+
},
|
|
70
|
+
body: JSON.stringify({
|
|
71
|
+
answers: params.answers,
|
|
72
|
+
outcome: params.outcome,
|
|
73
|
+
calculatedValues: params.calculatedValues,
|
|
74
|
+
captchaToken: params.captchaToken
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
const errorText = await response.text();
|
|
80
|
+
throw new Error(
|
|
81
|
+
`Failed to complete response: ${response.status} ${errorText}`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
} catch (error) {
|
|
85
|
+
this.onError?.(error);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async trackEvent(params) {
|
|
90
|
+
try {
|
|
91
|
+
const response = await fetch(`${this.baseUrl}/api/analytics/track`, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers: { "Content-Type": "application/json" },
|
|
94
|
+
body: JSON.stringify({
|
|
95
|
+
projectId: this.projectId,
|
|
96
|
+
event: params.event,
|
|
97
|
+
sessionId: params.sessionId
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
if (!response.ok) {
|
|
101
|
+
console.warn(`Analytics tracking failed: ${response.status}`);
|
|
102
|
+
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.warn("Analytics tracking failed:", error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
function createClient(config) {
|
|
109
|
+
return new LandformClient(config);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { LandformClient, createClient };
|
|
113
|
+
//# sourceMappingURL=chunk-PKHTPGWQ.js.map
|
|
114
|
+
//# sourceMappingURL=chunk-PKHTPGWQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/client.ts"],"names":[],"mappings":";AA6CO,IAAM,iBAAN,MAAqB;AAAA,EAK3B,YAAY,MAAA,EAA8B;AACzC,IAAA,IAAA,CAAK,OAAA,GAAU,OAAO,OAAA,IAAW,EAAA;AACjC,IAAA,IAAA,CAAK,YAAY,MAAA,CAAO,SAAA;AACxB,IAAA,IAAA,CAAK,UAAU,MAAA,CAAO,OAAA;AAAA,EACvB;AAAA,EAEA,MAAM,aAAA,CACL,MAAA,GAA8B,EAAC,EACA;AAC/B,IAAA,IAAI;AACH,MAAA,MAAM,WAAW,MAAM,KAAA,CAAM,CAAA,EAAG,IA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A,EAEA,MAAM,WAAW,MAAA,EAAyC;AACzD,IAAA,IAAI;AACH,MAAA,MAAM,WAAW,MAAM,KAAA,CAAM,CAAA,EAAG,IAAA,CAAK,OAAO,CAAA,oBAAA,CAAA,EAAwB;AAAA,QACnE,MAAA,EAAQ,MAAA;AAAA,QACR,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAA,EAAmB;AAAA,QAC9C,IAAA,EAAM,KAAK,SAAA,CAAU;AAAA,UACpB,WAAW,IAAA,CAAK,SAAA;AAAA,UAChB,OAAO,MAAA,CAAO,KAAA;AAAA,UACd,WAAW,MAAA,CAAO;AAAA,SAClB;AAAA,OACD,CAAA;AAED,MAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAEjB,QAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,2BAAA,EAA8B,QAAA,CAAS,MAAM,CAAA,CAAE,CAAA;AAAA,MAC7D;AAAA,IACD,SAAS,KAAA,EAAO;AAEf,MAAA,OAAA,CAAQ,IAAA,CAAK,8BAA8B,KAAK,CAAA;AAAA,IACjD;AAAA,EACD;AACD;AAEO,SAAS,aAAa,MAAA,EAA8C;AAC1E,EAAA,OAAO,IAAI,eAAe,MAAM,CAAA;AACjC","file":"chunk-PKHTPGWQ.js","sourcesContent":["import type {\n\tResponseAnswers,\n\tResponseMetadata,\n\tResponseOutcome,\n} from \"../types\";\n\nexport interface LandformClientConfig {\n\tbaseUrl?: string;\n\tprojectId: string;\n\tonError?: (error: Error) => void;\n}\n\nexport interface StartResponseParams {\n\tsessionId?: string;\n\tmetadata?: ResponseMetadata;\n\thiddenFields?: Record<string, string>;\n}\n\nexport interface StartResponseResult {\n\tid: string;\n\tsessionId: string;\n}\n\nexport interface UpdateAnswersParams {\n\tresponseId: string;\n\tsessionId: string;\n\tanswers: ResponseAnswers;\n\tlastFieldRef?: string;\n\tcalculatedValues?: Record<string, number>;\n}\n\nexport interface CompleteResponseParams {\n\tresponseId: string;\n\tsessionId: string;\n\tanswers?: ResponseAnswers;\n\toutcome?: ResponseOutcome;\n\tcalculatedValues?: Record<string, number>;\n\tcaptchaToken?: string;\n}\n\nexport interface TrackEventParams {\n\tevent: \"view\" | \"start\";\n\tsessionId?: string;\n}\n\nexport class LandformClient {\n\tprivate baseUrl: string;\n\tprivate projectId: string;\n\tprivate onError?: (error: Error) => void;\n\n\tconstructor(config: LandformClientConfig) {\n\t\tthis.baseUrl = config.baseUrl || \"\";\n\t\tthis.projectId = config.projectId;\n\t\tthis.onError = config.onError;\n\t}\n\n\tasync startResponse(\n\t\tparams: StartResponseParams = {},\n\t): Promise<StartResponseResult> {\n\t\ttry {\n\t\t\tconst response = await fetch(`${this.baseUrl}/api/responses`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tprojectId: this.projectId,\n\t\t\t\t\tsessionId: params.sessionId,\n\t\t\t\t\tmetadata: params.metadata,\n\t\t\t\t\thiddenFields: params.hiddenFields,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorText = await response.text();\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to start response: ${response.status} ${errorText}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn response.json();\n\t\t} catch (error) {\n\t\t\tthis.onError?.(error as Error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync updateAnswers(params: UpdateAnswersParams): Promise<void> {\n\t\ttry {\n\t\t\tconst response = await fetch(\n\t\t\t\t`${this.baseUrl}/api/responses/${params.responseId}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: \"PATCH\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t\t\"x-session-id\": params.sessionId,\n\t\t\t\t\t},\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tanswers: params.answers,\n\t\t\t\t\t\tlastFieldRef: params.lastFieldRef,\n\t\t\t\t\t\tcalculatedValues: params.calculatedValues,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorText = await response.text();\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to update answers: ${response.status} ${errorText}`,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.onError?.(error as Error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync completeResponse(params: CompleteResponseParams): Promise<void> {\n\t\ttry {\n\t\t\tconst response = await fetch(\n\t\t\t\t`${this.baseUrl}/api/responses/${params.responseId}/complete`,\n\t\t\t\t{\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t\t\"x-session-id\": params.sessionId,\n\t\t\t\t\t},\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tanswers: params.answers,\n\t\t\t\t\t\toutcome: params.outcome,\n\t\t\t\t\t\tcalculatedValues: params.calculatedValues,\n\t\t\t\t\t\tcaptchaToken: params.captchaToken,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorText = await response.text();\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to complete response: ${response.status} ${errorText}`,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.onError?.(error as Error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync trackEvent(params: TrackEventParams): Promise<void> {\n\t\ttry {\n\t\t\tconst response = await fetch(`${this.baseUrl}/api/analytics/track`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tprojectId: this.projectId,\n\t\t\t\t\tevent: params.event,\n\t\t\t\t\tsessionId: params.sessionId,\n\t\t\t\t}),\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\t// Silently fail for tracking - don't interrupt user experience\n\t\t\t\tconsole.warn(`Analytics tracking failed: ${response.status}`);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Silently fail for tracking - don't interrupt user experience\n\t\t\tconsole.warn(\"Analytics tracking failed:\", error);\n\t\t}\n\t}\n}\n\nexport function createClient(config: LandformClientConfig): LandformClient {\n\treturn new LandformClient(config);\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/theme/utils.ts
|
|
2
|
+
function hexToRgb(hex) {
|
|
3
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
4
|
+
return result ? {
|
|
5
|
+
r: parseInt(result[1], 16),
|
|
6
|
+
g: parseInt(result[2], 16),
|
|
7
|
+
b: parseInt(result[3], 16)
|
|
8
|
+
} : null;
|
|
9
|
+
}
|
|
10
|
+
function rgbToHex(r, g, b) {
|
|
11
|
+
return "#" + [r, g, b].map((x) => {
|
|
12
|
+
const hex = Math.max(0, Math.min(255, Math.round(x))).toString(16);
|
|
13
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
14
|
+
}).join("");
|
|
15
|
+
}
|
|
16
|
+
function darken(color, amount) {
|
|
17
|
+
const rgb = hexToRgb(color);
|
|
18
|
+
if (!rgb) return color;
|
|
19
|
+
return rgbToHex(
|
|
20
|
+
rgb.r * (1 - amount),
|
|
21
|
+
rgb.g * (1 - amount),
|
|
22
|
+
rgb.b * (1 - amount)
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
function lighten(color, amount) {
|
|
26
|
+
const rgb = hexToRgb(color);
|
|
27
|
+
if (!rgb) return color;
|
|
28
|
+
return rgbToHex(
|
|
29
|
+
rgb.r + (255 - rgb.r) * amount,
|
|
30
|
+
rgb.g + (255 - rgb.g) * amount,
|
|
31
|
+
rgb.b + (255 - rgb.b) * amount
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function adjustOpacity(color, opacity) {
|
|
35
|
+
const rgb = hexToRgb(color);
|
|
36
|
+
if (!rgb) return color;
|
|
37
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${opacity})`;
|
|
38
|
+
}
|
|
39
|
+
function getContrastColor(backgroundColor) {
|
|
40
|
+
const rgb = hexToRgb(backgroundColor);
|
|
41
|
+
if (!rgb) return "#000000";
|
|
42
|
+
const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
|
|
43
|
+
return luminance > 0.5 ? "#000000" : "#FFFFFF";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { adjustOpacity, darken, getContrastColor, hexToRgb, lighten, rgbToHex };
|
|
47
|
+
//# sourceMappingURL=chunk-V7WAYO2Q.js.map
|
|
48
|
+
//# sourceMappingURL=chunk-V7WAYO2Q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theme/utils.ts"],"names":[],"mappings":";AAOO,SAAS,SAAS,GAAA,EAAyD;AACjF,EAAA,MAAM,MAAA,GAAS,2CAAA,CAA4C,IAAA,CAAK,GAAG,CAAA;AACnE,EAAA,OAAO,MAAA,GACJ;AAAA,IACA,CAAA,EAAG,QAAA,CAAS,MAAA,CAAO,CAAC,GAAG,EAAE,CAAA;AAAA,IACzB,CAAA,EAAG,QAAA,CAAS,MAAA,CAAO,CAAC,GAAG,EAAE,CAAA;AAAA,IACzB,CAAA,EAAG,QAAA,CAAS,MAAA,CAAO,CAAC,GAAG,EAAE;AAAA,GAC1B,GACC,IAAA;AACJ;AAKO,SAAS,QAAA,CAAS,CAAA,EAAW,CAAA,EAAW,CAAA,EAAmB;AACjE,EAAA,OACC,GAAA,GACA,CAAC,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,CACN,GAAA,CAAI,CAAC,CAAA,KAAM;AACX,IAAA,MAAM,GAAA,GAAM,IAAA,CAAK,GAAA,CAAI,CAAA,EA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AAA,EAAA,EAAK,GAAA,CAAI,CAAC,CAAA,EAAA,EAAK,OAAO,CAAA,CAAA,CAAA;AACrD;AAKO,SAAS,iBAAiB,eAAA,EAAiC;AACjE,EAAA,MAAM,GAAA,GAAM,SAAS,eAAe,CAAA;AACpC,EAAA,IAAI,CAAC,KAAK,OAAO,SAAA;AAGjB,EAAA,MAAM,SAAA,GAAA,CAAa,QAAQ,GAAA,CAAI,CAAA,GAAI,QAAQ,GAAA,CAAI,CAAA,GAAI,KAAA,GAAQ,GAAA,CAAI,CAAA,IAAK,GAAA;AACpE,EAAA,OAAO,SAAA,GAAY,MAAM,SAAA,GAAY,SAAA;AACtC","file":"chunk-V7WAYO2Q.js","sourcesContent":["// ============================================================================\n// Color Manipulation Utilities\n// ============================================================================\n\n/**\n * Parse hex color to RGB components\n */\nexport function hexToRgb(hex: string): { r: number; g: number; b: number } | null {\n\tconst result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\treturn result\n\t\t? {\n\t\t\t\tr: parseInt(result[1], 16),\n\t\t\t\tg: parseInt(result[2], 16),\n\t\t\t\tb: parseInt(result[3], 16),\n\t\t\t}\n\t\t: null;\n}\n\n/**\n * Convert RGB to hex\n */\nexport function rgbToHex(r: number, g: number, b: number): string {\n\treturn (\n\t\t\"#\" +\n\t\t[r, g, b]\n\t\t\t.map((x) => {\n\t\t\t\tconst hex = Math.max(0, Math.min(255, Math.round(x))).toString(16);\n\t\t\t\treturn hex.length === 1 ? \"0\" + hex : hex;\n\t\t\t})\n\t\t\t.join(\"\")\n\t);\n}\n\n/**\n * Darken a color by a percentage (0-1)\n */\nexport function darken(color: string, amount: number): string {\n\tconst rgb = hexToRgb(color);\n\tif (!rgb) return color;\n\n\treturn rgbToHex(\n\t\trgb.r * (1 - amount),\n\t\trgb.g * (1 - amount),\n\t\trgb.b * (1 - amount)\n\t);\n}\n\n/**\n * Lighten a color by a percentage (0-1)\n */\nexport function lighten(color: string, amount: number): string {\n\tconst rgb = hexToRgb(color);\n\tif (!rgb) return color;\n\n\treturn rgbToHex(\n\t\trgb.r + (255 - rgb.r) * amount,\n\t\trgb.g + (255 - rgb.g) * amount,\n\t\trgb.b + (255 - rgb.b) * amount\n\t);\n}\n\n/**\n * Adjust opacity of a color, returning rgba string\n */\nexport function adjustOpacity(color: string, opacity: number): string {\n\tconst rgb = hexToRgb(color);\n\tif (!rgb) return color;\n\n\treturn `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${opacity})`;\n}\n\n/**\n * Calculate contrasting text color (black or white)\n */\nexport function getContrastColor(backgroundColor: string): string {\n\tconst rgb = hexToRgb(backgroundColor);\n\tif (!rgb) return \"#000000\";\n\n\t// Calculate relative luminance\n\tconst luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;\n\treturn luminance > 0.5 ? \"#000000\" : \"#FFFFFF\";\n}\n"]}
|