@charcoal-ui/react 1.0.0-alpha.1 → 2.0.0-alpha.1
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/README.md +0 -1
- package/dist/_lib/compat.d.ts +14 -0
- package/dist/_lib/compat.d.ts.map +1 -0
- package/dist/_lib/index.d.ts +26 -0
- package/dist/_lib/index.d.ts.map +1 -0
- package/dist/components/Button/index.d.ts +22 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/components/Button/index.story.d.ts +36 -0
- package/dist/components/Button/index.story.d.ts.map +1 -0
- package/dist/components/Clickable/index.d.ts +19 -0
- package/dist/components/Clickable/index.d.ts.map +1 -0
- package/dist/components/Clickable/index.story.d.ts +9 -0
- package/dist/components/Clickable/index.story.d.ts.map +1 -0
- package/dist/components/FieldLabel/index.d.ts +11 -0
- package/dist/components/FieldLabel/index.d.ts.map +1 -0
- package/dist/components/IconButton/index.d.ts +14 -0
- package/dist/components/IconButton/index.d.ts.map +1 -0
- package/dist/components/IconButton/index.story.d.ts +29 -0
- package/dist/components/IconButton/index.story.d.ts.map +1 -0
- package/dist/components/Radio/index.d.ts +24 -0
- package/dist/components/Radio/index.d.ts.map +1 -0
- package/dist/components/Radio/index.story.d.ts +34 -0
- package/dist/components/Radio/index.story.d.ts.map +1 -0
- package/dist/components/Radio/index.test.d.ts +2 -0
- package/dist/components/Radio/index.test.d.ts.map +1 -0
- package/dist/components/Select/context.d.ts +14 -0
- package/dist/components/Select/context.d.ts.map +1 -0
- package/dist/components/Select/index.d.ts +24 -0
- package/dist/components/Select/index.d.ts.map +1 -0
- package/dist/components/Select/index.story.d.ts +75 -0
- package/dist/components/Select/index.story.d.ts.map +1 -0
- package/dist/components/Select/index.test.d.ts +2 -0
- package/dist/components/Select/index.test.d.ts.map +1 -0
- package/dist/components/Switch/index.d.ts +16 -0
- package/dist/components/Switch/index.d.ts.map +1 -0
- package/dist/components/Switch/index.story.d.ts +14 -0
- package/dist/components/Switch/index.story.d.ts.map +1 -0
- package/dist/components/TextField/index.d.ts +41 -0
- package/dist/components/TextField/index.d.ts.map +1 -0
- package/dist/components/TextField/index.story.d.ts +29 -0
- package/dist/components/TextField/index.story.d.ts.map +1 -0
- package/dist/components/a11y.test.d.ts +2 -0
- package/dist/components/a11y.test.d.ts.map +1 -0
- package/dist/core/ComponentAbstraction.d.ts +24 -0
- package/dist/core/ComponentAbstraction.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.modern.js +347 -0
- package/dist/index.modern.js.map +1 -0
- package/dist/index.module.js +2 -0
- package/dist/index.module.js.map +1 -0
- package/dist/styled.d.ts +85 -0
- package/dist/styled.d.ts.map +1 -0
- package/package.json +12 -7
- package/src/_lib/compat.ts +1 -4
- package/src/components/IconButton/index.tsx +1 -0
- package/src/components/Radio/index.story.tsx +16 -17
- package/src/components/Radio/index.test.tsx +16 -18
- package/src/components/Radio/index.tsx +4 -7
- package/src/components/Select/context.ts +23 -0
- package/src/components/Select/index.story.tsx +153 -0
- package/src/components/Select/index.test.tsx +281 -0
- package/src/components/Select/index.tsx +210 -0
- package/src/components/TextField/index.story.tsx +10 -0
- package/src/components/TextField/index.tsx +105 -23
- package/src/components/a11y.test.tsx +33 -26
- package/src/index.ts +12 -1
- package/src/type.d.ts +1 -5
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=require("react"),n=require("styled-components"),t=require("@charcoal-ui/styled"),r=require("@charcoal-ui/utils"),a=require("warning"),i=require("@react-aria/switch"),o=require("react-stately"),l=require("@react-aria/textfield"),u=require("@react-aria/visually-hidden");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=/*#__PURE__*/d(e),c=/*#__PURE__*/d(n),f=/*#__PURE__*/d(t),p=/*#__PURE__*/d(a);function h(){return h=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},h.apply(this,arguments)}function v(e,n){if(null==e)return{};var t,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(t=i[r])>=0||(a[t]=e[t]);return a}function b(e,n){return n||(n=e.slice(0)),e.raw=n,e}function g(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function x(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return g(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?g(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var m=["to","children"],y={Link:s.default.forwardRef(function(e,n){var t=e.to,r=e.children,a=v(e,m);/*#__PURE__*/return s.default.createElement("a",h({href:t,ref:n},a),r)})},w=s.default.createContext(y);function E(){return e.useContext(w)}var C,k,S,R,P,z,q,L,T,O,N,D,M,H,j,A,F,I,G,B,X,V,Y,J,U,$,K,Q,W,Z,_,ee,ne,te,re,ae=f.default(c.default),ie=["onClick","disabled"],oe=s.default.forwardRef(function(e,n){var t=E().Link;if("to"in e){var r=e.onClick,a=e.disabled,i=void 0!==a&&a,o=v(e,ie);/*#__PURE__*/return s.default.createElement(de,h({},o,{as:i?void 0:t,onClick:i?void 0:r,"aria-disabled":i,ref:n}))}/*#__PURE__*/return s.default.createElement(ue,h({},e,{ref:n}))}),le=n.css(C||(C=b(["\n /* Clickable style */\n cursor: pointer;\n\n "," {\n cursor: default;\n }\n"])),r.disabledSelector),ue=c.default.button(k||(k=b(["\n /* Reset button appearance */\n appearance: none;\n background: transparent;\n padding: 0;\n border-style: none;\n outline: none;\n color: inherit;\n text-rendering: inherit;\n letter-spacing: inherit;\n word-spacing: inherit;\n\n &:focus {\n outline: none;\n }\n\n /* Change the font styles in all browsers. */\n font: inherit;\n\n /* Remove the margin in Firefox and Safari. */\n margin: 0;\n\n /* Show the overflow in Edge. */\n overflow: visible;\n\n /* Remove the inheritance of text transform in Firefox. */\n text-transform: none;\n\n /* Remove the inner border and padding in Firefox. */\n &::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n ","\n"])),le),de=c.default.span(S||(S=b(["\n /* Reset a-tag appearance */\n color: inherit;\n\n &:focus {\n outline: none;\n }\n\n .text {\n top: calc(1em + 2em);\n }\n\n ","\n"])),le),se=["children","variant","size","fixed","disabled"],ce=s.default.forwardRef(function(e,n){var t=e.children,r=e.variant,a=void 0===r?"Default":r,i=e.size,o=void 0===i?"M":i,l=e.fixed,u=void 0!==l&&l,d=e.disabled,c=void 0!==d&&d,f=v(e,se);/*#__PURE__*/return s.default.createElement(fe,h({},f,{disabled:c,variant:a,size:o,fixed:u,ref:n}),t)}),fe=c.default(oe).withConfig({shouldForwardProp:function(e){return"fixed"!==e}}).attrs(function(e){return h({},e,function(e){switch(e){case"Overlay":return{font:"text5",background:"surface4"};case"Default":return{font:"text2",background:"surface3"};case"Primary":return{font:"text5",background:"brand"};case"Navigation":return{font:"text5",background:"surface6"};case"Danger":return{font:"text5",background:"assertive"};default:return function(e){throw new Error(0===arguments.length?"unreachable":"unreachable ("+JSON.stringify(e)+")")}(e)}}(e.variant),function(e){switch(e){case"S":return{height:32,padding:16};case"M":return{height:40,padding:24}}}(e.size))})(R||(R=b(["\n width: ",";\n display: inline-grid;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n user-select: none;\n white-space: nowrap;\n\n ","\n\n /* よく考えたらheight=32って定義が存在しないな... */\n height: ","px;\n"])),function(e){return e.fixed?"stretch":"min-content"},function(e){return ae(function(n){return[n.font[e.font].hover.press,n.bg[e.background].hover.press,n.typography(14).bold.preserveHalfLeading,n.padding.horizontal(e.padding),n.disabled,n.borderRadius("oval"),n.outline.default.focus]})},function(e){return e.height}),pe=["variant","size","icon"],he=s.default.forwardRef(function(e,n){var t=e.variant,r=void 0===t?"Default":t,a=e.size,i=void 0===a?"M":a,o=e.icon,l=v(e,pe);return function(e,n){var t;switch(e){case"XS":t="16";break;case"S":case"M":t="24"}var r=/^[0-9]*/.exec(n);if(null==r)throw new Error("Invalid icon name");var a=r[0];a!==t&&console.warn('IconButton with size "'+e+'" expect icon size "'+t+', but got "'+a+'"')}(i,o),/*#__PURE__*/s.default.createElement(ve,h({},l,{ref:n,variant:r,size:i}),/*#__PURE__*/s.default.createElement("pixiv-icon",{name:o}))}),ve=c.default(oe).attrs(function(e){return h({},e,function(e){switch(e){case"Default":return{font:"text3",background:"transparent"};case"Overlay":return{font:"text5",background:"surface4"}}}(e.variant),function(e){switch(e){case"XS":return{width:20,height:20};case"S":return{width:32,height:32};case"M":return{width:40,height:40}}}(e.size))})(P||(P=b(["\n user-select: none;\n\n width: ","px;\n height: ","px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ","\n"])),function(e){return e.width},function(e){return e.height},function(e){var n=e.font,t=e.background;return ae(function(e){return[e.font[n],e.bg[t].hover.press,e.disabled,e.borderRadius("oval"),e.outline.default.focus]})}),be=c.default.label(z||(z=b(["\n display: grid;\n grid-template-columns: auto 1fr;\n grid-gap: ",";\n align-items: center;\n cursor: pointer;\n\n ","\n"])),function(e){return r.px(e.theme.spacing[4])},ae(function(e){return[e.disabled]})),ge=c.default.input.attrs({type:"radio"})(q||(q=b(["\n /** Make prior to browser default style */\n &[type='radio'] {\n appearance: none;\n display: block;\n box-sizing: border-box;\n\n padding: 6px;\n\n width: 20px;\n height: 20px;\n\n ",";\n\n &:not(:checked) {\n border-width: 2px;\n border-style: solid;\n border-color: ",";\n }\n\n &:checked {\n ","\n\n &::after {\n content: '';\n display: block;\n width: 8px;\n height: 8px;\n pointer-events: none;\n\n ","\n }\n }\n\n ","\n }\n"])),function(e){var n=e.hasError,t=void 0!==n&&n;return ae(function(e){return[e.borderRadius("oval"),e.bg.text5.hover.press,t&&e.outline.assertive]})},function(e){return e.theme.color.text4},ae(function(e){return e.bg.brand.hover.press}),ae(function(e){return[e.bg.text5.hover.press,e.borderRadius("oval")]}),ae(function(e){return e.outline.default.focus})),xe=c.default.div(L||(L=b(["\n ","\n"])),ae(function(e){return[e.typography(14)]})),me=c.default.div(T||(T=b(["\n display: grid;\n grid-template-columns: 1fr;\n grid-gap: ",";\n"])),function(e){return r.px(e.theme.spacing[8])}),ye=s.default.createContext({name:void 0,selected:void 0,disabled:!1,readonly:!1,hasError:!1,onChange:function(){throw new Error("Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?")}}),we=e.createContext({name:void 0,selected:[],disabled:!1,readonly:!1,hasError:!1,onChange:function(){throw new Error("Cannot find `onChange()` handler. Perhaps you forgot to wrap it with `<SelectGroup />` ?")}}),Ee=c.default.label(O||(O=b(["\n display: grid;\n grid-template-columns: auto 1fr;\n align-items: center;\n position: relative;\n cursor: pointer;\n "," {\n cursor: default;\n }\n gap: ",";\n ","\n"])),r.disabledSelector,function(e){return r.px(e.theme.spacing[4])},ae(function(e){return e.disabled})),Ce=c.default.div(N||(N=b(["\n display: flex;\n align-items: center;\n ","\n"])),ae(function(e){return[e.typography(14),e.font.text1]})),ke=c.default.input.attrs({type:"checkbox"})(D||(D=b(["\n &[type='checkbox'] {\n appearance: none;\n display: block;\n width: 20px;\n height: 20px;\n margin: 0;\n\n &:checked {\n ","\n }\n\n ",";\n }\n"])),ae(function(e){return e.bg.brand.hover.press}),function(e){var n=e.hasError,t=e.overlay;return ae(function(e){return[e.bg.text3.hover.press,e.borderRadius("oval"),n&&!t&&e.outline.assertive,t&&e.bg.surface4]})}),Se=c.default.div(M||(M=b(["\n position: absolute;\n top: -2px;\n left: -2px;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ","\n\n ","\n"])),function(e){var n=e.hasError,t=e.overlay;return ae(function(e){return[e.width.px(24),e.height.px(24),e.borderRadius("oval"),e.font.text5,n&&t&&e.outline.assertive]})},function(e){return e.overlay&&n.css(H||(H=b(["\n border-color: ",";\n border-width: 2px;\n border-style: solid;\n "])),function(e){return e.theme.color.text5})}),Re=["className","type"],Pe=c.default.label(j||(j=b(["\n display: inline-grid;\n grid-template-columns: auto 1fr;\n gap: ",";\n cursor: pointer;\n outline: 0;\n\n ","\n\n "," {\n cursor: default;\n }\n"])),function(e){return r.px(e.theme.spacing[4])},ae(function(e){return e.disabled}),r.disabledSelector),ze=c.default.div(A||(A=b(["\n ","\n"])),ae(function(e){return e.typography(14)})),qe=c.default.input.attrs({type:"checkbox"})(F||(F=b(["\n &[type='checkbox'] {\n appearance: none;\n display: inline-flex;\n position: relative;\n box-sizing: border-box;\n width: 28px;\n border: 2px solid transparent;\n transition: box-shadow 0.2s, background-color 0.2s;\n cursor: inherit;\n ","\n\n &::after {\n content: '';\n position: absolute;\n display: block;\n top: 0;\n left: 0;\n width: 12px;\n height: 12px;\n transform: translateX(0);\n transition: transform 0.2s;\n ","\n }\n\n &:checked {\n ","\n\n &::after {\n transform: translateX(12px);\n }\n }\n }\n"])),ae(function(e){return[e.borderRadius(16),e.height.px(16),e.bg.text4.hover.press,e.outline.default.focus]}),ae(function(e){return[e.bg.text5.hover.press,e.borderRadius("oval")]}),ae(function(e){return e.bg.brand.hover.press})),Le=["style","className","label","required","requiredText","subLabel"],Te=s.default.forwardRef(function(e,n){var t=e.style,r=e.className,a=e.label,i=e.required,o=void 0!==i&&i,l=e.requiredText,u=e.subLabel,d=v(e,Le);/*#__PURE__*/return s.default.createElement(He,{style:t,className:r},/*#__PURE__*/s.default.createElement(Ne,h({ref:n},d),a),o&&/*#__PURE__*/s.default.createElement(De,null,l),/*#__PURE__*/s.default.createElement(Me,null,/*#__PURE__*/s.default.createElement("span",null,u)))}),Oe=f.default(c.default),Ne=c.default.label(I||(I=b(["\n ","\n"])),Oe(function(e){return[e.typography(14).bold,e.font.text1]})),De=c.default.span(G||(G=b(["\n ","\n"])),Oe(function(e){return[e.typography(14),e.font.text3]})),Me=c.default.div(B||(B=b(["\n ","\n"])),Oe(function(e){return[e.typography(14),e.font.text3.hover.press,e.outline.default.focus]})),He=c.default.div(X||(X=b(["\n display: inline-flex;\n align-items: center;\n\n > "," {\n ","\n }\n\n > "," {\n ","\n }\n"])),De,Oe(function(e){return e.margin.left(4)}),Me,Oe(function(e){return e.margin.left("auto")})),je=["onChange"],Ae=["onChange"],Fe=f.default(c.default);function Ie(){var e=arguments;return function(n){for(var t,r=x([].slice.call(e));!(t=r()).done;){var a=t.value;"function"==typeof a?a(n):null!==a&&(a.current=n)}}}function Ge(e){return Array.from(e).length}var Be=s.default.forwardRef(function(e,n){/*#__PURE__*/return s.default.createElement(void 0!==e.multiline&&e.multiline?Ve:Xe,h({ref:n},e))}),Xe=s.default.forwardRef(function(n,t){var r,a=n.onChange,i=v(n,je),o=i.className,d=i.showLabel,c=void 0!==d&&d,f=i.showCount,p=void 0!==f&&f,b=i.label,g=i.requiredText,x=i.subLabel,m=i.disabled,y=void 0!==m&&m,w=i.required,E=i.invalid,C=void 0!==E&&E,k=i.assistiveText,S=i.maxLength,R=i.prefix,P=void 0===R?"":R,z=i.suffix,q=void 0===z?"":z,L=u.useVisuallyHidden().visuallyHiddenProps,T=e.useRef(null),O=e.useRef(null),N=e.useRef(null),D=e.useState(Ge(null!=(r=i.value)?r:"")),M=D[0],H=D[1],j=e.useState(0),A=j[0],F=j[1],I=e.useState(0),G=I[0],B=I[1],X=void 0===i.value,V=e.useCallback(function(e){var n=Ge(e);void 0!==S&&n>S||(X&&H(n),null==a||a(e))},[S,X,a]);e.useEffect(function(){var e;H(Ge(null!=(e=i.value)?e:""))},[i.value]);var Y=l.useTextField(h({inputElementType:"input",isDisabled:y,isRequired:w,validationState:C?"invalid":"valid",description:!C&&k,errorMessage:C&&k,onChange:V},i),T),J=Y.inputProps,U=Y.labelProps,$=Y.descriptionProps,K=Y.errorMessageProps;return e.useEffect(function(){var e=new ResizeObserver(function(e){F(e[0].contentRect.width)}),n=new ResizeObserver(function(e){B(e[0].contentRect.width)});return null!==O.current&&e.observe(O.current),null!==N.current&&n.observe(N.current),function(){n.disconnect(),e.disconnect()}},[]),/*#__PURE__*/s.default.createElement(Ye,{className:o,isDisabled:y},/*#__PURE__*/s.default.createElement(Je,h({label:b,requiredText:g,required:w,subLabel:x},U,c?{}:L)),/*#__PURE__*/s.default.createElement(Ue,null,/*#__PURE__*/s.default.createElement($e,{ref:O},/*#__PURE__*/s.default.createElement(Qe,null,P)),/*#__PURE__*/s.default.createElement(We,h({ref:Ie(t,T),invalid:C,extraLeftPadding:A,extraRightPadding:G},J)),/*#__PURE__*/s.default.createElement(Ke,{ref:N},/*#__PURE__*/s.default.createElement(Qe,null,q),p&&S&&/*#__PURE__*/s.default.createElement(en,null,M,"/",S))),null!=k&&0!==k.length&&/*#__PURE__*/s.default.createElement(tn,h({invalid:C},C?K:$),k))}),Ve=s.default.forwardRef(function(n,t){var r,a=n.onChange,i=v(n,Ae),o=i.className,d=i.showCount,c=void 0!==d&&d,f=i.showLabel,p=void 0!==f&&f,b=i.label,g=i.requiredText,x=i.subLabel,m=i.disabled,y=void 0!==m&&m,w=i.required,E=i.invalid,C=void 0!==E&&E,k=i.assistiveText,S=i.maxLength,R=i.autoHeight,P=void 0!==R&&R,z=i.rows,q=void 0===z?4:z,L=u.useVisuallyHidden().visuallyHiddenProps,T=e.useRef(null),O=e.useRef(null),N=e.useState(Ge(null!=(r=i.value)?r:"")),D=N[0],M=N[1],H=e.useState(q),j=H[0],A=H[1],F=e.useCallback(function(e){var n,t,r=null!=(n=null==(t=(e.value+"\n").match(/\n/g))?void 0:t.length)?n:1;q<=r&&A(r)},[q]),I=void 0===i.value,G=e.useCallback(function(e){var n=Ge(e);void 0!==S&&n>S||(I&&M(n),P&&null!==T.current&&F(T.current),null==a||a(e))},[P,S,I,a,F]);e.useEffect(function(){var e;M(Ge(null!=(e=i.value)?e:""))},[i.value]);var B=l.useTextField(h({inputElementType:"textarea",isDisabled:y,isRequired:w,validationState:C?"invalid":"valid",description:!C&&k,errorMessage:C&&k,onChange:G},i),O),X=B.inputProps,V=B.labelProps,Y=B.descriptionProps,J=B.errorMessageProps;return e.useEffect(function(){P&&null!==T.current&&F(T.current)},[P,F]),/*#__PURE__*/s.default.createElement(Ye,{className:o,isDisabled:y},/*#__PURE__*/s.default.createElement(Je,h({label:b,requiredText:g,required:w,subLabel:x},V,p?L:{})),/*#__PURE__*/s.default.createElement(Ze,{rows:j},/*#__PURE__*/s.default.createElement(_e,h({ref:Ie(T,t,O),invalid:C,rows:j},X)),c&&/*#__PURE__*/s.default.createElement(nn,null,D)),null!=k&&0!==k.length&&/*#__PURE__*/s.default.createElement(tn,h({invalid:C},C?J:Y),k))}),Ye=c.default.div(V||(V=b(["\n display: flex;\n flex-direction: column;\n\n ","\n"])),function(e){return e.isDisabled&&{opacity:e.theme.elementEffect.disabled.opacity}}),Je=c.default(Te)(Y||(Y=b(["\n ","\n"])),Fe(function(e){return e.margin.bottom(8)})),Ue=c.default.div(J||(J=b(["\n height: 40px;\n display: grid;\n position: relative;\n"]))),$e=c.default.span(U||(U=b(["\n position: absolute;\n top: 50%;\n left: 8px;\n transform: translateY(-50%);\n"]))),Ke=c.default.span($||($=b(["\n position: absolute;\n top: 50%;\n right: 8px;\n transform: translateY(-50%);\n\n display: flex;\n gap: 8px;\n"]))),Qe=c.default.span(K||(K=b(["\n user-select: none;\n\n ","\n"])),Fe(function(e){return[e.typography(14).preserveHalfLeading,e.font.text2]})),We=c.default.input(Q||(Q=b(["\n border: none;\n box-sizing: border-box;\n outline: none;\n font-family: inherit;\n\n /* Prevent zooming for iOS Safari */\n transform-origin: top left;\n transform: scale(0.875);\n width: calc(100% / 0.875);\n height: calc(100% / 0.875);\n font-size: calc(14px / 0.875);\n line-height: calc(22px / 0.875);\n padding-top: calc(9px / 0.875);\n padding-bottom: calc(9px / 0.875);\n padding-left: calc((8px + ","px) / 0.875);\n padding-right: calc((8px + ","px) / 0.875);\n border-radius: calc(4px / 0.875);\n\n /* Display box-shadow for iOS Safari */\n appearance: none;\n\n ","\n\n &::placeholder {\n ","\n }\n"])),function(e){return e.extraLeftPadding},function(e){return e.extraRightPadding},function(e){return Fe(function(n){return[n.bg.surface3.hover,n.outline.default.focus,e.invalid&&n.outline.assertive,n.font.text2]})},Fe(function(e){return e.font.text3})),Ze=c.default.div(W||(W=b(["\n display: grid;\n position: relative;\n\n ",";\n"])),function(e){var t=e.rows;return n.css(Z||(Z=b(["\n max-height: calc(22px * "," + 18px);\n "])),t)}),_e=c.default.textarea(_||(_=b(["\n border: none;\n box-sizing: border-box;\n outline: none;\n resize: none;\n font-family: inherit;\n\n /* Prevent zooming for iOS Safari */\n transform-origin: top left;\n transform: scale(0.875);\n width: calc(100% / 0.875);\n font-size: calc(14px / 0.875);\n line-height: calc(22px / 0.875);\n padding: calc(9px / 0.875) calc(8px / 0.875);\n border-radius: calc(4px / 0.875);\n\n ",";\n\n /* Display box-shadow for iOS Safari */\n appearance: none;\n\n ","\n\n &::placeholder {\n ","\n }\n\n /* Hide scrollbar for Chrome, Safari and Opera */\n &::-webkit-scrollbar {\n display: none;\n }\n /* Hide scrollbar for IE, Edge and Firefox */\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n"])),function(e){var t=e.rows;return n.css(ee||(ee=b(["\n height: calc(22px / 0.875 * "," + 18px / 0.875);\n "])),t)},function(e){return Fe(function(n){return[n.bg.surface3.hover,n.outline.default.focus,e.invalid&&n.outline.assertive,n.font.text2]})},Fe(function(e){return e.font.text3})),en=c.default.span(ne||(ne=b(["\n ","\n"])),Fe(function(e){return[e.typography(14).preserveHalfLeading,e.font.text3]})),nn=c.default.span(te||(te=b(["\n position: absolute;\n bottom: 9px;\n right: 8px;\n\n ","\n"])),Fe(function(e){return[e.typography(14).preserveHalfLeading,e.font.text3]})),tn=c.default.p(re||(re=b(["\n ","\n"])),function(e){return Fe(function(n){return[n.typography(14),n.margin.top(8),n.margin.bottom(0),n.font[e.invalid?"assertive":"text1"]]})});exports.Button=ce,exports.Clickable=oe,exports.ComponentAbstraction=function(e){var n=e.children;/*#__PURE__*/return s.default.createElement(w.Provider,{value:h({},y,e.components)},n)},exports.IconButton=he,exports.Radio=function(n){var t=n.value,r=n.forceChecked,a=void 0!==r&&r,i=n.disabled,o=void 0!==i&&i,l=n.children,u=e.useContext(ye),d=u.name,c=u.selected,f=u.disabled,h=u.readonly,v=u.hasError,b=u.onChange;p.default(void 0!==d,'"name" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?');var g=t===c,x=o||f,m=h&&!g,y=e.useCallback(function(e){b(e.currentTarget.value)},[b]);/*#__PURE__*/return s.default.createElement(be,{"aria-disabled":x||m},/*#__PURE__*/s.default.createElement(ge,{name:d,value:t,checked:a||g,hasError:v,onChange:y,disabled:x||m}),null!=l&&/*#__PURE__*/s.default.createElement(xe,null,l))},exports.RadioGroup=function(n){var t=n.className,r=n.value,a=n.label,i=n.name,o=n.onChange,l=n.disabled,u=n.readonly,d=n.hasError,c=n.children,f=e.useCallback(function(e){o(e)},[o]);/*#__PURE__*/return s.default.createElement(ye.Provider,{value:{name:i,selected:r,disabled:null!=l&&l,readonly:null!=u&&u,hasError:null!=d&&d,onChange:f}},/*#__PURE__*/s.default.createElement(me,{role:"radiogroup","aria-orientation":"vertical","aria-label":a,"aria-invalid":d,className:t},c))},exports.Select=function(n){var t=n.value,r=n.forceChecked,a=void 0!==r&&r,i=n.disabled,o=void 0!==i&&i,l=n.onChange,u=n.variant,d=void 0===u?"default":u,c=n.children,f=e.useContext(we),h=f.name,v=f.selected,b=f.disabled,g=f.readonly,x=f.hasError,m=f.onChange;p.default(void 0!==h,'"name" is not Provided for <Select>. Perhaps you forgot to wrap with <SelectGroup> ?');var y=v.includes(t)||a,w=o||b||g,E=e.useCallback(function(e){e.currentTarget instanceof HTMLInputElement&&(l&&l({value:t,selected:e.currentTarget.checked}),m({value:t,selected:e.currentTarget.checked}))},[l,m,t]);/*#__PURE__*/return s.default.createElement(Ee,{"aria-disabled":w},/*#__PURE__*/s.default.createElement(ke,{name:h,value:t,hasError:x,checked:y,disabled:w,onChange:E,overlay:"overlay"===d,"aria-invalid":x}),/*#__PURE__*/s.default.createElement(Se,{overlay:"overlay"===d,hasError:x,"aria-hidden":!0},/*#__PURE__*/s.default.createElement("pixiv-icon",{name:"24/Check","unsafe-non-guideline-scale":16/24})),Boolean(c)&&/*#__PURE__*/s.default.createElement(Ce,null,c))},exports.SelectGroup=function(n){var t=n.className,r=n.name,a=n.ariaLabel,i=n.selected,o=n.onChange,l=n.disabled,u=void 0!==l&&l,d=n.readonly,c=void 0!==d&&d,f=n.hasError,p=void 0!==f&&f,h=n.children,v=e.useCallback(function(e){var n=i.indexOf(e.value);e.selected?n<0&&o([].concat(i,[e.value])):n>=0&&o([].concat(i.slice(0,n),i.slice(n+1)))},[o,i]);/*#__PURE__*/return s.default.createElement(we.Provider,{value:{name:r,selected:Array.from(new Set(i)),disabled:u,readonly:c,hasError:p,onChange:v}},/*#__PURE__*/s.default.createElement("div",{className:t,"aria-label":a,"data-testid":"SelectGroup"},h))},exports.Switch=function(n){var t=n.disabled,r=n.className,a=e.useMemo(function(){return h({},n,{"aria-label":"children"in n?void 0:n.label,isDisabled:n.disabled,isSelected:n.checked})},[n]),l=o.useToggleState(a),u=e.useRef(null),d=v(i.useSwitch(a,l,u).inputProps,Re);/*#__PURE__*/return s.default.createElement(Pe,{className:r,"aria-disabled":t},/*#__PURE__*/s.default.createElement(qe,h({},d,{ref:u})),"children"in n?/*#__PURE__*/s.default.createElement(ze,null,n.children):void 0)},exports.TextField=Be,exports.useComponentAbstraction=E;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/core/ComponentAbstraction.tsx","../src/styled.ts","../src/components/Clickable/index.tsx","../src/components/Button/index.tsx","../src/_lib/index.ts","../src/components/IconButton/index.tsx","../src/components/Radio/index.tsx","../src/components/Select/context.ts","../src/components/Select/index.tsx","../src/components/Switch/index.tsx","../src/components/FieldLabel/index.tsx","../src/components/TextField/index.tsx"],"sourcesContent":["import React, { useContext } from 'react'\n\nexport type LinkProps = {\n /**\n * リンクのURL\n */\n to: string\n} & Omit<React.ComponentPropsWithoutRef<'a'>, 'href'>\n\nexport const DefaultLink = React.forwardRef<HTMLAnchorElement, LinkProps>(\n function DefaultLink({ to, children, ...rest }, ref) {\n return (\n <a href={to} ref={ref} {...rest}>\n {children}\n </a>\n )\n }\n)\n\ninterface Components {\n Link: React.ComponentType<React.ComponentPropsWithRef<typeof DefaultLink>>\n}\n\nconst DefaultValue: Components = {\n Link: DefaultLink,\n}\n\nconst ComponentAbstractionContext = React.createContext(DefaultValue)\n\ninterface Props {\n children: React.ReactNode\n components: Partial<Components>\n}\n\nexport default function ComponentAbstraction({ children, components }: Props) {\n return (\n <ComponentAbstractionContext.Provider\n value={{ ...DefaultValue, ...components }}\n >\n {children}\n </ComponentAbstractionContext.Provider>\n )\n}\n\nexport function useComponentAbstraction() {\n return useContext(ComponentAbstractionContext)\n}\n","import styled from 'styled-components'\nimport createTheme from '@charcoal-ui/styled'\nexport const theme = createTheme(styled)\n","import React from 'react'\nimport styled, { css } from 'styled-components'\nimport {\n LinkProps,\n useComponentAbstraction,\n} from '../../core/ComponentAbstraction'\nimport { disabledSelector } from '@charcoal-ui/utils'\n\ninterface BaseProps {\n /**\n * クリックの無効化\n */\n disabled?: boolean\n}\n\ninterface LinkBaseProps {\n /**\n * リンクのURL。指定するとbuttonタグではなくaタグとして描画される\n */\n to: string\n}\n\nexport type ClickableProps =\n | (BaseProps & Omit<React.ComponentPropsWithoutRef<'button'>, 'disabled'>)\n | (BaseProps & LinkBaseProps & Omit<LinkProps, 'to'>)\nexport type ClickableElement = HTMLButtonElement & HTMLAnchorElement\n\nconst Clickable = React.forwardRef<ClickableElement, ClickableProps>(\n function Clickable(props, ref) {\n const { Link } = useComponentAbstraction()\n if ('to' in props) {\n const { onClick, disabled = false, ...rest } = props\n return (\n <A<typeof Link>\n {...rest}\n as={disabled ? undefined : Link}\n onClick={disabled ? undefined : onClick}\n aria-disabled={disabled}\n ref={ref}\n />\n )\n } else {\n return <Button {...props} ref={ref} />\n }\n }\n)\nexport default Clickable\n\nconst clickableCss = css`\n /* Clickable style */\n cursor: pointer;\n\n ${disabledSelector} {\n cursor: default;\n }\n`\n\nconst Button = styled.button`\n /* Reset button appearance */\n appearance: none;\n background: transparent;\n padding: 0;\n border-style: none;\n outline: none;\n color: inherit;\n text-rendering: inherit;\n letter-spacing: inherit;\n word-spacing: inherit;\n\n &:focus {\n outline: none;\n }\n\n /* Change the font styles in all browsers. */\n font: inherit;\n\n /* Remove the margin in Firefox and Safari. */\n margin: 0;\n\n /* Show the overflow in Edge. */\n overflow: visible;\n\n /* Remove the inheritance of text transform in Firefox. */\n text-transform: none;\n\n /* Remove the inner border and padding in Firefox. */\n &::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n ${clickableCss}\n`\n\nconst A = styled.span`\n /* Reset a-tag appearance */\n color: inherit;\n\n &:focus {\n outline: none;\n }\n\n .text {\n top: calc(1em + 2em);\n }\n\n ${clickableCss}\n`\n","import React from 'react'\nimport styled from 'styled-components'\nimport { unreachable } from '../../_lib'\nimport { theme } from '../../styled'\nimport Clickable, { ClickableElement, ClickableProps } from '../Clickable'\n\ntype Variant = 'Primary' | 'Default' | 'Overlay' | 'Danger' | 'Navigation'\ntype Size = 'S' | 'M'\n\ninterface StyledProps {\n /**\n * ボタンのスタイル\n */\n variant: Variant\n /**\n * ボタンのサイズ\n */\n size: Size\n /**\n * 幅を最大まで広げて描画\n */\n fixed: boolean\n}\n\nexport type ButtonProps = Partial<StyledProps> & ClickableProps\n\nconst Button = React.forwardRef<ClickableElement, ButtonProps>(function Button(\n {\n children,\n variant = 'Default',\n size = 'M',\n fixed = false,\n disabled = false,\n ...rest\n },\n ref\n) {\n return (\n <StyledButton\n {...rest}\n disabled={disabled}\n variant={variant}\n size={size}\n fixed={fixed}\n ref={ref}\n >\n {children}\n </StyledButton>\n )\n})\nexport default Button\n\nconst StyledButton = styled(Clickable)\n .withConfig<StyledProps>({\n shouldForwardProp(prop) {\n // fixed は <button> 要素に渡ってはいけない\n return prop !== 'fixed'\n },\n })\n .attrs<StyledProps, ReturnType<typeof styledProps>>(styledProps)`\n width: ${(p) => (p.fixed ? 'stretch' : 'min-content')};\n display: inline-grid;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n user-select: none;\n white-space: nowrap;\n\n ${(p) =>\n theme((o) => [\n o.font[p.font].hover.press,\n o.bg[p.background].hover.press,\n o.typography(14).bold.preserveHalfLeading,\n o.padding.horizontal(p.padding),\n o.disabled,\n o.borderRadius('oval'),\n o.outline.default.focus,\n ])}\n\n /* よく考えたらheight=32って定義が存在しないな... */\n height: ${(p) => p.height}px;\n`\n\nfunction styledProps(props: StyledProps) {\n return {\n ...props,\n ...variantToProps(props.variant),\n ...sizeToProps(props.size),\n }\n}\n\nfunction variantToProps(variant: Variant) {\n switch (variant) {\n case 'Overlay':\n return { font: 'text5', background: 'surface4' } as const\n case 'Default':\n return { font: 'text2', background: 'surface3' } as const\n case 'Primary':\n return { font: 'text5', background: 'brand' } as const\n case 'Navigation':\n return { font: 'text5', background: 'surface6' } as const\n case 'Danger':\n return { font: 'text5', background: 'assertive' } as const\n default:\n return unreachable(variant)\n }\n}\n\nfunction sizeToProps(size: Size) {\n switch (size) {\n case 'S':\n return {\n height: 32,\n padding: 16,\n } as const\n case 'M':\n return {\n height: 40,\n padding: 24,\n } as const\n }\n}\n","/**\n * 今後ポートされる予定の汎用的な関数群\n */\n\n/**\n * Function used to assert a given code path is unreachable\n */\nexport function unreachable(): never\n/**\n * Function used to assert a given code path is unreachable.\n * Very useful for ensuring switches are exhaustive:\n *\n * ```ts\n * switch (a.type) {\n * case Types.A:\n * case Types.B:\n * break\n * default:\n * unreachable(a) // will cause a build error if there was\n * // a Types.C that was not checked\n * }\n * ```\n *\n * @param value Value to be asserted as unreachable\n */\n// NOTE: Uses separate overloads, _not_ `value?: never`, to not allow `undefined` to be passed\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport function unreachable(value: never): never\nexport function unreachable(value?: never): never {\n throw new Error(\n arguments.length === 0\n ? 'unreachable'\n : `unreachable (${JSON.stringify(value)})`\n )\n}\n","import React from 'react'\nimport styled from 'styled-components'\nimport { theme } from '../../styled'\nimport Clickable, { ClickableElement, ClickableProps } from '../Clickable'\nimport type { KnownIconType } from '@charcoal-ui/icons'\n\ntype Variant = 'Default' | 'Overlay'\ntype Size = 'XS' | 'S' | 'M'\n\ninterface StyledProps {\n readonly variant?: Variant\n readonly size?: Size\n readonly icon: keyof KnownIconType\n}\n\nexport type IconButtonProps = StyledProps & ClickableProps\n\nconst IconButton = React.forwardRef<ClickableElement, IconButtonProps>(\n function IconButtonInner(\n { variant = 'Default', size = 'M', icon, ...rest }: IconButtonProps,\n ref\n ) {\n validateIconSize(size, icon)\n return (\n <StyledIconButton {...rest} ref={ref} variant={variant} size={size}>\n <pixiv-icon name={icon} />\n </StyledIconButton>\n )\n }\n)\n\nexport default IconButton\n\nconst StyledIconButton = styled(Clickable).attrs<\n Required<StyledProps>,\n ReturnType<typeof styledProps>\n>(styledProps)`\n user-select: none;\n\n width: ${(p) => p.width}px;\n height: ${(p) => p.height}px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ${({ font, background }) =>\n theme((o) => [\n o.font[font],\n o.bg[background].hover.press,\n o.disabled,\n o.borderRadius('oval'),\n o.outline.default.focus,\n ])}\n`\n\nfunction styledProps(props: Required<StyledProps>) {\n return {\n ...props,\n ...variantToProps(props.variant),\n ...sizeToProps(props.size),\n }\n}\n\nfunction variantToProps(variant: Variant) {\n switch (variant) {\n case 'Default':\n return { font: 'text3', background: 'transparent' } as const\n case 'Overlay':\n return { font: 'text5', background: 'surface4' } as const\n }\n}\n\nfunction sizeToProps(size: Size) {\n switch (size) {\n case 'XS':\n return {\n width: 20,\n height: 20,\n }\n case 'S':\n return {\n width: 32,\n height: 32,\n }\n case 'M':\n return {\n width: 40,\n height: 40,\n }\n }\n}\n\n/**\n * validates matches of size and icon\n */\nfunction validateIconSize(size: Size, icon: keyof KnownIconType) {\n let requiredIconSize: string\n switch (size) {\n case 'XS':\n requiredIconSize = '16'\n break\n case 'S':\n case 'M':\n requiredIconSize = '24'\n break\n }\n // アイコン名は サイズ/名前\n const result = /^\\d*/u.exec(icon)\n if (result == null) {\n throw new Error('Invalid icon name')\n }\n const [iconSize] = result\n if (iconSize !== requiredIconSize) {\n // eslint-disable-next-line no-console\n console.warn(\n `IconButton with size \"${size}\" expect icon size \"${requiredIconSize}, but got \"${iconSize}\"`\n )\n }\n}\n","import React, { useCallback, useContext } from 'react'\nimport styled from 'styled-components'\nimport warning from 'warning'\nimport { theme } from '../../styled'\nimport { px } from '@charcoal-ui/utils'\n\nexport type RadioProps = React.PropsWithChildren<{\n value: string\n forceChecked?: boolean\n disabled?: boolean\n}>\n\nexport default function Radio({\n value,\n forceChecked = false,\n disabled = false,\n children,\n}: RadioProps) {\n const {\n name,\n selected,\n disabled: isParentDisabled,\n readonly,\n hasError,\n onChange,\n } = useContext(RadioGroupContext)\n\n warning(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n name !== undefined,\n `\"name\" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?`\n )\n\n const isSelected = value === selected\n const isDisabled = disabled || isParentDisabled\n const isReadonly = readonly && !isSelected\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange(e.currentTarget.value)\n },\n [onChange]\n )\n\n return (\n <RadioRoot aria-disabled={isDisabled || isReadonly}>\n <RadioInput\n name={name}\n value={value}\n checked={forceChecked || isSelected}\n hasError={hasError}\n onChange={handleChange}\n disabled={isDisabled || isReadonly}\n />\n {children != null && <RadioLabel>{children}</RadioLabel>}\n </RadioRoot>\n )\n}\n\nconst RadioRoot = styled.label`\n display: grid;\n grid-template-columns: auto 1fr;\n grid-gap: ${({ theme }) => px(theme.spacing[4])};\n align-items: center;\n cursor: pointer;\n\n ${theme((o) => [o.disabled])}\n`\n\nexport const RadioInput = styled.input.attrs({ type: 'radio' })<{\n hasError?: boolean\n}>`\n /** Make prior to browser default style */\n &[type='radio'] {\n appearance: none;\n display: block;\n box-sizing: border-box;\n\n padding: 6px;\n\n width: 20px;\n height: 20px;\n\n ${({ hasError = false }) =>\n theme((o) => [\n o.borderRadius('oval'),\n o.bg.text5.hover.press,\n hasError && o.outline.assertive,\n ])};\n\n &:not(:checked) {\n border-width: 2px;\n border-style: solid;\n border-color: ${({ theme }) => theme.color.text4};\n }\n\n &:checked {\n ${theme((o) => o.bg.brand.hover.press)}\n\n &::after {\n content: '';\n display: block;\n width: 8px;\n height: 8px;\n pointer-events: none;\n\n ${theme((o) => [o.bg.text5.hover.press, o.borderRadius('oval')])}\n }\n }\n\n ${theme((o) => o.outline.default.focus)}\n }\n`\n\nconst RadioLabel = styled.div`\n ${theme((o) => [o.typography(14)])}\n`\n\nexport type RadioGroupProps = React.PropsWithChildren<{\n className?: string\n value?: string\n label: string\n name: string\n onChange(next: string): void\n disabled?: boolean\n readonly?: boolean\n hasError?: boolean\n}>\n\n// TODO: use (or polyfill) flex gap\nconst StyledRadioGroup = styled.div`\n display: grid;\n grid-template-columns: 1fr;\n grid-gap: ${({ theme }) => px(theme.spacing[8])};\n`\n\ninterface RadioGroupContext {\n name: string\n selected?: string\n disabled: boolean\n readonly: boolean\n hasError: boolean\n onChange: (next: string) => void\n}\n\nconst RadioGroupContext = React.createContext<RadioGroupContext>({\n name: undefined as never,\n selected: undefined,\n disabled: false,\n readonly: false,\n hasError: false,\n onChange() {\n throw new Error(\n 'Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?'\n )\n },\n})\n\nexport function RadioGroup({\n className,\n value,\n label,\n name,\n onChange,\n disabled,\n readonly,\n hasError,\n children,\n}: RadioGroupProps) {\n const handleChange = useCallback(\n (next: string) => {\n onChange(next)\n },\n [onChange]\n )\n\n return (\n <RadioGroupContext.Provider\n value={{\n name,\n selected: value,\n disabled: disabled ?? false,\n readonly: readonly ?? false,\n hasError: hasError ?? false,\n onChange: handleChange,\n }}\n >\n <StyledRadioGroup\n role=\"radiogroup\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-invalid={hasError}\n className={className}\n >\n {children}\n </StyledRadioGroup>\n </RadioGroupContext.Provider>\n )\n}\n","import { createContext } from 'react'\n\ntype SelectGroupContext = {\n name: string\n selected: string[]\n disabled: boolean\n readonly: boolean\n hasError: boolean\n onChange: ({ value, selected }: { value: string; selected: boolean }) => void\n}\n\nexport const SelectGroupContext = createContext<SelectGroupContext>({\n name: undefined as never,\n selected: [],\n disabled: false,\n readonly: false,\n hasError: false,\n onChange() {\n throw new Error(\n 'Cannot find `onChange()` handler. Perhaps you forgot to wrap it with `<SelectGroup />` ?'\n )\n },\n})\n","import React, { ChangeEvent, useCallback, useContext } from 'react'\nimport styled, { css } from 'styled-components'\nimport warning from 'warning'\nimport { theme } from '../../styled'\nimport { disabledSelector, px } from '@charcoal-ui/utils'\n\nimport { SelectGroupContext } from './context'\n\nexport type SelectProps = React.PropsWithChildren<{\n value: string\n forceChecked?: boolean\n disabled?: boolean\n variant?: 'default' | 'overlay'\n onChange?: (payload: { value: string; selected: boolean }) => void\n}>\n\nexport default function Select({\n value,\n forceChecked = false,\n disabled = false,\n onChange,\n variant = 'default',\n children,\n}: SelectProps) {\n const {\n name,\n selected,\n disabled: parentDisabled,\n readonly,\n hasError,\n onChange: parentOnChange,\n } = useContext(SelectGroupContext)\n\n warning(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n name !== undefined,\n `\"name\" is not Provided for <Select>. Perhaps you forgot to wrap with <SelectGroup> ?`\n )\n\n const isSelected = selected.includes(value) || forceChecked\n const isDisabled = disabled || parentDisabled || readonly\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n if (!(event.currentTarget instanceof HTMLInputElement)) {\n return\n }\n if (onChange) onChange({ value, selected: event.currentTarget.checked })\n parentOnChange({ value, selected: event.currentTarget.checked })\n },\n [onChange, parentOnChange, value]\n )\n\n return (\n <SelectRoot aria-disabled={isDisabled}>\n <SelectInput\n {...{\n name,\n value,\n hasError,\n }}\n checked={isSelected}\n disabled={isDisabled}\n onChange={handleChange}\n overlay={variant === 'overlay'}\n aria-invalid={hasError}\n />\n <SelectInputOverlay\n overlay={variant === 'overlay'}\n hasError={hasError}\n aria-hidden={true}\n >\n <pixiv-icon name=\"24/Check\" unsafe-non-guideline-scale={16 / 24} />\n </SelectInputOverlay>\n {Boolean(children) && <SelectLabel>{children}</SelectLabel>}\n </SelectRoot>\n )\n}\n\nconst SelectRoot = styled.label`\n display: grid;\n grid-template-columns: auto 1fr;\n align-items: center;\n position: relative;\n cursor: pointer;\n ${disabledSelector} {\n cursor: default;\n }\n gap: ${({ theme }) => px(theme.spacing[4])};\n ${theme((o) => o.disabled)}\n`\n\nconst SelectLabel = styled.div`\n display: flex;\n align-items: center;\n ${theme((o) => [o.typography(14), o.font.text1])}\n`\n\nconst SelectInput = styled.input.attrs({ type: 'checkbox' })<{\n hasError: boolean\n overlay: boolean\n}>`\n &[type='checkbox'] {\n appearance: none;\n display: block;\n width: 20px;\n height: 20px;\n margin: 0;\n\n &:checked {\n ${theme((o) => o.bg.brand.hover.press)}\n }\n\n ${({ hasError, overlay }) =>\n theme((o) => [\n o.bg.text3.hover.press,\n o.borderRadius('oval'),\n hasError && !overlay && o.outline.assertive,\n overlay && o.bg.surface4,\n ])};\n }\n`\n\nconst SelectInputOverlay = styled.div<{ overlay: boolean; hasError: boolean }>`\n position: absolute;\n top: -2px;\n left: -2px;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ${({ hasError, overlay }) =>\n theme((o) => [\n o.width.px(24),\n o.height.px(24),\n o.borderRadius('oval'),\n o.font.text5,\n hasError && overlay && o.outline.assertive,\n ])}\n\n ${({ overlay }) =>\n overlay &&\n css`\n border-color: ${({ theme }) => theme.color.text5};\n border-width: 2px;\n border-style: solid;\n `}\n`\n\nexport type SelectGroupProps = React.PropsWithChildren<{\n className?: string\n name: string\n ariaLabel: string\n selected: string[]\n onChange: (selected: string[]) => void\n disabled?: boolean\n readonly?: boolean\n hasError?: boolean\n}>\n\nexport function SelectGroup({\n className,\n name,\n ariaLabel,\n selected,\n onChange,\n disabled = false,\n readonly = false,\n hasError = false,\n children,\n}: SelectGroupProps) {\n const handleChange = useCallback(\n (payload: { value: string; selected: boolean }) => {\n const index = selected.indexOf(payload.value)\n\n if (payload.selected) {\n if (index < 0) {\n onChange([...selected, payload.value])\n }\n } else {\n if (index >= 0) {\n onChange([...selected.slice(0, index), ...selected.slice(index + 1)])\n }\n }\n },\n [onChange, selected]\n )\n\n return (\n <SelectGroupContext.Provider\n value={{\n name,\n selected: Array.from(new Set(selected)),\n disabled,\n readonly,\n hasError,\n onChange: handleChange,\n }}\n >\n <div\n className={className}\n aria-label={ariaLabel}\n data-testid=\"SelectGroup\"\n >\n {children}\n </div>\n </SelectGroupContext.Provider>\n )\n}\n","import { useSwitch } from '@react-aria/switch'\nimport type { AriaSwitchProps } from '@react-types/switch'\nimport React, { useRef, useMemo } from 'react'\nimport { useToggleState } from 'react-stately'\nimport styled from 'styled-components'\nimport { theme } from '../../styled'\nimport { disabledSelector, px } from '@charcoal-ui/utils'\n\nexport type SwitchProps = {\n name: string\n className?: string\n value?: string\n checked?: boolean\n disabled?: boolean\n onChange(checked: boolean): void\n} & (\n | // children か label は片方が必須\n {\n children: React.ReactNode\n }\n | {\n label: string\n }\n)\n\nexport default function SwitchCheckbox(props: SwitchProps) {\n const { disabled, className } = props\n\n const ariaSwitchProps: AriaSwitchProps = useMemo(\n () => ({\n ...props,\n\n // children がいない場合は aria-label をつけないといけない\n 'aria-label': 'children' in props ? undefined : props.label,\n isDisabled: props.disabled,\n isSelected: props.checked,\n }),\n [props]\n )\n\n const state = useToggleState(ariaSwitchProps)\n const ref = useRef<HTMLInputElement>(null)\n const {\n inputProps: { className: _className, type: _type, ...rest },\n } = useSwitch(ariaSwitchProps, state, ref)\n\n return (\n <Label className={className} aria-disabled={disabled}>\n <SwitchInput {...rest} ref={ref} />\n {'children' in props ? (\n // eslint-disable-next-line react/destructuring-assignment\n <LabelInner>{props.children}</LabelInner>\n ) : undefined}\n </Label>\n )\n}\n\nconst Label = styled.label`\n display: inline-grid;\n grid-template-columns: auto 1fr;\n gap: ${({ theme }) => px(theme.spacing[4])};\n cursor: pointer;\n outline: 0;\n\n ${theme((o) => o.disabled)}\n\n ${disabledSelector} {\n cursor: default;\n }\n`\n\nconst LabelInner = styled.div`\n ${theme((o) => o.typography(14))}\n`\n\nconst SwitchInput = styled.input.attrs({\n type: 'checkbox',\n})`\n &[type='checkbox'] {\n appearance: none;\n display: inline-flex;\n position: relative;\n box-sizing: border-box;\n width: 28px;\n border: 2px solid transparent;\n transition: box-shadow 0.2s, background-color 0.2s;\n cursor: inherit;\n ${theme((o) => [\n o.borderRadius(16),\n o.height.px(16),\n o.bg.text4.hover.press,\n o.outline.default.focus,\n ])}\n\n &::after {\n content: '';\n position: absolute;\n display: block;\n top: 0;\n left: 0;\n width: 12px;\n height: 12px;\n transform: translateX(0);\n transition: transform 0.2s;\n ${theme((o) => [o.bg.text5.hover.press, o.borderRadius('oval')])}\n }\n\n &:checked {\n ${theme((o) => o.bg.brand.hover.press)}\n\n &::after {\n transform: translateX(12px);\n }\n }\n }\n`\n","import React from 'react'\nimport styled from 'styled-components'\nimport createTheme from '@charcoal-ui/styled'\n\nexport interface FieldLabelProps\n extends React.LabelHTMLAttributes<HTMLLabelElement> {\n readonly className?: string\n readonly label: string\n readonly subLabel?: React.ReactNode\n readonly required?: boolean\n // TODO: 翻訳用のContextで注入する\n readonly requiredText?: string\n}\n\nconst FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(\n function FieldLabel(\n {\n style,\n className,\n label,\n required = false,\n requiredText,\n subLabel,\n ...labelProps\n },\n ref\n ) {\n return (\n <FieldLabelWrapper style={style} className={className}>\n <Label ref={ref} {...labelProps}>\n {label}\n </Label>\n {required && <RequiredText>{requiredText}</RequiredText>}\n <SubLabelClickable>\n <span>{subLabel}</span>\n </SubLabelClickable>\n </FieldLabelWrapper>\n )\n }\n)\n\nexport default FieldLabel\n\nconst theme = createTheme(styled)\n\nconst Label = styled.label`\n ${theme((o) => [o.typography(14).bold, o.font.text1])}\n`\n\nconst RequiredText = styled.span`\n ${theme((o) => [o.typography(14), o.font.text3])}\n`\n\nconst SubLabelClickable = styled.div`\n ${theme((o) => [\n o.typography(14),\n o.font.text3.hover.press,\n o.outline.default.focus,\n ])}\n`\n\nconst FieldLabelWrapper = styled.div`\n display: inline-flex;\n align-items: center;\n\n > ${RequiredText} {\n ${theme((o) => o.margin.left(4))}\n }\n\n > ${SubLabelClickable} {\n ${theme((o) => o.margin.left('auto'))}\n }\n`\n","import { useTextField } from '@react-aria/textfield'\nimport { useVisuallyHidden } from '@react-aria/visually-hidden'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport styled, { css } from 'styled-components'\nimport FieldLabel, { FieldLabelProps } from '../FieldLabel'\nimport createTheme from '@charcoal-ui/styled'\n\nconst theme = createTheme(styled)\n\ninterface TextFieldBaseProps\n extends Pick<FieldLabelProps, 'label' | 'requiredText' | 'subLabel'> {\n readonly className?: string\n readonly defaultValue?: string\n readonly value?: string\n readonly onChange?: (value: string) => void\n readonly showCount?: boolean\n readonly showLabel?: boolean\n readonly placeholder?: string\n readonly assistiveText?: string\n readonly disabled?: boolean\n readonly required?: boolean\n readonly invalid?: boolean\n readonly maxLength?: number\n /**\n * tab-indexがー1かどうか\n */\n readonly excludeFromTabOrder?: boolean\n}\n\nexport interface SingleLineTextFieldProps extends TextFieldBaseProps {\n readonly autoHeight?: never\n readonly multiline?: false\n readonly rows?: never\n readonly type?: string\n readonly prefix?: string\n readonly suffix?: string\n}\n\nexport interface MultiLineTextFieldProps extends TextFieldBaseProps {\n readonly autoHeight?: boolean\n readonly multiline: true\n readonly rows?: number\n readonly type?: never\n readonly prefix?: never\n readonly suffix?: never\n}\n\nexport type TextFieldProps = SingleLineTextFieldProps | MultiLineTextFieldProps\ntype TextFieldElement = HTMLInputElement & HTMLTextAreaElement\n\nfunction mergeRefs<T>(...refs: React.Ref<T>[]): React.RefCallback<T> {\n return (value) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(value)\n } else if (ref !== null) {\n ;(ref as React.MutableRefObject<T | null>).current = value\n }\n }\n }\n}\n\nfunction countCodePointsInString(string: string) {\n // [...string] とするとproduction buildで動かなくなる\n // cf. https://twitter.com/f_subal/status/1497214727511891972\n return Array.from(string).length\n}\n\nconst TextField = React.forwardRef<TextFieldElement, TextFieldProps>(\n function TextField(props, ref) {\n return props.multiline !== undefined && props.multiline ? (\n <MultiLineTextField ref={ref} {...props} />\n ) : (\n <SingleLineTextField ref={ref} {...props} />\n )\n }\n)\n\nexport default TextField\n\nconst SingleLineTextField = React.forwardRef<\n HTMLInputElement,\n SingleLineTextFieldProps\n>(function SingleLineTextFieldInner({ onChange, ...props }, forwardRef) {\n const {\n className,\n showLabel = false,\n showCount = false,\n label,\n requiredText,\n subLabel,\n disabled = false,\n required,\n invalid = false,\n assistiveText,\n maxLength,\n prefix = '',\n suffix = '',\n } = props\n\n const { visuallyHiddenProps } = useVisuallyHidden()\n const ariaRef = useRef<HTMLInputElement>(null)\n const prefixRef = useRef<HTMLSpanElement>(null)\n const suffixRef = useRef<HTMLSpanElement>(null)\n const [count, setCount] = useState(countCodePointsInString(props.value ?? ''))\n const [prefixWidth, setPrefixWidth] = useState(0)\n const [suffixWidth, setSuffixWidth] = useState(0)\n\n const nonControlled = props.value === undefined\n const handleChange = useCallback(\n (value: string) => {\n const count = countCodePointsInString(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n if (nonControlled) {\n setCount(count)\n }\n onChange?.(value)\n },\n [maxLength, nonControlled, onChange]\n )\n\n useEffect(() => {\n setCount(countCodePointsInString(props.value ?? ''))\n }, [props.value])\n\n const { inputProps, labelProps, descriptionProps, errorMessageProps } =\n useTextField(\n {\n inputElementType: 'input',\n isDisabled: disabled,\n isRequired: required,\n validationState: invalid ? 'invalid' : 'valid',\n description: !invalid && assistiveText,\n errorMessage: invalid && assistiveText,\n onChange: handleChange,\n ...props,\n },\n ariaRef\n )\n\n useEffect(() => {\n const prefixObserver = new ResizeObserver((entries) => {\n setPrefixWidth(entries[0].contentRect.width)\n })\n const suffixObserver = new ResizeObserver((entries) => {\n setSuffixWidth(entries[0].contentRect.width)\n })\n\n if (prefixRef.current !== null) {\n prefixObserver.observe(prefixRef.current)\n }\n if (suffixRef.current !== null) {\n suffixObserver.observe(suffixRef.current)\n }\n\n return () => {\n suffixObserver.disconnect()\n prefixObserver.disconnect()\n }\n }, [])\n\n return (\n <TextFieldRoot className={className} isDisabled={disabled}>\n <TextFieldLabel\n label={label}\n requiredText={requiredText}\n required={required}\n subLabel={subLabel}\n {...labelProps}\n {...(!showLabel ? visuallyHiddenProps : {})}\n />\n <StyledInputContainer>\n <PrefixContainer ref={prefixRef}>\n <Affix>{prefix}</Affix>\n </PrefixContainer>\n <StyledInput\n ref={mergeRefs(forwardRef, ariaRef)}\n invalid={invalid}\n extraLeftPadding={prefixWidth}\n extraRightPadding={suffixWidth}\n {...inputProps}\n />\n <SuffixContainer ref={suffixRef}>\n <Affix>{suffix}</Affix>\n {showCount && maxLength && (\n <SingleLineCounter>\n {count}/{maxLength}\n </SingleLineCounter>\n )}\n </SuffixContainer>\n </StyledInputContainer>\n {assistiveText != null && assistiveText.length !== 0 && (\n <AssistiveText\n invalid={invalid}\n {...(invalid ? errorMessageProps : descriptionProps)}\n >\n {assistiveText}\n </AssistiveText>\n )}\n </TextFieldRoot>\n )\n})\n\nconst MultiLineTextField = React.forwardRef<\n HTMLTextAreaElement,\n MultiLineTextFieldProps\n>(function MultiLineTextFieldInner({ onChange, ...props }, forwardRef) {\n const {\n className,\n showCount = false,\n showLabel = false,\n label,\n requiredText,\n subLabel,\n disabled = false,\n required,\n invalid = false,\n assistiveText,\n maxLength,\n autoHeight = false,\n rows: initialRows = 4,\n } = props\n\n const { visuallyHiddenProps } = useVisuallyHidden()\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n const ariaRef = useRef<HTMLTextAreaElement>(null)\n const [count, setCount] = useState(countCodePointsInString(props.value ?? ''))\n const [rows, setRows] = useState(initialRows)\n\n const syncHeight = useCallback(\n (textarea: HTMLTextAreaElement) => {\n const rows = `${textarea.value}\\n`.match(/\\n/gu)?.length ?? 1\n if (initialRows <= rows) {\n setRows(rows)\n }\n },\n [initialRows]\n )\n\n const nonControlled = props.value === undefined\n const handleChange = useCallback(\n (value: string) => {\n const count = countCodePointsInString(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n if (nonControlled) {\n setCount(count)\n }\n if (autoHeight && textareaRef.current !== null) {\n syncHeight(textareaRef.current)\n }\n onChange?.(value)\n },\n [autoHeight, maxLength, nonControlled, onChange, syncHeight]\n )\n\n useEffect(() => {\n setCount(countCodePointsInString(props.value ?? ''))\n }, [props.value])\n\n const { inputProps, labelProps, descriptionProps, errorMessageProps } =\n useTextField(\n {\n inputElementType: 'textarea',\n isDisabled: disabled,\n isRequired: required,\n validationState: invalid ? 'invalid' : 'valid',\n description: !invalid && assistiveText,\n errorMessage: invalid && assistiveText,\n onChange: handleChange,\n ...props,\n },\n ariaRef\n )\n\n useEffect(() => {\n if (autoHeight && textareaRef.current !== null) {\n syncHeight(textareaRef.current)\n }\n }, [autoHeight, syncHeight])\n\n return (\n <TextFieldRoot className={className} isDisabled={disabled}>\n <TextFieldLabel\n label={label}\n requiredText={requiredText}\n required={required}\n subLabel={subLabel}\n {...labelProps}\n {...(showLabel ? visuallyHiddenProps : {})}\n />\n <StyledTextareaContainer rows={rows}>\n <StyledTextarea\n ref={mergeRefs(textareaRef, forwardRef, ariaRef)}\n invalid={invalid}\n rows={rows}\n {...inputProps}\n />\n {showCount && <MultiLineCounter>{count}</MultiLineCounter>}\n </StyledTextareaContainer>\n {assistiveText != null && assistiveText.length !== 0 && (\n <AssistiveText\n invalid={invalid}\n {...(invalid ? errorMessageProps : descriptionProps)}\n >\n {assistiveText}\n </AssistiveText>\n )}\n </TextFieldRoot>\n )\n})\n\nconst TextFieldRoot = styled.div<{ isDisabled: boolean }>`\n display: flex;\n flex-direction: column;\n\n ${(p) => p.isDisabled && { opacity: p.theme.elementEffect.disabled.opacity }}\n`\n\nconst TextFieldLabel = styled(FieldLabel)`\n ${theme((o) => o.margin.bottom(8))}\n`\n\nconst StyledInputContainer = styled.div`\n height: 40px;\n display: grid;\n position: relative;\n`\n\nconst PrefixContainer = styled.span`\n position: absolute;\n top: 50%;\n left: 8px;\n transform: translateY(-50%);\n`\n\nconst SuffixContainer = styled.span`\n position: absolute;\n top: 50%;\n right: 8px;\n transform: translateY(-50%);\n\n display: flex;\n gap: 8px;\n`\n\nconst Affix = styled.span`\n user-select: none;\n\n ${theme((o) => [o.typography(14).preserveHalfLeading, o.font.text2])}\n`\n\nconst StyledInput = styled.input<{\n invalid: boolean\n extraLeftPadding: number\n extraRightPadding: number\n}>`\n border: none;\n box-sizing: border-box;\n outline: none;\n font-family: inherit;\n\n /* Prevent zooming for iOS Safari */\n transform-origin: top left;\n transform: scale(0.875);\n width: calc(100% / 0.875);\n height: calc(100% / 0.875);\n font-size: calc(14px / 0.875);\n line-height: calc(22px / 0.875);\n padding-top: calc(9px / 0.875);\n padding-bottom: calc(9px / 0.875);\n padding-left: calc((8px + ${(p) => p.extraLeftPadding}px) / 0.875);\n padding-right: calc((8px + ${(p) => p.extraRightPadding}px) / 0.875);\n border-radius: calc(4px / 0.875);\n\n /* Display box-shadow for iOS Safari */\n appearance: none;\n\n ${(p) =>\n theme((o) => [\n o.bg.surface3.hover,\n o.outline.default.focus,\n p.invalid && o.outline.assertive,\n o.font.text2,\n ])}\n\n &::placeholder {\n ${theme((o) => o.font.text3)}\n }\n`\n\nconst StyledTextareaContainer = styled.div<{ rows: number }>`\n display: grid;\n position: relative;\n\n ${({ rows }) => css`\n max-height: calc(22px * ${rows} + 18px);\n `};\n`\n\nconst StyledTextarea = styled.textarea<{ invalid: boolean }>`\n border: none;\n box-sizing: border-box;\n outline: none;\n resize: none;\n font-family: inherit;\n\n /* Prevent zooming for iOS Safari */\n transform-origin: top left;\n transform: scale(0.875);\n width: calc(100% / 0.875);\n font-size: calc(14px / 0.875);\n line-height: calc(22px / 0.875);\n padding: calc(9px / 0.875) calc(8px / 0.875);\n border-radius: calc(4px / 0.875);\n\n ${({ rows }) => css`\n height: calc(22px / 0.875 * ${rows} + 18px / 0.875);\n `};\n\n /* Display box-shadow for iOS Safari */\n appearance: none;\n\n ${(p) =>\n theme((o) => [\n o.bg.surface3.hover,\n o.outline.default.focus,\n p.invalid && o.outline.assertive,\n o.font.text2,\n ])}\n\n &::placeholder {\n ${theme((o) => o.font.text3)}\n }\n\n /* Hide scrollbar for Chrome, Safari and Opera */\n &::-webkit-scrollbar {\n display: none;\n }\n /* Hide scrollbar for IE, Edge and Firefox */\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n`\n\nconst SingleLineCounter = styled.span`\n ${theme((o) => [o.typography(14).preserveHalfLeading, o.font.text3])}\n`\n\nconst MultiLineCounter = styled.span`\n position: absolute;\n bottom: 9px;\n right: 8px;\n\n ${theme((o) => [o.typography(14).preserveHalfLeading, o.font.text3])}\n`\n\nconst AssistiveText = styled.p<{ invalid: boolean }>`\n ${(p) =>\n theme((o) => [\n o.typography(14),\n o.margin.top(8),\n o.margin.bottom(0),\n o.font[p.invalid ? 'assertive' : 'text1'],\n ])}\n`\n"],"names":["DefaultValue","Link","React","forwardRef","ref","to","children","rest","href","ComponentAbstractionContext","createContext","useComponentAbstraction","useContext","theme","createTheme","styled","Clickable","props","onClick","disabled","A","as","undefined","Button","clickableCss","css","disabledSelector","button","span","variant","size","fixed","StyledButton","withConfig","shouldForwardProp","prop","attrs","font","background","value","Error","arguments","length","JSON","stringify","unreachable","variantToProps","height","padding","sizeToProps","p","o","hover","press","bg","typography","bold","preserveHalfLeading","horizontal","borderRadius","outline","focus","IconButton","icon","requiredIconSize","result","exec","iconSize","console","warn","validateIconSize","StyledIconButton","name","width","RadioRoot","label","px","spacing","RadioInput","input","type","hasError","text5","assertive","color","text4","brand","RadioLabel","div","StyledRadioGroup","RadioGroupContext","selected","readonly","onChange","SelectGroupContext","SelectRoot","SelectLabel","text1","SelectInput","overlay","text3","surface4","SelectInputOverlay","Label","LabelInner","SwitchInput","FieldLabel","style","className","required","requiredText","subLabel","labelProps","FieldLabelWrapper","RequiredText","SubLabelClickable","margin","left","mergeRefs","current","countCodePointsInString","string","Array","from","TextField","multiline","MultiLineTextField","SingleLineTextField","showLabel","showCount","invalid","assistiveText","maxLength","prefix","suffix","visuallyHiddenProps","useVisuallyHidden","ariaRef","useRef","prefixRef","suffixRef","useState","count","setCount","prefixWidth","setPrefixWidth","suffixWidth","setSuffixWidth","nonControlled","handleChange","useCallback","useEffect","useTextField","inputElementType","isDisabled","isRequired","validationState","description","errorMessage","inputProps","descriptionProps","errorMessageProps","prefixObserver","ResizeObserver","entries","contentRect","suffixObserver","observe","disconnect","TextFieldRoot","TextFieldLabel","StyledInputContainer","PrefixContainer","Affix","StyledInput","extraLeftPadding","extraRightPadding","SuffixContainer","SingleLineCounter","AssistiveText","autoHeight","rows","initialRows","textareaRef","setRows","syncHeight","textarea","match","_$match","StyledTextareaContainer","StyledTextarea","MultiLineCounter","opacity","elementEffect","bottom","text2","surface3","top","Provider","components","forceChecked","isParentDisabled","warning","isSelected","isReadonly","e","currentTarget","checked","next","role","parentDisabled","parentOnChange","includes","event","HTMLInputElement","Boolean","ariaLabel","payload","index","indexOf","slice","Set","ariaSwitchProps","useMemo","state","useToggleState","useSwitch"],"mappings":"ooDAuBMA,EAA2B,CAC/BC,KAfyBC,UAAMC,WAC/B,WAAgDC,OAAzBC,IAAAA,GAAIC,IAAAA,SAAaC,sBACtC,OACEL,+BAAGM,KAAMH,EAAID,IAAKA,GAASG,GACxBD,MAcHG,EAA8BP,UAAMQ,cAAcV,YAiBxCW,IACd,OAAOC,aAAWH,iFC3CPI,GAAQC,UAAYC,qCCyB3BC,GAAYd,UAAMC,WACtB,SAAmBc,EAAOb,GACxB,IAAQH,EAASU,IAATV,KACR,GAAI,OAAQgB,EAAO,CACjB,IAAQC,EAAuCD,EAAvCC,UAAuCD,EAA9BE,SAAAA,gBAAqBZ,IAASU,mBAC/C,OACEf,wBAACkB,QACKb,GACJc,GAAIF,OAAWG,EAAYrB,EAC3BiB,QAASC,OAAWG,EAAYJ,EAChC,gBAAeC,EACff,IAAKA,kBAIT,OAAOF,wBAACqB,QAAWN,GAAOb,IAAKA,OAM/BoB,GAAeC,0GAIjBC,oBAKEH,GAASR,UAAOY,utBAkClBH,IAGEJ,GAAIL,UAAOa,uKAYbJ,wDChFED,GAASrB,UAAMC,WAA0C,WAS7DC,OAPEE,IAAAA,aACAuB,QAAAA,aAAU,gBACVC,KAAAA,aAAO,UACPC,MAAAA,oBACAZ,SAAAA,gBACGZ,uBAIL,OACEL,wBAAC8B,QACKzB,GACJY,SAAUA,EACVU,QAASA,EACTC,KAAMA,EACNC,MAAOA,EACP3B,IAAKA,IAEJE,KAMD0B,GAAejB,UAAOC,IACzBiB,WAAwB,CACvBC,2BAAkBC,GAEhB,MAAgB,UAATA,KAGVC,MAwBH,SAAqBnB,GACnB,YACKA,EAMP,SAAwBY,GACtB,OAAQA,GACN,IAAK,UACH,MAAO,CAAEQ,KAAM,QAAS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,gBAAezF,gBAC1CjB,wBAACuG,QAAgBlG,GAAMH,IAAKA,KAC3B,aAAca,eAEbf,wBAACsG,QAAYvF,EAAMX,eACjBgB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as ComponentAbstraction, useComponentAbstraction, type LinkProps, } from './core/ComponentAbstraction';
|
|
2
|
+
export { default as Button, type ButtonProps } from './components/Button';
|
|
3
|
+
export { default as Clickable, type ClickableProps, type ClickableElement, } from './components/Clickable';
|
|
4
|
+
export { default as IconButton, type IconButtonProps, } from './components/IconButton';
|
|
5
|
+
export { default as Radio, type RadioProps, RadioGroup, type RadioGroupProps, } from './components/Radio';
|
|
6
|
+
export { default as Select, type SelectProps, SelectGroup, type SelectGroupProps, } from './components/Select';
|
|
7
|
+
export { default as Switch, type SwitchProps } from './components/Switch';
|
|
8
|
+
export { default as TextField, type TextFieldProps, } from './components/TextField';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,oBAAoB,EAC/B,uBAAuB,EACvB,KAAK,SAAS,GACf,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,OAAO,IAAI,UAAU,EACrB,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,OAAO,IAAI,KAAK,EAChB,KAAK,UAAU,EACf,UAAU,EACV,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,OAAO,IAAI,MAAM,EACjB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import e,{useContext as t,useCallback as r,createContext as n,useMemo as a,useRef as o,useState as i,useEffect as l}from"react";import s,{css as c}from"styled-components";import d from"@charcoal-ui/styled";import{disabledSelector as u,px as p}from"@charcoal-ui/utils";import f from"warning";import{useSwitch as h}from"@react-aria/switch";import{useToggleState as g}from"react-stately";import{useTextField as b}from"@react-aria/textfield";import{useVisuallyHidden as m}from"@react-aria/visually-hidden";function v(){return v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},v.apply(this,arguments)}function x(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(a[r]=e[r]);return a}const y=["to","children"],w={Link:e.forwardRef(function(t,r){let{to:n,children:a}=t,o=x(t,y);/*#__PURE__*/return e.createElement("a",v({href:n,ref:r},o),a)})},E=e.createContext(w);function $({children:t,components:r}){/*#__PURE__*/return e.createElement(E.Provider,{value:v({},w,r)},t)}function k(){return t(E)}const C=d(s);let R,P,S,z=e=>e;const L=["onClick","disabled"],N=e.forwardRef(function(t,r){const{Link:n}=k();if("to"in t){const{onClick:a,disabled:o=!1}=t,i=x(t,L);/*#__PURE__*/return e.createElement(q,v({},i,{as:o?void 0:n,onClick:o?void 0:a,"aria-disabled":o,ref:r}))}/*#__PURE__*/return e.createElement(T,v({},t,{ref:r}))}),O=c(R||(R=z`
|
|
2
|
+
/* Clickable style */
|
|
3
|
+
cursor: pointer;
|
|
4
|
+
|
|
5
|
+
${0} {
|
|
6
|
+
cursor: default;
|
|
7
|
+
}
|
|
8
|
+
`),u),T=s.button(P||(P=z`
|
|
9
|
+
/* Reset button appearance */
|
|
10
|
+
appearance: none;
|
|
11
|
+
background: transparent;
|
|
12
|
+
padding: 0;
|
|
13
|
+
border-style: none;
|
|
14
|
+
outline: none;
|
|
15
|
+
color: inherit;
|
|
16
|
+
text-rendering: inherit;
|
|
17
|
+
letter-spacing: inherit;
|
|
18
|
+
word-spacing: inherit;
|
|
19
|
+
|
|
20
|
+
&:focus {
|
|
21
|
+
outline: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Change the font styles in all browsers. */
|
|
25
|
+
font: inherit;
|
|
26
|
+
|
|
27
|
+
/* Remove the margin in Firefox and Safari. */
|
|
28
|
+
margin: 0;
|
|
29
|
+
|
|
30
|
+
/* Show the overflow in Edge. */
|
|
31
|
+
overflow: visible;
|
|
32
|
+
|
|
33
|
+
/* Remove the inheritance of text transform in Firefox. */
|
|
34
|
+
text-transform: none;
|
|
35
|
+
|
|
36
|
+
/* Remove the inner border and padding in Firefox. */
|
|
37
|
+
&::-moz-focus-inner {
|
|
38
|
+
border-style: none;
|
|
39
|
+
padding: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
${0}
|
|
43
|
+
`),O),q=s.span(S||(S=z`
|
|
44
|
+
/* Reset a-tag appearance */
|
|
45
|
+
color: inherit;
|
|
46
|
+
|
|
47
|
+
&:focus {
|
|
48
|
+
outline: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.text {
|
|
52
|
+
top: calc(1em + 2em);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
${0}
|
|
56
|
+
`),O);let D;const M=["children","variant","size","fixed","disabled"],H=e.forwardRef(function(t,r){let{children:n,variant:a="Default",size:o="M",fixed:i=!1,disabled:l=!1}=t,s=x(t,M);/*#__PURE__*/return e.createElement(j,v({},s,{disabled:l,variant:a,size:o,fixed:i,ref:r}),n)}),j=s(N).withConfig({shouldForwardProp:e=>"fixed"!==e}).attrs(function(e){return v({},e,function(e){switch(e){case"Overlay":return{font:"text5",background:"surface4"};case"Default":return{font:"text2",background:"surface3"};case"Primary":return{font:"text5",background:"brand"};case"Navigation":return{font:"text5",background:"surface6"};case"Danger":return{font:"text5",background:"assertive"};default:return function(e){throw new Error(0===arguments.length?"unreachable":`unreachable (${JSON.stringify(e)})`)}(e)}}(e.variant),function(e){switch(e){case"S":return{height:32,padding:16};case"M":return{height:40,padding:24}}}(e.size))})(D||(D=(e=>e)`
|
|
57
|
+
width: ${0};
|
|
58
|
+
display: inline-grid;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
user-select: none;
|
|
63
|
+
white-space: nowrap;
|
|
64
|
+
|
|
65
|
+
${0}
|
|
66
|
+
|
|
67
|
+
/* よく考えたらheight=32って定義が存在しないな... */
|
|
68
|
+
height: ${0}px;
|
|
69
|
+
`),e=>e.fixed?"stretch":"min-content",e=>C(t=>[t.font[e.font].hover.press,t.bg[e.background].hover.press,t.typography(14).bold.preserveHalfLeading,t.padding.horizontal(e.padding),t.disabled,t.borderRadius("oval"),t.outline.default.focus]),e=>e.height);let F;const G=["variant","size","icon"],I=e.forwardRef(function(t,r){let{variant:n="Default",size:a="M",icon:o}=t,i=x(t,G);return function(e,t){let r;switch(e){case"XS":r="16";break;case"S":case"M":r="24"}const n=/^[0-9]*/.exec(t);if(null==n)throw new Error("Invalid icon name");const[a]=n;a!==r&&console.warn(`IconButton with size "${e}" expect icon size "${r}, but got "${a}"`)}(a,o),/*#__PURE__*/e.createElement(X,v({},i,{ref:r,variant:n,size:a}),/*#__PURE__*/e.createElement("pixiv-icon",{name:o}))}),X=s(N).attrs(function(e){return v({},e,function(e){switch(e){case"Default":return{font:"text3",background:"transparent"};case"Overlay":return{font:"text5",background:"surface4"}}}(e.variant),function(e){switch(e){case"XS":return{width:20,height:20};case"S":return{width:32,height:32};case"M":return{width:40,height:40}}}(e.size))})(F||(F=(e=>e)`
|
|
70
|
+
user-select: none;
|
|
71
|
+
|
|
72
|
+
width: ${0}px;
|
|
73
|
+
height: ${0}px;
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
|
|
78
|
+
${0}
|
|
79
|
+
`),e=>e.width,e=>e.height,({font:e,background:t})=>C(r=>[r.font[e],r.bg[t].hover.press,r.disabled,r.borderRadius("oval"),r.outline.default.focus]));let A,B,Y,J,K=e=>e;function Q({value:n,forceChecked:a=!1,disabled:o=!1,children:i}){const{name:l,selected:s,disabled:c,readonly:d,hasError:u,onChange:p}=t(_);f(void 0!==l,'"name" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?');const h=n===s,g=o||c,b=d&&!h,m=r(e=>{p(e.currentTarget.value)},[p]);/*#__PURE__*/return e.createElement(U,{"aria-disabled":g||b},/*#__PURE__*/e.createElement(V,{name:l,value:n,checked:a||h,hasError:u,onChange:m,disabled:g||b}),null!=i&&/*#__PURE__*/e.createElement(W,null,i))}const U=s.label(A||(A=K`
|
|
80
|
+
display: grid;
|
|
81
|
+
grid-template-columns: auto 1fr;
|
|
82
|
+
grid-gap: ${0};
|
|
83
|
+
align-items: center;
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
|
|
86
|
+
${0}
|
|
87
|
+
`),({theme:e})=>p(e.spacing[4]),C(e=>[e.disabled])),V=s.input.attrs({type:"radio"})(B||(B=K`
|
|
88
|
+
/** Make prior to browser default style */
|
|
89
|
+
&[type='radio'] {
|
|
90
|
+
appearance: none;
|
|
91
|
+
display: block;
|
|
92
|
+
box-sizing: border-box;
|
|
93
|
+
|
|
94
|
+
padding: 6px;
|
|
95
|
+
|
|
96
|
+
width: 20px;
|
|
97
|
+
height: 20px;
|
|
98
|
+
|
|
99
|
+
${0};
|
|
100
|
+
|
|
101
|
+
&:not(:checked) {
|
|
102
|
+
border-width: 2px;
|
|
103
|
+
border-style: solid;
|
|
104
|
+
border-color: ${0};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&:checked {
|
|
108
|
+
${0}
|
|
109
|
+
|
|
110
|
+
&::after {
|
|
111
|
+
content: '';
|
|
112
|
+
display: block;
|
|
113
|
+
width: 8px;
|
|
114
|
+
height: 8px;
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
|
|
117
|
+
${0}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
${0}
|
|
122
|
+
}
|
|
123
|
+
`),({hasError:e=!1})=>C(t=>[t.borderRadius("oval"),t.bg.text5.hover.press,e&&t.outline.assertive]),({theme:e})=>e.color.text4,C(e=>e.bg.brand.hover.press),C(e=>[e.bg.text5.hover.press,e.borderRadius("oval")]),C(e=>e.outline.default.focus)),W=s.div(Y||(Y=K`
|
|
124
|
+
${0}
|
|
125
|
+
`),C(e=>[e.typography(14)])),Z=s.div(J||(J=K`
|
|
126
|
+
display: grid;
|
|
127
|
+
grid-template-columns: 1fr;
|
|
128
|
+
grid-gap: ${0};
|
|
129
|
+
`),({theme:e})=>p(e.spacing[8])),_=e.createContext({name:void 0,selected:void 0,disabled:!1,readonly:!1,hasError:!1,onChange(){throw new Error("Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?")}});function ee({className:t,value:n,label:a,name:o,onChange:i,disabled:l,readonly:s,hasError:c,children:d}){const u=r(e=>{i(e)},[i]);/*#__PURE__*/return e.createElement(_.Provider,{value:{name:o,selected:n,disabled:null!=l&&l,readonly:null!=s&&s,hasError:null!=c&&c,onChange:u}},/*#__PURE__*/e.createElement(Z,{role:"radiogroup","aria-orientation":"vertical","aria-label":a,"aria-invalid":c,className:t},d))}const te=n({name:void 0,selected:[],disabled:!1,readonly:!1,hasError:!1,onChange(){throw new Error("Cannot find `onChange()` handler. Perhaps you forgot to wrap it with `<SelectGroup />` ?")}});let re,ne,ae,oe,ie,le=e=>e;function se({value:n,forceChecked:a=!1,disabled:o=!1,onChange:i,variant:l="default",children:s}){const{name:c,selected:d,disabled:u,readonly:p,hasError:h,onChange:g}=t(te);f(void 0!==c,'"name" is not Provided for <Select>. Perhaps you forgot to wrap with <SelectGroup> ?');const b=d.includes(n)||a,m=o||u||p,v=r(e=>{e.currentTarget instanceof HTMLInputElement&&(i&&i({value:n,selected:e.currentTarget.checked}),g({value:n,selected:e.currentTarget.checked}))},[i,g,n]);/*#__PURE__*/return e.createElement(ce,{"aria-disabled":m},/*#__PURE__*/e.createElement(ue,{name:c,value:n,hasError:h,checked:b,disabled:m,onChange:v,overlay:"overlay"===l,"aria-invalid":h}),/*#__PURE__*/e.createElement(pe,{overlay:"overlay"===l,hasError:h,"aria-hidden":!0},/*#__PURE__*/e.createElement("pixiv-icon",{name:"24/Check","unsafe-non-guideline-scale":16/24})),Boolean(s)&&/*#__PURE__*/e.createElement(de,null,s))}const ce=s.label(re||(re=le`
|
|
130
|
+
display: grid;
|
|
131
|
+
grid-template-columns: auto 1fr;
|
|
132
|
+
align-items: center;
|
|
133
|
+
position: relative;
|
|
134
|
+
cursor: pointer;
|
|
135
|
+
${0} {
|
|
136
|
+
cursor: default;
|
|
137
|
+
}
|
|
138
|
+
gap: ${0};
|
|
139
|
+
${0}
|
|
140
|
+
`),u,({theme:e})=>p(e.spacing[4]),C(e=>e.disabled)),de=s.div(ne||(ne=le`
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
${0}
|
|
144
|
+
`),C(e=>[e.typography(14),e.font.text1])),ue=s.input.attrs({type:"checkbox"})(ae||(ae=le`
|
|
145
|
+
&[type='checkbox'] {
|
|
146
|
+
appearance: none;
|
|
147
|
+
display: block;
|
|
148
|
+
width: 20px;
|
|
149
|
+
height: 20px;
|
|
150
|
+
margin: 0;
|
|
151
|
+
|
|
152
|
+
&:checked {
|
|
153
|
+
${0}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
${0};
|
|
157
|
+
}
|
|
158
|
+
`),C(e=>e.bg.brand.hover.press),({hasError:e,overlay:t})=>C(r=>[r.bg.text3.hover.press,r.borderRadius("oval"),e&&!t&&r.outline.assertive,t&&r.bg.surface4])),pe=s.div(oe||(oe=le`
|
|
159
|
+
position: absolute;
|
|
160
|
+
top: -2px;
|
|
161
|
+
left: -2px;
|
|
162
|
+
box-sizing: border-box;
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
justify-content: center;
|
|
166
|
+
|
|
167
|
+
${0}
|
|
168
|
+
|
|
169
|
+
${0}
|
|
170
|
+
`),({hasError:e,overlay:t})=>C(r=>[r.width.px(24),r.height.px(24),r.borderRadius("oval"),r.font.text5,e&&t&&r.outline.assertive]),({overlay:e})=>e&&c(ie||(ie=le`
|
|
171
|
+
border-color: ${0};
|
|
172
|
+
border-width: 2px;
|
|
173
|
+
border-style: solid;
|
|
174
|
+
`),({theme:e})=>e.color.text5));function fe({className:t,name:n,ariaLabel:a,selected:o,onChange:i,disabled:l=!1,readonly:s=!1,hasError:c=!1,children:d}){const u=r(e=>{const t=o.indexOf(e.value);e.selected?t<0&&i([...o,e.value]):t>=0&&i([...o.slice(0,t),...o.slice(t+1)])},[i,o]);/*#__PURE__*/return e.createElement(te.Provider,{value:{name:n,selected:Array.from(new Set(o)),disabled:l,readonly:s,hasError:c,onChange:u}},/*#__PURE__*/e.createElement("div",{className:t,"aria-label":a,"data-testid":"SelectGroup"},d))}let he,ge,be,me=e=>e;const ve=["className","type"];function xe(t){const{disabled:r,className:n}=t,i=a(()=>v({},t,{"aria-label":"children"in t?void 0:t.label,isDisabled:t.disabled,isSelected:t.checked}),[t]),l=g(i),s=o(null),c=x(h(i,l,s).inputProps,ve);/*#__PURE__*/return e.createElement(ye,{className:n,"aria-disabled":r},/*#__PURE__*/e.createElement(Ee,v({},c,{ref:s})),"children"in t?/*#__PURE__*/e.createElement(we,null,t.children):void 0)}const ye=s.label(he||(he=me`
|
|
175
|
+
display: inline-grid;
|
|
176
|
+
grid-template-columns: auto 1fr;
|
|
177
|
+
gap: ${0};
|
|
178
|
+
cursor: pointer;
|
|
179
|
+
outline: 0;
|
|
180
|
+
|
|
181
|
+
${0}
|
|
182
|
+
|
|
183
|
+
${0} {
|
|
184
|
+
cursor: default;
|
|
185
|
+
}
|
|
186
|
+
`),({theme:e})=>p(e.spacing[4]),C(e=>e.disabled),u),we=s.div(ge||(ge=me`
|
|
187
|
+
${0}
|
|
188
|
+
`),C(e=>e.typography(14))),Ee=s.input.attrs({type:"checkbox"})(be||(be=me`
|
|
189
|
+
&[type='checkbox'] {
|
|
190
|
+
appearance: none;
|
|
191
|
+
display: inline-flex;
|
|
192
|
+
position: relative;
|
|
193
|
+
box-sizing: border-box;
|
|
194
|
+
width: 28px;
|
|
195
|
+
border: 2px solid transparent;
|
|
196
|
+
transition: box-shadow 0.2s, background-color 0.2s;
|
|
197
|
+
cursor: inherit;
|
|
198
|
+
${0}
|
|
199
|
+
|
|
200
|
+
&::after {
|
|
201
|
+
content: '';
|
|
202
|
+
position: absolute;
|
|
203
|
+
display: block;
|
|
204
|
+
top: 0;
|
|
205
|
+
left: 0;
|
|
206
|
+
width: 12px;
|
|
207
|
+
height: 12px;
|
|
208
|
+
transform: translateX(0);
|
|
209
|
+
transition: transform 0.2s;
|
|
210
|
+
${0}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
&:checked {
|
|
214
|
+
${0}
|
|
215
|
+
|
|
216
|
+
&::after {
|
|
217
|
+
transform: translateX(12px);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
`),C(e=>[e.borderRadius(16),e.height.px(16),e.bg.text4.hover.press,e.outline.default.focus]),C(e=>[e.bg.text5.hover.press,e.borderRadius("oval")]),C(e=>e.bg.brand.hover.press));let $e,ke,Ce,Re,Pe=e=>e;const Se=["style","className","label","required","requiredText","subLabel"],ze=e.forwardRef(function(t,r){let{style:n,className:a,label:o,required:i=!1,requiredText:l,subLabel:s}=t,c=x(t,Se);/*#__PURE__*/return e.createElement(qe,{style:n,className:a},/*#__PURE__*/e.createElement(Ne,v({ref:r},c),o),i&&/*#__PURE__*/e.createElement(Oe,null,l),/*#__PURE__*/e.createElement(Te,null,/*#__PURE__*/e.createElement("span",null,s)))}),Le=d(s),Ne=s.label($e||($e=Pe`
|
|
222
|
+
${0}
|
|
223
|
+
`),Le(e=>[e.typography(14).bold,e.font.text1])),Oe=s.span(ke||(ke=Pe`
|
|
224
|
+
${0}
|
|
225
|
+
`),Le(e=>[e.typography(14),e.font.text3])),Te=s.div(Ce||(Ce=Pe`
|
|
226
|
+
${0}
|
|
227
|
+
`),Le(e=>[e.typography(14),e.font.text3.hover.press,e.outline.default.focus])),qe=s.div(Re||(Re=Pe`
|
|
228
|
+
display: inline-flex;
|
|
229
|
+
align-items: center;
|
|
230
|
+
|
|
231
|
+
> ${0} {
|
|
232
|
+
${0}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
> ${0} {
|
|
236
|
+
${0}
|
|
237
|
+
}
|
|
238
|
+
`),Oe,Le(e=>e.margin.left(4)),Te,Le(e=>e.margin.left("auto")));let De,Me,He,je,Fe,Ge,Ie,Xe,Ae,Be,Ye,Je,Ke,Qe,Ue=e=>e;const Ve=["onChange"],We=["onChange"],Ze=d(s);function _e(...e){return t=>{for(const r of e)"function"==typeof r?r(t):null!==r&&(r.current=t)}}function et(e){return Array.from(e).length}const tt=e.forwardRef(function(t,r){/*#__PURE__*/return e.createElement(void 0!==t.multiline&&t.multiline?nt:rt,v({ref:r},t))}),rt=e.forwardRef(function(t,n){var a;let{onChange:s}=t,c=x(t,Ve);const{className:d,showLabel:u=!1,showCount:p=!1,label:f,requiredText:h,subLabel:g,disabled:y=!1,required:w,invalid:E=!1,assistiveText:$,maxLength:k,prefix:C="",suffix:R=""}=c,{visuallyHiddenProps:P}=m(),S=o(null),z=o(null),L=o(null),[N,O]=i(et(null!=(a=c.value)?a:"")),[T,q]=i(0),[D,M]=i(0),H=void 0===c.value,j=r(e=>{const t=et(e);void 0!==k&&t>k||(H&&O(t),null==s||s(e))},[k,H,s]);l(()=>{var e;O(et(null!=(e=c.value)?e:""))},[c.value]);const{inputProps:F,labelProps:G,descriptionProps:I,errorMessageProps:X}=b(v({inputElementType:"input",isDisabled:y,isRequired:w,validationState:E?"invalid":"valid",description:!E&&$,errorMessage:E&&$,onChange:j},c),S);return l(()=>{const e=new ResizeObserver(e=>{q(e[0].contentRect.width)}),t=new ResizeObserver(e=>{M(e[0].contentRect.width)});return null!==z.current&&e.observe(z.current),null!==L.current&&t.observe(L.current),()=>{t.disconnect(),e.disconnect()}},[]),/*#__PURE__*/e.createElement(at,{className:d,isDisabled:y},/*#__PURE__*/e.createElement(ot,v({label:f,requiredText:h,required:w,subLabel:g},G,u?{}:P)),/*#__PURE__*/e.createElement(it,null,/*#__PURE__*/e.createElement(lt,{ref:z},/*#__PURE__*/e.createElement(ct,null,C)),/*#__PURE__*/e.createElement(dt,v({ref:_e(n,S),invalid:E,extraLeftPadding:T,extraRightPadding:D},F)),/*#__PURE__*/e.createElement(st,{ref:L},/*#__PURE__*/e.createElement(ct,null,R),p&&k&&/*#__PURE__*/e.createElement(ft,null,N,"/",k))),null!=$&&0!==$.length&&/*#__PURE__*/e.createElement(gt,v({invalid:E},E?X:I),$))}),nt=e.forwardRef(function(t,n){var a;let{onChange:s}=t,c=x(t,We);const{className:d,showCount:u=!1,showLabel:p=!1,label:f,requiredText:h,subLabel:g,disabled:y=!1,required:w,invalid:E=!1,assistiveText:$,maxLength:k,autoHeight:C=!1,rows:R=4}=c,{visuallyHiddenProps:P}=m(),S=o(null),z=o(null),[L,N]=i(et(null!=(a=c.value)?a:"")),[O,T]=i(R),q=r(e=>{var t,r;const n=null!=(t=null==(r=`${e.value}\n`.match(/\n/g))?void 0:r.length)?t:1;R<=n&&T(n)},[R]),D=void 0===c.value,M=r(e=>{const t=et(e);void 0!==k&&t>k||(D&&N(t),C&&null!==S.current&&q(S.current),null==s||s(e))},[C,k,D,s,q]);l(()=>{var e;N(et(null!=(e=c.value)?e:""))},[c.value]);const{inputProps:H,labelProps:j,descriptionProps:F,errorMessageProps:G}=b(v({inputElementType:"textarea",isDisabled:y,isRequired:w,validationState:E?"invalid":"valid",description:!E&&$,errorMessage:E&&$,onChange:M},c),z);return l(()=>{C&&null!==S.current&&q(S.current)},[C,q]),/*#__PURE__*/e.createElement(at,{className:d,isDisabled:y},/*#__PURE__*/e.createElement(ot,v({label:f,requiredText:h,required:w,subLabel:g},j,p?P:{})),/*#__PURE__*/e.createElement(ut,{rows:O},/*#__PURE__*/e.createElement(pt,v({ref:_e(S,n,z),invalid:E,rows:O},H)),u&&/*#__PURE__*/e.createElement(ht,null,L)),null!=$&&0!==$.length&&/*#__PURE__*/e.createElement(gt,v({invalid:E},E?G:F),$))}),at=s.div(De||(De=Ue`
|
|
239
|
+
display: flex;
|
|
240
|
+
flex-direction: column;
|
|
241
|
+
|
|
242
|
+
${0}
|
|
243
|
+
`),e=>e.isDisabled&&{opacity:e.theme.elementEffect.disabled.opacity}),ot=s(ze)(Me||(Me=Ue`
|
|
244
|
+
${0}
|
|
245
|
+
`),Ze(e=>e.margin.bottom(8))),it=s.div(He||(He=Ue`
|
|
246
|
+
height: 40px;
|
|
247
|
+
display: grid;
|
|
248
|
+
position: relative;
|
|
249
|
+
`)),lt=s.span(je||(je=Ue`
|
|
250
|
+
position: absolute;
|
|
251
|
+
top: 50%;
|
|
252
|
+
left: 8px;
|
|
253
|
+
transform: translateY(-50%);
|
|
254
|
+
`)),st=s.span(Fe||(Fe=Ue`
|
|
255
|
+
position: absolute;
|
|
256
|
+
top: 50%;
|
|
257
|
+
right: 8px;
|
|
258
|
+
transform: translateY(-50%);
|
|
259
|
+
|
|
260
|
+
display: flex;
|
|
261
|
+
gap: 8px;
|
|
262
|
+
`)),ct=s.span(Ge||(Ge=Ue`
|
|
263
|
+
user-select: none;
|
|
264
|
+
|
|
265
|
+
${0}
|
|
266
|
+
`),Ze(e=>[e.typography(14).preserveHalfLeading,e.font.text2])),dt=s.input(Ie||(Ie=Ue`
|
|
267
|
+
border: none;
|
|
268
|
+
box-sizing: border-box;
|
|
269
|
+
outline: none;
|
|
270
|
+
font-family: inherit;
|
|
271
|
+
|
|
272
|
+
/* Prevent zooming for iOS Safari */
|
|
273
|
+
transform-origin: top left;
|
|
274
|
+
transform: scale(0.875);
|
|
275
|
+
width: calc(100% / 0.875);
|
|
276
|
+
height: calc(100% / 0.875);
|
|
277
|
+
font-size: calc(14px / 0.875);
|
|
278
|
+
line-height: calc(22px / 0.875);
|
|
279
|
+
padding-top: calc(9px / 0.875);
|
|
280
|
+
padding-bottom: calc(9px / 0.875);
|
|
281
|
+
padding-left: calc((8px + ${0}px) / 0.875);
|
|
282
|
+
padding-right: calc((8px + ${0}px) / 0.875);
|
|
283
|
+
border-radius: calc(4px / 0.875);
|
|
284
|
+
|
|
285
|
+
/* Display box-shadow for iOS Safari */
|
|
286
|
+
appearance: none;
|
|
287
|
+
|
|
288
|
+
${0}
|
|
289
|
+
|
|
290
|
+
&::placeholder {
|
|
291
|
+
${0}
|
|
292
|
+
}
|
|
293
|
+
`),e=>e.extraLeftPadding,e=>e.extraRightPadding,e=>Ze(t=>[t.bg.surface3.hover,t.outline.default.focus,e.invalid&&t.outline.assertive,t.font.text2]),Ze(e=>e.font.text3)),ut=s.div(Xe||(Xe=Ue`
|
|
294
|
+
display: grid;
|
|
295
|
+
position: relative;
|
|
296
|
+
|
|
297
|
+
${0};
|
|
298
|
+
`),({rows:e})=>c(Ae||(Ae=Ue`
|
|
299
|
+
max-height: calc(22px * ${0} + 18px);
|
|
300
|
+
`),e)),pt=s.textarea(Be||(Be=Ue`
|
|
301
|
+
border: none;
|
|
302
|
+
box-sizing: border-box;
|
|
303
|
+
outline: none;
|
|
304
|
+
resize: none;
|
|
305
|
+
font-family: inherit;
|
|
306
|
+
|
|
307
|
+
/* Prevent zooming for iOS Safari */
|
|
308
|
+
transform-origin: top left;
|
|
309
|
+
transform: scale(0.875);
|
|
310
|
+
width: calc(100% / 0.875);
|
|
311
|
+
font-size: calc(14px / 0.875);
|
|
312
|
+
line-height: calc(22px / 0.875);
|
|
313
|
+
padding: calc(9px / 0.875) calc(8px / 0.875);
|
|
314
|
+
border-radius: calc(4px / 0.875);
|
|
315
|
+
|
|
316
|
+
${0};
|
|
317
|
+
|
|
318
|
+
/* Display box-shadow for iOS Safari */
|
|
319
|
+
appearance: none;
|
|
320
|
+
|
|
321
|
+
${0}
|
|
322
|
+
|
|
323
|
+
&::placeholder {
|
|
324
|
+
${0}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/* Hide scrollbar for Chrome, Safari and Opera */
|
|
328
|
+
&::-webkit-scrollbar {
|
|
329
|
+
display: none;
|
|
330
|
+
}
|
|
331
|
+
/* Hide scrollbar for IE, Edge and Firefox */
|
|
332
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
333
|
+
scrollbar-width: none; /* Firefox */
|
|
334
|
+
`),({rows:e})=>c(Ye||(Ye=Ue`
|
|
335
|
+
height: calc(22px / 0.875 * ${0} + 18px / 0.875);
|
|
336
|
+
`),e),e=>Ze(t=>[t.bg.surface3.hover,t.outline.default.focus,e.invalid&&t.outline.assertive,t.font.text2]),Ze(e=>e.font.text3)),ft=s.span(Je||(Je=Ue`
|
|
337
|
+
${0}
|
|
338
|
+
`),Ze(e=>[e.typography(14).preserveHalfLeading,e.font.text3])),ht=s.span(Ke||(Ke=Ue`
|
|
339
|
+
position: absolute;
|
|
340
|
+
bottom: 9px;
|
|
341
|
+
right: 8px;
|
|
342
|
+
|
|
343
|
+
${0}
|
|
344
|
+
`),Ze(e=>[e.typography(14).preserveHalfLeading,e.font.text3])),gt=s.p(Qe||(Qe=Ue`
|
|
345
|
+
${0}
|
|
346
|
+
`),e=>Ze(t=>[t.typography(14),t.margin.top(8),t.margin.bottom(0),t.font[e.invalid?"assertive":"text1"]]));export{H as Button,N as Clickable,$ as ComponentAbstraction,I as IconButton,Q as Radio,ee as RadioGroup,se as Select,fe as SelectGroup,xe as Switch,tt as TextField,k as useComponentAbstraction};
|
|
347
|
+
//# sourceMappingURL=index.modern.js.map
|