klip-components 0.6.2 → 0.7.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.
|
@@ -83,8 +83,11 @@ const Input = (_c) => {
|
|
|
83
83
|
suffix,
|
|
84
84
|
helperText,
|
|
85
85
|
className,
|
|
86
|
+
labelClass,
|
|
87
|
+
helperTextClass,
|
|
86
88
|
onChange,
|
|
87
|
-
id
|
|
89
|
+
id,
|
|
90
|
+
hasError
|
|
88
91
|
} = _d, props = __objRest(_d, [
|
|
89
92
|
"variant",
|
|
90
93
|
"type",
|
|
@@ -93,26 +96,38 @@ const Input = (_c) => {
|
|
|
93
96
|
"suffix",
|
|
94
97
|
"helperText",
|
|
95
98
|
"className",
|
|
99
|
+
"labelClass",
|
|
100
|
+
"helperTextClass",
|
|
96
101
|
"onChange",
|
|
97
|
-
"id"
|
|
102
|
+
"id",
|
|
103
|
+
"hasError"
|
|
98
104
|
]);
|
|
99
105
|
const generatedId = React.useId();
|
|
100
106
|
const inputId = id || `input-${generatedId}`;
|
|
101
107
|
const handleChange = (e) => onChange == null ? void 0 : onChange(e.target.value);
|
|
108
|
+
const hasPrefix = !!prefix;
|
|
109
|
+
const hasSuffix = !!suffix;
|
|
102
110
|
const combinedClass = cn(
|
|
103
111
|
"form-field",
|
|
104
|
-
{ prefix:
|
|
112
|
+
{ "has-prefix": hasPrefix, "has-suffix": hasSuffix },
|
|
105
113
|
{ [`variant-${variant}`]: variant },
|
|
106
114
|
className
|
|
107
115
|
);
|
|
108
116
|
return /* @__PURE__ */ jsxs("article", { className: "input-container", children: [
|
|
109
|
-
label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "input-label", children: label }),
|
|
117
|
+
label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: cn("input-label", labelClass), children: label }),
|
|
110
118
|
/* @__PURE__ */ jsxs("section", { className: "input-wrapper", children: [
|
|
111
|
-
prefix && /* @__PURE__ */ jsx("article", { className: "input-
|
|
119
|
+
prefix && /* @__PURE__ */ jsx("article", { className: "input-prefix", children: prefix }),
|
|
112
120
|
/* @__PURE__ */ jsx("input", __spreadValues({ id: inputId, type, className: combinedClass, onChange: handleChange }, props)),
|
|
113
|
-
suffix && /* @__PURE__ */ jsx("article", { className: "input-
|
|
121
|
+
suffix && /* @__PURE__ */ jsx("article", { className: "input-suffix", children: suffix })
|
|
114
122
|
] }),
|
|
115
|
-
helperText && /* @__PURE__ */ jsx(
|
|
123
|
+
helperText && /* @__PURE__ */ jsx(
|
|
124
|
+
"small",
|
|
125
|
+
{
|
|
126
|
+
className: cn("input-helper-text", helperTextClass),
|
|
127
|
+
style: { color: hasError ? "var(--color-danger)" : "inherit" },
|
|
128
|
+
children: helperText
|
|
129
|
+
}
|
|
130
|
+
)
|
|
116
131
|
] });
|
|
117
132
|
};
|
|
118
133
|
const Toggle = (_e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react/jsx-runtime"),require("react")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).KlipComponents={},e.React,e.React)}(this,function(e,r,t){"use strict";var n=Object.defineProperty,a=Object.defineProperties,s=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,o=(e,r,t)=>r in e?n(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,u=(e,r)=>{for(var t in r||(r={}))i.call(r,t)&&o(e,t,r[t]);if(l)for(var t of l(r))c.call(r,t)&&o(e,t,r[t]);return e},d=(e,r)=>{var t={};for(var n in e)i.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&l)for(var n of l(e))r.indexOf(n)<0&&c.call(e,n)&&(t[n]=e[n]);return t};function p(e){var r,t,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var a=e.length;for(r=0;r<a;r++)e[r]&&(t=p(e[r]))&&(n&&(n+=" "),n+=t)}else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function f(){for(var e,r,t=0,n="",a=arguments.length;t<a;t++)(e=arguments[t])&&(r=p(e))&&(n&&(n+=" "),n+=r);return n}function h(...e){const r=e.join(" ").split(" ").filter(Boolean);return[...new Set(r)].join(" ")}function b(...e){return h(f(...e))}e.Button=e=>{var t,n=e,{variant:l="primary",size:i="md",startIcon:c,endIcon:o,className:p="",children:f}=n,h=d(n,["variant","size","startIcon","endIcon","className","children"]);return r.jsxs("button",(t=u({className:b("rounded btn",`btn-${l}`,`btn-${i}`,p)},h),a(t,s({children:[c&&r.jsx("span",{className:"btn-icon-start",children:c}),f,o&&r.jsx("span",{className:"btn-icon-end",children:o})]}))))},e.ButtonSelect=({options:e,value:t,onChange:n,disabled:a=!1,multiple:s=!1})=>{const l=e=>Array.isArray(t)?t.includes(e):e===t;return r.jsx("div",{className:"button-select "+(a?"disabled":""),children:e.map(({value:e,child:i})=>r.jsx("button",{className:"button-select-option "+(l(e)?"selected":""),onClick:()=>(e=>{if(a)return;if(!s)return void n(e);const r=Array.isArray(t)?t:[],l=r.includes(e)?r.filter(r=>r!==e):[...r,e];n(l)})(e),disabled:a,type:"button",children:i},e))})},e.Input=e=>{var n=e,{variant:a="primary",type:s="text",label:l,prefix:i,suffix:c,helperText:o,className:p,labelClass:f,helperTextClass:h,onChange:m,id:x,hasError:y}=n,j=d(n,["variant","type","label","prefix","suffix","helperText","className","labelClass","helperTextClass","onChange","id","hasError"]);const v=t.useId(),g=x||`input-${v}`,N=b("form-field",{"has-prefix":!!i,"has-suffix":!!c},{[`variant-${a}`]:a},p);return r.jsxs("article",{className:"input-container",children:[l&&r.jsx("label",{htmlFor:g,className:b("input-label",f),children:l}),r.jsxs("section",{className:"input-wrapper",children:[i&&r.jsx("article",{className:"input-prefix",children:i}),r.jsx("input",u({id:g,type:s,className:N,onChange:e=>null==m?void 0:m(e.target.value)},j)),c&&r.jsx("article",{className:"input-suffix",children:c})]}),o&&r.jsx("small",{className:b("input-helper-text",h),style:{color:y?"var(--color-danger)":"inherit"},children:o})]})},e.Toggle=e=>{var t=e,{color:n="var(--color-primary)",size:a="3.75rem",checked:s=!1,onChange:l,label:i,labelPosition:c="right",className:o}=t,p=d(t,["color","size","checked","onChange","label","labelPosition","className"]);return r.jsxs("label",{className:b("switch-container",c,o),children:[r.jsxs("div",{className:"toggle-switch",style:{"--switch-size":a,"--switch-color":n},children:[r.jsx("input",u({type:"checkbox",role:"switch",checked:s,onChange:e=>null==l?void 0:l(e.target.checked)},p)),r.jsx("span",{className:"slider"})]}),i&&r.jsx("span",{className:"switch-label",children:i})]})},e.clsx=f,e.cn=b,e.mergeClasses=h,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "klip-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"description": "A collection of reusable React components for Klip.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/klip-components.cjs.js",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@eslint/js": "^9.30.1",
|
|
57
|
-
"@storybook/addon-docs": "^9.
|
|
58
|
-
"@storybook/addon-onboarding": "^9.
|
|
59
|
-
"@storybook/react-vite": "^9.
|
|
57
|
+
"@storybook/addon-docs": "^9.1.2",
|
|
58
|
+
"@storybook/addon-onboarding": "^9.1.2",
|
|
59
|
+
"@storybook/react-vite": "^9.1.2",
|
|
60
60
|
"@types/node": "^24.0.13",
|
|
61
61
|
"@types/react": "^19.1.8",
|
|
62
62
|
"@types/react-dom": "^19.1.6",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"eslint": "^9.30.1",
|
|
68
68
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
69
69
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
70
|
-
"eslint-plugin-storybook": "^9.
|
|
70
|
+
"eslint-plugin-storybook": "^9.1.2",
|
|
71
71
|
"globals": "^16.3.0",
|
|
72
72
|
"postcss": "^8.5.6",
|
|
73
73
|
"postcss-cli": "^11.0.1",
|
|
74
|
-
"storybook": "^9.
|
|
74
|
+
"storybook": "^9.1.2",
|
|
75
75
|
"terser": "^5.43.1",
|
|
76
76
|
"typescript": "~5.8.3",
|
|
77
77
|
"typescript-eslint": "^8.35.1",
|