ingred-ui 25.12.0 → 25.13.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.
|
@@ -26,3 +26,4 @@ export declare const SplitWithIcon: StoryObj<DropdownButtonProps>;
|
|
|
26
26
|
export declare const WithSelectedValue: StoryObj<DropdownButtonProps>;
|
|
27
27
|
export declare const WithConfirmModal: StoryObj<DropdownButtonProps>;
|
|
28
28
|
export declare const WithLoading: StoryObj<DropdownButtonProps>;
|
|
29
|
+
export declare const WithHeadingAndHelpText: StoryObj<DropdownButtonProps>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { ButtonSize, ButtonColor } from "../Button/Button";
|
|
3
3
|
export type DropdownButtonColor = Exclude<ButtonColor, "danger">;
|
|
4
|
-
export type
|
|
4
|
+
export type ContextMenu2ButtonContent = {
|
|
5
|
+
type?: undefined;
|
|
5
6
|
text: string;
|
|
6
7
|
onClick: () => void;
|
|
7
8
|
divideTop?: boolean;
|
|
@@ -11,6 +12,18 @@ export type ContextMenu2ContentProp = {
|
|
|
11
12
|
checked?: boolean;
|
|
12
13
|
onChange?: (checked: boolean) => void;
|
|
13
14
|
};
|
|
15
|
+
export type ContextMenu2HeadingContent = {
|
|
16
|
+
type: "heading";
|
|
17
|
+
text: string;
|
|
18
|
+
divideTop?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type ContextMenu2HelpTextContent = {
|
|
21
|
+
type: "helpText";
|
|
22
|
+
text: string;
|
|
23
|
+
prepend?: ReactNode;
|
|
24
|
+
divideTop?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type ContextMenu2ContentProp = ContextMenu2ButtonContent | ContextMenu2HeadingContent | ContextMenu2HelpTextContent;
|
|
14
27
|
export type DropdownButtonProps = {
|
|
15
28
|
size?: ButtonSize;
|
|
16
29
|
color?: DropdownButtonColor;
|
package/dist/index.es.js
CHANGED
|
@@ -20,16 +20,13 @@ import*as e from"react";import t,{forwardRef as n,useState as r,useRef as i,useE
|
|
|
20
20
|
${Q};
|
|
21
21
|
${({theme:e,gap:t})=>t&&`gap: ${e.spacing*t}px`};
|
|
22
22
|
`,K=y.div`
|
|
23
|
-
border-
|
|
23
|
+
border-bottom: ${({theme:e})=>`1px solid ${e.palette.gray.main}`};
|
|
24
24
|
`,ee=y(q)`
|
|
25
|
-
background-color: ${({
|
|
25
|
+
background-color: ${({theme:e})=>e.palette.gray.highlight};
|
|
26
26
|
color: ${({disabled:e,theme:t})=>e?t.palette.text.disabled:"auto"};
|
|
27
27
|
cursor: ${({disabled:e})=>e?"not-allowed":"pointer"};
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
justify-content: space-between;
|
|
30
|
-
transition:
|
|
31
|
-
background-color 0.3s,
|
|
32
|
-
border-top 0.3s;
|
|
33
30
|
`,te=y.div`
|
|
34
31
|
padding: ${({theme:e})=>e.spacing}px
|
|
35
32
|
${({theme:e})=>2*e.spacing}px;
|
|
@@ -54,7 +51,7 @@ import*as e from"react";import t,{forwardRef as n,useState as r,useRef as i,useE
|
|
|
54
51
|
overflow: ${({overflow:e})=>e};
|
|
55
52
|
transition: 0.3s all;
|
|
56
53
|
background-color: ${({theme:e})=>e.palette.white};
|
|
57
|
-
`,oe=n((function(e,n){var{title:a,expanded:l=!1,disabled:s=!1,onChange:c,children:d}=e,u=$(e,["title","expanded","disabled","onChange","children"]);const p=j(),[m,h]=r(l),[g,f]=r("0px"),[b,v]=r("hidden"),y=i(null),x=e=>{var t,n,r,i;e?f(`${null!==(n=null===(t=y.current)||void 0===t?void 0:t.scrollHeight)&&void 0!==n?n:0}px`):(f(`${null!==(i=null===(r=y.current)||void 0===r?void 0:r.scrollHeight)&&void 0!==i?i:0}px`),v("hidden"),setTimeout((()=>f("0px")),100))},w=(e,t)=>{h(t),x(t),c&&c(e,t)};return o((()=>{h(l),x(l)}),[l]),t.createElement(K,Object.assign({ref:n},u),t.createElement(ee,{display:"flex",tabIndex:s?-1:0,role:"button","aria-expanded":m,"aria-controls":`accordion-content-${a}`,expanded:m,disabled:s,onClick:e=>{w(e,!m)},onKeyDown:e=>{"Enter"===e.key&&w(e,!m)}},t.createElement(te,null,a),t.createElement(re,null,t.createElement(ne,{expanded:m},t.createElement(U,{name:"arrow_bottom",size:"md",color:s?p.palette.text.disabled:"black"})))),t.createElement(ie,{ref:y,height:g,overflow:b,onTransitionEnd:()=>{m&&(f("auto"),v("visible"))}},d))})),ae=y.p`
|
|
54
|
+
`,oe=n((function(e,n){var{title:a,expanded:l=!1,disabled:s=!1,onChange:c,children:d}=e,u=$(e,["title","expanded","disabled","onChange","children"]);const p=j(),[m,h]=r(l),[g,f]=r("0px"),[b,v]=r("hidden"),y=i(null),x=e=>{var t,n,r,i;e?f(`${null!==(n=null===(t=y.current)||void 0===t?void 0:t.scrollHeight)&&void 0!==n?n:0}px`):(f(`${null!==(i=null===(r=y.current)||void 0===r?void 0:r.scrollHeight)&&void 0!==i?i:0}px`),v("hidden"),setTimeout((()=>f("0px")),100))},w=(e,t)=>{h(t),x(t),c&&c(e,t)};return o((()=>{h(l),x(l)}),[l]),t.createElement(K,Object.assign({ref:n},u),t.createElement(ee,{display:"flex",tabIndex:s?-1:0,role:"button","aria-expanded":m,"aria-disabled":s,"aria-controls":`accordion-content-${a}`,expanded:m,disabled:s,onClick:e=>{s||w(e,!m)},onKeyDown:e=>{s||"Enter"===e.key&&w(e,!m)}},t.createElement(te,null,a),t.createElement(re,null,t.createElement(ne,{expanded:m},t.createElement(U,{name:"arrow_bottom",size:"md",color:s?p.palette.text.disabled:"black"})))),t.createElement(ie,{ref:y,height:g,overflow:b,onTransitionEnd:()=>{m&&(f("auto"),v("visible"))}},d))})),ae=y.p`
|
|
58
55
|
color: ${({color:e})=>e};
|
|
59
56
|
text-align: ${({align:e})=>e};
|
|
60
57
|
font-size: ${({fontSize:e})=>e};
|
|
@@ -2260,6 +2257,10 @@ object-assign
|
|
|
2260
2257
|
}
|
|
2261
2258
|
`,kw=y.div`
|
|
2262
2259
|
position: relative;
|
|
2260
|
+
display: flex;
|
|
2261
|
+
flex-direction: column;
|
|
2262
|
+
justify-content: center;
|
|
2263
|
+
gap: 4px;
|
|
2263
2264
|
box-sizing: border-box;
|
|
2264
2265
|
padding: 8px ${({isSmallLayout:e})=>e?6:10}px;
|
|
2265
2266
|
height: 100%;
|
|
@@ -2345,10 +2346,6 @@ object-assign
|
|
|
2345
2346
|
font-size: 13px;
|
|
2346
2347
|
line-height: 16px;
|
|
2347
2348
|
color: ${({theme:e})=>e.palette.black};
|
|
2348
|
-
|
|
2349
|
-
&:not(:last-child) {
|
|
2350
|
-
margin-bottom: 4px;
|
|
2351
|
-
}
|
|
2352
2349
|
`,$w=y.button`
|
|
2353
2350
|
padding: 0;
|
|
2354
2351
|
border: 0;
|
|
@@ -2680,7 +2677,7 @@ object-assign
|
|
|
2680
2677
|
`,GC=y.span`
|
|
2681
2678
|
display: flex;
|
|
2682
2679
|
align-items: center;
|
|
2683
|
-
`,jC=({size:t="medium",color:n="primary",onClick:r,split:i=!1,contents:o=[],disabled:a=!1,children:l,icon:s,selectedValue:c,menuWidth:d=200,loading:u=!1})=>{const p=j(),m=!!u,h="string"==typeof u?u:u?"Loading...":void 0,g=((e,t)=>e?p.palette.text.disabled:"primary"===t?p.palette.white:p.palette.black)(a||m,n),f=e.useMemo((()=>({small:"16px",medium:"18px",large:"20px"}[t])),[t]),b=void 0!==c?c:l,v=e.useMemo((()=>e.createElement(U,{name:"arrow_bottom",size:ZC[t].arrowIconSize,color:g})),[t,g]),y=e.useMemo((()=>m?e.createElement(Cs,{width:f}):null),[m,f]),x=!!s,w=!!b,C=m?x?y:void 0:s,E=m?!x&&w||x&&w?h:void 0:b,I=m?x?y:void 0:s,k=(()=>{if(m&&(!x||w))return w?h:void 0})(),A=i?e.createElement(zC,{role:"button"},e.createElement(BC,{size:t,color:n,inline:!0,disabled:a||m,icon:C,onClick:r},E),e.createElement(_C,{size:t,color:n,inline:!0,disabled:a||m,"data-testid":"menu-toggle"},v)):e.createElement(PC,{size:t,color:n,disabled:a||m,"data-testid":"menu-toggle",icon:I},e.createElement(FC,null,m?k?e.createElement(e.Fragment,null,"string"==typeof k?e.createElement(ps,null,k):k,e.createElement(GC,null,e.createElement(gs,{pr:.5}),v)):e.createElement(GC,null,e.createElement(gs,{pr:.5}),v):e.createElement(e.Fragment,null,b&&e.createElement(ps,null,b),e.createElement(GC,null,e.createElement(gs,{pr:.5}),v))));return e.createElement(ts,null,e.createElement(es,{trigger:A,width:d},o.map(((t,n)=>e.createElement(e.Fragment,{key:`${n}-${t.text}`},t.divideTop&&e.createElement(os,null),void 0!==t.checked?e.createElement(Bi,{closeOnChange:!0,checked:t.checked,color:t.color,disabled:t.disabled,prepend:t.icon,onChange:t.onChange},t.text):e.createElement(Ni,{closeOnClick:!0,color:t.color,disabled:t.disabled,prepend:t.icon,onClick:t.onClick},t.text))))))},WC=y.div`
|
|
2680
|
+
`,jC=({size:t="medium",color:n="primary",onClick:r,split:i=!1,contents:o=[],disabled:a=!1,children:l,icon:s,selectedValue:c,menuWidth:d=200,loading:u=!1})=>{const p=j(),m=!!u,h="string"==typeof u?u:u?"Loading...":void 0,g=((e,t)=>e?p.palette.text.disabled:"primary"===t?p.palette.white:p.palette.black)(a||m,n),f=e.useMemo((()=>({small:"16px",medium:"18px",large:"20px"}[t])),[t]),b=void 0!==c?c:l,v=e.useMemo((()=>e.createElement(U,{name:"arrow_bottom",size:ZC[t].arrowIconSize,color:g})),[t,g]),y=e.useMemo((()=>m?e.createElement(Cs,{width:f}):null),[m,f]),x=!!s,w=!!b,C=m?x?y:void 0:s,E=m?!x&&w||x&&w?h:void 0:b,I=m?x?y:void 0:s,k=(()=>{if(m&&(!x||w))return w?h:void 0})(),A=i?e.createElement(zC,{role:"button"},e.createElement(BC,{size:t,color:n,inline:!0,disabled:a||m,icon:C,onClick:r},E),e.createElement(_C,{size:t,color:n,inline:!0,disabled:a||m,"data-testid":"menu-toggle"},v)):e.createElement(PC,{size:t,color:n,disabled:a||m,"data-testid":"menu-toggle",icon:I},e.createElement(FC,null,m?k?e.createElement(e.Fragment,null,"string"==typeof k?e.createElement(ps,null,k):k,e.createElement(GC,null,e.createElement(gs,{pr:.5}),v)):e.createElement(GC,null,e.createElement(gs,{pr:.5}),v):e.createElement(e.Fragment,null,b&&e.createElement(ps,null,b),e.createElement(GC,null,e.createElement(gs,{pr:.5}),v))));return e.createElement(ts,null,e.createElement(es,{trigger:A,width:d},o.map(((t,n)=>e.createElement(e.Fragment,{key:`${n}-${t.text}`},t.divideTop&&e.createElement(os,null),(t=>"heading"===t.type?e.createElement(ns,null,t.text):"helpText"===t.type?e.createElement(is,{prepend:t.prepend},t.text):void 0!==t.checked?e.createElement(Bi,{closeOnChange:!0,checked:t.checked,color:t.color,disabled:t.disabled,prepend:t.icon,onChange:t.onChange},t.text):e.createElement(Ni,{closeOnClick:!0,color:t.color,disabled:t.disabled,prepend:t.icon,onClick:t.onClick},t.text))(t))))))},WC=y.div`
|
|
2684
2681
|
background-color: ${({theme:e})=>e.palette.background.default};
|
|
2685
2682
|
border: 1px solid ${({theme:e})=>e.palette.divider};
|
|
2686
2683
|
border-radius: ${({theme:e})=>e.radius}px;
|
|
@@ -2698,7 +2695,7 @@ object-assign
|
|
|
2698
2695
|
`,UC=y(XC)`
|
|
2699
2696
|
border-bottom: 1px solid ${({theme:e})=>e.palette.divider};
|
|
2700
2697
|
`,QC=y(oe)`
|
|
2701
|
-
border-
|
|
2698
|
+
border-bottom: none;
|
|
2702
2699
|
`,qC=y.div`
|
|
2703
2700
|
padding-left: ${({theme:e})=>e.spacing/2}px;
|
|
2704
2701
|
`,KC=({children:e,disableCheckbox:n=!1,item:r,onAdd:i,onRemove:o})=>{var a;return t.createElement(q,{display:"flex",justifyContent:"space-between"},r.items||n?e:t.createElement(Rh,{checked:null!==(a=null==r?void 0:r.selected)&&void 0!==a&&a,onClick:()=>{r.selected?null==o||o(r):null==i||i(r)}},e))},eE=({disableCheckbox:e,items:n,onAdd:r,onRemove:i})=>t.createElement(YC,null,n.map(((o,a)=>t.createElement(t.Fragment,null,o.items?t.createElement(UC,{key:o.id},t.createElement(QC,{title:t.createElement(qC,null,t.createElement(KC,{item:o,onAdd:r,onRemove:i},o.content))},t.createElement(eE,{disableCheckbox:e,items:o.items,onAdd:r,onRemove:i}))):t.createElement(JC,{key:o.id,isLastIndex:a+1===n.length},t.createElement(KC,{disableCheckbox:e,item:o,onAdd:r,onRemove:i},o.content)))))),tE=y.div`
|