amotify 0.2.232 → 0.2.234
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/demo/next/package.json +1 -1
- package/dist/@declares/property.d.ts +1 -0
- package/dist/@utils/LaunchReactApp.d.ts +5 -3
- package/dist/atoms/Box.d.ts +2 -2
- package/dist/atoms/Box.js +1 -1
- package/dist/atoms/Logo.d.ts +14 -14
- package/dist/atoms/Logo.js +3 -3
- package/dist/fn/Button.d.ts +3 -3
- package/dist/fn/Button.js +1 -1
- package/dist/fn/Effect/index.d.ts +2 -2
- package/dist/fn/Input/Autocomplete.d.ts +3 -3
- package/dist/fn/Input/Autocomplete.js +1 -1
- package/dist/fn/Input/List.d.ts +12 -12
- package/dist/fn/Input/List.js +1 -1
- package/dist/fn/Input/Search.d.ts +1 -1
- package/dist/fn/Input/Search.js +1 -1
- package/dist/fn/Input/Segmented.d.ts +7 -7
- package/dist/fn/Input/Segmented.js +1 -1
- package/dist/fn/Input/Select.d.ts +1 -1
- package/dist/fn/Input/TextField.d.ts +1 -1
- package/dist/fn/Input/Time/index.d.ts +9 -9
- package/dist/fn/Input/Time/index.js +1 -1
- package/dist/fn/Loader/index.d.ts +1 -1
- package/dist/fn/Loader/index.js +1 -1
- package/dist/fn/Sheet.d.ts +3 -3
- package/dist/fn/Sheet.js +1 -1
- package/dist/fn/Snackbar.d.ts +3 -3
- package/dist/fn/Snackbar.js +1 -1
- package/dist/fn/Table/Data.d.ts +1 -1
- package/dist/fn/Table/Wrapper.d.ts +1 -1
- package/dist/fn/Table/Wrapper.js +1 -1
- package/dist/fn/Tooltips.d.ts +1 -1
- package/dist/index.d.ts +24 -24
- package/dist/mols/List.d.ts +6 -6
- package/dist/mols/List.js +1 -1
- package/dist/mols/Literal.d.ts +1 -1
- package/dist/mols/Literal.js +1 -1
- package/package.json +7 -7
- package/demo/next/src/app/(hooks)/useClientEffect.tsx +0 -83
- package/demo/next/src/app/(router)/designbook/page.tsx +0 -2891
- package/demo/next/src/app/(router)/page.tsx +0 -211
- package/demo/next/src/app/apis/test/route.ts +0 -9
- package/demo/next/src/app/layout.tsx +0 -26
- package/demo/next/src/server/app.ts +0 -42
- package/demo/next/src/server/fin.ts +0 -11
- package/demo/next/src/server/index.ts +0 -4
package/demo/next/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ReactElement } from '../@declares';
|
|
3
3
|
declare global {
|
|
4
|
-
namespace
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
namespace React {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'amotify-app': React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
8
|
+
}
|
|
7
9
|
}
|
|
8
10
|
}
|
|
9
11
|
}
|
package/dist/atoms/Box.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ declare namespace Box {
|
|
|
7
7
|
} & StyleTags.BasicElement & Omit<React.ComponentPropsWithRef<HTMLComponent>, 'htmlTag'> & React.HTMLAttributes<any>;
|
|
8
8
|
type DefaultInput = Input<'div'>;
|
|
9
9
|
type Component = {
|
|
10
|
-
<T extends React.ElementType = 'div'>(p: Input<T>): JSX.Element;
|
|
10
|
+
<T extends React.ElementType = 'div'>(p: Input<T>): React.JSX.Element;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
declare const Box: <T extends
|
|
13
|
+
declare const Box: <T extends React.ElementType<any, keyof React.JSX.IntrinsicElements> = "div">(p: Box.Input<T>) => import("react/jsx-runtime").JSX.Element | null;
|
|
14
14
|
export { Box, Box as default };
|
package/dist/atoms/Box.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,c as p,d as
|
|
1
|
+
import{b as o,c as p,d as a}from"../chunk-C5N2D3ZX.js";import{jsx as c}from"react/jsx-runtime";import{GenerateHTMLProps as s}from"../@utils";const m=e=>{let{ref:l}=e,n=s(e),{htmlTag:T}=n,r=a(n,["htmlTag"]);const t=T||"div";return t?c(t,p(o({},r),{ref:l})):null};export{m as Box,m as default};
|
package/dist/atoms/Logo.d.ts
CHANGED
|
@@ -11,21 +11,21 @@ declare namespace Logo {
|
|
|
11
11
|
color?: 'normal' | 'white';
|
|
12
12
|
};
|
|
13
13
|
type Methods = {
|
|
14
|
-
Icon: (p: ComponentInput) => JSX.Element;
|
|
15
|
-
Title: (p: ComponentInput) => JSX.Element;
|
|
14
|
+
Icon: (p: ComponentInput) => React.JSX.Element;
|
|
15
|
+
Title: (p: ComponentInput) => React.JSX.Element;
|
|
16
16
|
Brands: {
|
|
17
|
-
MingooIcon: (p: DefaultLogoInput) => JSX.Element;
|
|
18
|
-
MingooTitle: (p: DefaultLogoInput) => JSX.Element;
|
|
19
|
-
MingooLogoH: (p: DefaultLogoInput) => JSX.Element;
|
|
20
|
-
MingooLogoV: (p: DefaultLogoInput) => JSX.Element;
|
|
21
|
-
ComunIcon: (p: DefaultLogoInput) => JSX.Element;
|
|
22
|
-
ComunTitle: (p: DefaultLogoInput) => JSX.Element;
|
|
23
|
-
ComunLogoH: (p: DefaultLogoInput) => JSX.Element;
|
|
24
|
-
ComunLogoV: (p: DefaultLogoInput) => JSX.Element;
|
|
25
|
-
Google: (p: DefaultLogoInput) => JSX.Element;
|
|
26
|
-
Facebook: (p: DefaultLogoInput) => JSX.Element;
|
|
27
|
-
Twitter: (p: DefaultLogoInput) => JSX.Element;
|
|
28
|
-
LINE: (p: DefaultLogoInput) => JSX.Element;
|
|
17
|
+
MingooIcon: (p: DefaultLogoInput) => React.JSX.Element;
|
|
18
|
+
MingooTitle: (p: DefaultLogoInput) => React.JSX.Element;
|
|
19
|
+
MingooLogoH: (p: DefaultLogoInput) => React.JSX.Element;
|
|
20
|
+
MingooLogoV: (p: DefaultLogoInput) => React.JSX.Element;
|
|
21
|
+
ComunIcon: (p: DefaultLogoInput) => React.JSX.Element;
|
|
22
|
+
ComunTitle: (p: DefaultLogoInput) => React.JSX.Element;
|
|
23
|
+
ComunLogoH: (p: DefaultLogoInput) => React.JSX.Element;
|
|
24
|
+
ComunLogoV: (p: DefaultLogoInput) => React.JSX.Element;
|
|
25
|
+
Google: (p: DefaultLogoInput) => React.JSX.Element;
|
|
26
|
+
Facebook: (p: DefaultLogoInput) => React.JSX.Element;
|
|
27
|
+
Twitter: (p: DefaultLogoInput) => React.JSX.Element;
|
|
28
|
+
LINE: (p: DefaultLogoInput) => React.JSX.Element;
|
|
29
29
|
};
|
|
30
30
|
Images: {
|
|
31
31
|
mingooIcon: string;
|
package/dist/atoms/Logo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as l,c
|
|
1
|
+
import{b as l,c,d as p}from"../chunk-C5N2D3ZX.js";import{Fragment as A,jsx as e,jsxs as I}from"react/jsx-runtime";import T from"jmini";import{Flex as L,Img as C}from".";import{LogoClasses as a}from"../@styles/componentClasses";const h={ComunIcon:()=>e("svg",{viewBox:"0,0,1200,1200",className:a("ComunIcon"),children:I("g",{children:[e("path",{d:`
|
|
2
2
|
M
|
|
3
3
|
100,600
|
|
4
4
|
A 500,500 0 0,0 600,1100
|
|
@@ -40,7 +40,7 @@ import{b as l,c as g,d as p}from"../chunk-C5N2D3ZX.js";import{Fragment as A,jsx
|
|
|
40
40
|
L600,600
|
|
41
41
|
L600,300
|
|
42
42
|
Z
|
|
43
|
-
`,className:[
|
|
43
|
+
`,className:[a("P"),a("P_"+t)].join(" "),style:{fill:"#c56ff0"}}),e("path",{d:`
|
|
44
44
|
M
|
|
45
45
|
600,300
|
|
46
46
|
A 45,45 0 0,1 600,390
|
|
@@ -48,4 +48,4 @@ import{b as l,c as g,d as p}from"../chunk-C5N2D3ZX.js";import{Fragment as A,jsx
|
|
|
48
48
|
L600,600
|
|
49
49
|
L600,300
|
|
50
50
|
Z
|
|
51
|
-
`,className:[
|
|
51
|
+
`,className:[a("P"),a("P_"+t)].join(" "),style:{fill:"#ea6093"}})]});return I("svg",{viewBox:"0,0,1200,1200",className:a("MingooIcon"),children:[o(0),o(1),o(2),o(3),o(4),o(5),o(6),o(7),o(8)]})}},u={Icon:o=>e(r.Icon,c(l({},o),{children:e(h.MingooIcon,{})})),Title:o=>e(r.Title,c(l({className:a("ComunTitle"),height:"auto"},o),{freeCSS:l({letterSpacing:"3px"},o.freeCSS),children:"mingoo"})),LogoH:o=>{let n=o,{size:t,color:g}=n,i=p(n,["size","color"]);return I(L,c(l({gap:"1/2",flexCenter:!0},i),{children:[e(u.Icon,{size:t,color:g}),e(u.Title,{size:t,color:g})]}))},LogoV:o=>{let n=o,{size:t,color:g}=n,i=p(n,["size","color"]);return I(L,c(l({flexType:"col",gap:"1/2"},i),{children:[e(u.Icon,{margin:"auto",size:t,color:g}),e(u.Title,{size:t,color:g})]}))}},m={Icon:o=>e(r.Icon,c(l({},o),{children:e(h.ComunIcon,{})})),Title:o=>e(r.Title,c(l({className:a("ComunTitle"),height:"auto"},o),{freeCSS:l({letterSpacing:"3px"},o.freeCSS),children:"comun"})),LogoH:o=>{let n=o,{size:t,color:g}=n,i=p(n,["size","color"]);return I(L,c(l({gap:"1/2",flexCenter:!0},i),{children:[e(m.Icon,{size:t,color:g}),e(m.Title,{size:t,color:g})]}))},LogoV:o=>{let n=o,{size:t,color:g}=n,i=p(n,["size","color"]);return I(L,c(l({flexType:"col",gap:"1/2"},i),{children:[e(m.Icon,{margin:"auto",size:t,color:g}),e(m.Title,{size:t,color:g})]}))}};let s="https://cdn.amotify.com/";const r={Icon:o=>{let f=o,{size:t="R",color:g="normal",className:i="",children:n}=f,S=p(f,["size","color","className","children"]);return e(L,c(l({className:[i,a("Icon"),a("Size_"+t)].join(" "),verticalAlign:"center"},S),{children:T.is.function(n)?e(n,{}):n}))},Title:o=>{let f=o,{size:t="R",color:g="normal",className:i="",children:n}=f,S=p(f,["size","color","className","children"]);return e(L,c(l({className:[i,a("Title"),a("Size_"+t)].join(" "),verticalAlign:"center",fontColor:g=="white"?"white":"logo"},S),{children:T.is.function(n)?e(n,{}):n}))},Brands:{MingooIcon:u.Icon,MingooTitle:u.Title,MingooLogoH:u.LogoH,MingooLogoV:u.LogoV,ComunIcon:m.Icon,ComunTitle:m.Title,ComunLogoH:m.LogoH,ComunLogoV:m.LogoV,Google:o=>e(r.Icon,c(l({},o),{children:e(C,{src:s+"@env/@logos/brands/Google_Icon.svg",alt:""})})),Facebook:o=>e(r.Icon,c(l({},o),{children:e(C,{src:s+"@env/@logos/brands/FaceBook_Icon.svg",alt:""})})),Twitter:o=>e(r.Icon,c(l({},o),{children:e(C,{src:s+"@env/@logos/brands/Twitter_Icon.svg",alt:""})})),LINE:o=>e(r.Icon,c(l({},o),{children:e(C,{src:s+"@env/@logos/brands/Line_Icon.svg",alt:""})}))},Images:{mingooIcon:s+"@env/@logos/mingoo/icon.png",mingooIconClear:s+"@env/@logos/mingoo/iconClear.png",comunIcon:s+"@env/@logos/comun/icon.png",comunIconClear:s+"@env/@logos/comun/iconClear.png",defaultIcon:o=>s+"@env/@icon/"+(o||"image")+".png"}};export{r as Logo,r as default};
|
package/dist/fn/Button.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ declare namespace Button {
|
|
|
43
43
|
};
|
|
44
44
|
} & React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
45
45
|
namespace Methods {
|
|
46
|
-
type Component = (p: Input) => JSX.Element;
|
|
46
|
+
type Component = (p: Input) => React.JSX.Element;
|
|
47
47
|
type FNs = {
|
|
48
48
|
Plain: ButtonTypes.SizeMethods<Input<''>>;
|
|
49
49
|
Link: ButtonTypes.SizeMethods<Input<''>>;
|
|
@@ -63,7 +63,7 @@ declare namespace Label {
|
|
|
63
63
|
htmlFor?: string;
|
|
64
64
|
} & React.LabelHTMLAttributes<HTMLLabelElement>;
|
|
65
65
|
namespace Methods {
|
|
66
|
-
type Component = (p: Input) => JSX.Element;
|
|
66
|
+
type Component = (p: Input) => React.JSX.Element;
|
|
67
67
|
type FNs = {
|
|
68
68
|
Plain: ButtonTypes.SizeMethods<Input<''>>;
|
|
69
69
|
Link: ButtonTypes.SizeMethods<Input<''>>;
|
|
@@ -87,7 +87,7 @@ declare namespace Anchor {
|
|
|
87
87
|
shiftQueryParams?: boolean;
|
|
88
88
|
} & React.ButtonHTMLAttributes<HTMLAnchorElement>;
|
|
89
89
|
namespace Methods {
|
|
90
|
-
type Component = (p: Input) => JSX.Element;
|
|
90
|
+
type Component = (p: Input) => React.JSX.Element;
|
|
91
91
|
type FNs = {
|
|
92
92
|
Plain: ButtonTypes.SizeMethods<Input<''>>;
|
|
93
93
|
Link: ButtonTypes.SizeMethods<Input<''>>;
|
package/dist/fn/Button.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as s,c as i,d as B,e as z}from"../chunk-C5N2D3ZX.js";import{jsx as p}from"react/jsx-runtime";import L,{UUID as
|
|
1
|
+
import{b as s,c as i,d as B,e as z}from"../chunk-C5N2D3ZX.js";import{jsx as p}from"react/jsx-runtime";import L,{UUID as R}from"jmini";import{pageRouter as k,ReadStyleSet as P}from"../@utils";import{Input as E}from".";import{Box as I}from"../atoms";import{ButtonClasses as c}from"../@styles/componentClasses";const x={Size:(l,t,o,n)=>{let e={fontSize:"inherit"};return o=o||"R",t=="plain"?{}:(t=="link"?o=="xsmall"?e.fontSize="0.xs":o=="small"?e.fontSize="1.mini":o=="regular"||o=="large"&&(e.fontSize="3.paragraph"):e=s({borderRadius:"2.tone.secondary",transition:"middle",position:"relative",textAlign:"center"},e),o=="xsmall"?e=i(s({},e),{padding:["1/3","2/3"],fontSize:"0.xs",borderRadius:"3.tone.tertiary"}):o=="small"?e=i(s({},e),{padding:["1/2","3/4"],fontSize:"1.mini",borderRadius:"3.tone.tertiary"}):o=="regular"?e.padding=["3/4",1]:o=="large"&&(e.padding=[1,2],e.fontSize="3.paragraph",e.isSemiBoldFont=!0),e)},Tone:(l,t,o,n)=>{let e={display:"inlineBlock",fontWeight:"inherit",fontColor:"inherit",border:"unset"};return t=="plain"||(t=="link"?(e.fontColor="theme",e.textAlign="left",e.backgroundColor="trans"):t=="normal"?e=i(s({},e),{backgroundColor:"trans"}):t=="border"?e=i(s({},e),{backgroundColor:"layer.1",border:"2.normal",borderStyle:"solid",boxShadow:"0.min"}):t=="prime"?(e=i(s({},e),{isSemiBoldFont:!0,fontColor:"white",backgroundColor:n,boxShadow:"0.normal",ssEffectsOnActive:["shrink","push","ripple.white"]}),n=="white"&&(e=i(s({},e),{fontColor:"theme",ssEffectsOnActive:["shrink","push","ripple.cloud"]}))):t=="sub"?e=i(s({},e),{fontColor:n,ssEffectsOnActive:["shrink","ripple.cloud"]}):t=="clear"?e=i(s({},e),{fontColor:n,backgroundColor:"trans",ssEffectsOnActive:["shrink","ripple.cloud"]}):t=="fillToBorder"?e=i(s({},e),{boxShadow:"0.normal",border:"2.normal",borderWidth:2,borderColor:n,fontColor:n,backgroundColor:n}):t=="borderToFill"&&(e=i(s({},e),{fontColor:n,boxShadow:"0.normal",border:"2.normal",borderWidth:2,borderColor:n,backgroundColor:n})),n=="cloud"&&(e.fontColor="2.normal"),t!="link"&&(e=s({position:"relative",ssEffectsOnActive:["shrink","push"]},e))),e}},F=l=>{let t=P(s({isLocked:!1,isActive:!1,isActiveStyles:{},isActiveClassName:"",tabIndex:0,className:"",color:"theme",tone:"border","aria-label":R()},l)),o=t.seed;{let{isLocked:y=!1,isActive:m=!1,isActiveStyles:h={},isActiveClassName:C="",tone:r="border",size:u="regular",color:a="theme",className:T=""}=t;t=s(s(s({},x.Size(l.seed,r,u,a)),x.Tone(l.seed,r,u,a)),t),t.className=[T,c("Wrap"),c("isNeutral_"+!m),c("isLocked_"+y),c("Tone_"+r),c("Color_"+a),c("Tone_"+r+"_Color_"+a)].join(" "),m&&(t=s(s({className:[t.className,C].join(" ")},t),h))}if(o=="button"){let n=t,{isLocked:y,isActive:m,isActiveClassName:h,isActiveStyles:C,submitOption:r,onClick:u}=n,a=B(n,["isLocked","isActive","isActiveClassName","isActiveStyles","submitOption","onClick"]);return r&&(r=s({acceptInvalidForm:!1,submitDelegationKey:"auxEnter"},r),a=i(s({},a),{"data-form-submit-button":r.formName,"data-sdfike":L.flatArray(r.submitDelegationKey).join(",")})),p(I,i(s({htmlTag:"button",fontHeight:"inherit"},a),{onClick:T=>z(void 0,null,function*(){if(y||(u&&u(T),!r))return;let S=yield E.CollectForm(r.formName);!S.valid&&!r.acceptInvalidForm||r.callback(S.data,S.valid)})}))}else if(o=="label"){let e=t,{isLocked:y,isActive:m,isActiveClassName:h,isActiveStyles:C,onClick:r}=e,u=B(e,["isLocked","isActive","isActiveClassName","isActiveStyles","onClick"]);return p(I,i(s({htmlTag:"label"},u),{onClick:a=>{y||r&&r(a)}}))}else if(o=="anchor"){let M=t,{isLocked:y,isActive:m,isActiveClassName:h,isActiveStyles:C,onClick:r,href:u="",newTab:a,sync:T,shiftQueryParams:S}=M,A=B(M,["isLocked","isActive","isActiveClassName","isActiveStyles","onClick","href","newTab","sync","shiftQueryParams"]);return p(I,i(s({htmlTag:"button"},A),{onClick:f=>{if(y)return;if(r)return r(f);let v=f.ctrlKey||f.metaKey,N=a||!!v,b=u;if(S&&(b+=location.search),T){k.pushSync(b);return}k.push(b,!!N)}}))}return null},d=function(l,t){const o=e=>p(F,s({seed:l,tone:t,size:"regular"},e)),n=o;return n.Plain=e=>p(o,s({size:"plain",tone:t},e)),n.XS=e=>p(o,s({size:"xsmall",tone:t},e)),n.S=e=>p(o,s({size:"small",tone:t},e)),n.R=e=>p(o,s({size:"regular",tone:t},e)),n.L=e=>p(o,s({size:"large",tone:t},e)),n},g=function(l){const o=n=>p(F,s({seed:l,tone:"prime",size:"regular"},n));return o.Plain=d(l,"plain"),o.Link=d(l,"link"),o.Normal=d(l,"normal"),o.Border=d(l,"border"),o.Prime=d(l,"prime"),o.Sub=d(l,"sub"),o.Clear=d(l,"clear"),o.FillToBorder=d(l,"fillToBorder"),o.BorderToFill=d(l,"borderToFill"),o},w=g("button"),H=g("label"),K=g("anchor");export{K as Anchor,w as Button,H as Label};
|
|
@@ -5,7 +5,7 @@ import Pudding from './Pudding';
|
|
|
5
5
|
declare const Effect: {
|
|
6
6
|
Ripple: Ripple.Methods;
|
|
7
7
|
Pudding: Pudding.Methods;
|
|
8
|
-
FadeIn:
|
|
9
|
-
FadeUp:
|
|
8
|
+
FadeIn: React.FC<FadeIn.Input>;
|
|
9
|
+
FadeUp: React.FC<FadeUp.Input>;
|
|
10
10
|
};
|
|
11
11
|
export { Effect, Effect as default };
|
|
@@ -24,10 +24,10 @@ declare namespace Autocomplete {
|
|
|
24
24
|
DynamicOptionsOnSearch?: DynamicOptionsOnSearch<T>;
|
|
25
25
|
DynamicOptionsOnSearchDelay?: number;
|
|
26
26
|
SelectedComponent?: {
|
|
27
|
-
(p: SelectedComponentProps<T>): JSX.Element;
|
|
27
|
+
(p: SelectedComponentProps<T>): React.JSX.Element;
|
|
28
28
|
};
|
|
29
29
|
SelectorComponent?: {
|
|
30
|
-
(p: SelectorComponentProps<T>): JSX.Element;
|
|
30
|
+
(p: SelectorComponentProps<T>): React.JSX.Element;
|
|
31
31
|
};
|
|
32
32
|
SelectorStyles?: StyleTags.PropsNFreeCSS;
|
|
33
33
|
SelectorPosition?: 1 | 2 | 3 | 4;
|
|
@@ -90,7 +90,7 @@ declare namespace Autocomplete {
|
|
|
90
90
|
set_validate: React.Dispatch<React.SetStateAction<InputTypes.Validation.Result>>;
|
|
91
91
|
};
|
|
92
92
|
type Component = {
|
|
93
|
-
<T = Value>(p: Input<Value<T>>): JSX.Element;
|
|
93
|
+
<T = Value>(p: Input<Value<T>>): React.JSX.Element;
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
declare const Autocomplete: Autocomplete.Component;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as m,c as g,d as ee,e as te}from"../../chunk-C5N2D3ZX.js";import{Fragment as X,jsx as l,jsxs as V}from"react/jsx-runtime";import{useState as b,useEffect as F,useRef as ue}from"react";import p,{UUID as D}from"jmini";import{ExtractStyles as ce}from"../../@utils";import{Box as E,Span as pe,FAI as H,Column as oe}from"../../atoms";import{Literal as q,Row as P}from"../../mols";import{Button as ae}from"../Button";import{Loader as de}from"../Loader";import{Sheet as Se}from"../Sheet";import{OptionalInputWrapper as fe,BoxWrapper as me,CoreEffects as M,DefaultBoxishStyles as ve}from"./core";import{InputAutocompleteClasses as W}from"../../@styles/componentClasses";import{InputLabel as ye}from"./Label";import{RightIcon as le}from".";function _e(e){let{value:t,states:s}=e,{required:d,options:o,min:a,max:n}=s;a=a||0,n=n||65535;let S=[],u=t.filter(c=>c!==null).length;return d&&(u||S.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),u<a&&S.push({type:"invalid",label:a+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),u>n&&S.push({type:"invalid",label:n+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!S.filter(({type:c})=>c=="invalid").length,notice:S}}const z={InitOptions:e=>{let t=[];return e.forEach(s=>{if(!s)return;let{type:d,label:o,value:a,searchValue:n}=s,S=n||p.is.string(o)&&o||""||p.is.string(a)&&a||p.Stringify(a||"")||"";p.is.nullish(o)&&(o=String(a)),t.push(g(m({id:D()},s),{searchValue:S,type:d||"selector",label:o,value:a}))}),t},FilterSelectableOptions:(e,t,s)=>{let d=e;return s||(d=e.filter(o=>(o==null?void 0:o.type)!="label")),p.scope(()=>{if(!t)return;let o=t.toLower().replace(/ /g,"");d=d.filter(a=>(a.searchValue||"").toLower().replace(/ /g,"").includes(o))}),d}},L={Shallow:e=>{let{rootStates:t,val_status:s}=e,d=ce(t);return l(E,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(q.Description,g(m({className:t.className},d),{position:"absolute",width:1,freeCSS:g(m({},d.freeCSS),{color:"orange"}),"data-id":"shallow_"+s.componentId,children:l(E,{"data-input-value-shallow":s.componentId,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:s,set_keyword:d,val_optionFocused:o,set_optionFocused:a,val_preventOpenSelector:n,set_preventOpenSelector:S,val_openSelector:u,set_openSelector:c,val_status:i,set_status:f,val_activeInput:v,set_activeInput:y,val_validate:C,set_validate:O}=e,Y=t,{tone:h,required:A,form:I,className:w,multiSelect:T,enableFormSubmit:K,checkValidationAtFirst:N,onValidate:$,onValidateDelay:Q,onUpdateValue:U,onUpdateValidValue:J,onUserAction:j,value:G="",options:R,leftIndicator:B,rightIndicator:k,leftIcon:ge,rightIcon:he,componentId:Ie,status_id:be,wrapStyles:Ce,emptySelect:De,SearchInput:Oe,SearchInputPlaceholder:we,SelectedComponent:Te,SelectorComponent:Re,SelectorStyles:ke,SelectorPosition:xe,DynamicOptionsOnSearch:Ve,DynamicOptionsOnSearchDelay:Ae}=Y,r=ee(Y,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","emptySelect","SearchInput","SearchInputPlaceholder","SelectedComponent","SelectorComponent","SelectorStyles","SelectorPosition","DynamicOptionsOnSearch","DynamicOptionsOnSearchDelay"]);return F(()=>{var x;if(t.disabled||!u||p.is.exist(o))return;let _=z.FilterSelectableOptions(e.val_options,s,!1);a(((x=_[0])==null?void 0:x.id)||"")},[s]),F(()=>{if(i.eventType!="init"&&i.eventType!="override"){if(t.max==i.dataValue.length){c(!1),S(!0),d("");return}p("#SearchInput_"+t.componentId).focus()}},[i.dataValue]),F(()=>{if(i.eventType=="override")return;let _="autocomplete-click-"+t.componentId;if(!u){p(document).removeEvent([_]);return}p('[data-input-origin="'+t.componentId+'"]')&&(p("#SearchInput_"+t.componentId).focus(),p(document).addEvent({eventID:_,eventType:"mousedown",callback:ie=>{let Z=p(ie.target),re=!!p(Z).parent("."+W("Core")).length,se=!!p(Z).parent("."+W("Selector")).length;re||se||(c(!1),y(!1))},options:{passive:!1}}))},[u]),V(X,{children:[l(E,g(m({tabIndex:0},r),{"data-disabled":t.disabled,"data-show-validation":M.isShowValidation(C,i,!!N),"data-component-id":i.componentId,"data-input-origin":i.componentId,"data-focus":!!u||!!v,className:[w,W("Core")].join(" "),onFocus:_=>{if(r!=null&&r.onFocus&&(r==null||r.onFocus(_)),!t.disabled){if(n)return S(!1);c(!0),y(!0),_.preventDefault()}},onBlur:_=>{r!=null&&r.onBlur&&(r==null||r.onBlur(_))},onCompositionStart:_=>{r!=null&&r.onCompositionStart&&(r==null||r.onCompositionStart(_))},onCompositionEnd:_=>{r!=null&&r.onCompositionEnd&&(r==null||r.onCompositionEnd(_))},onClick:_=>{r!=null&&r.onClick&&(r==null||r.onClick(_)),!t.disabled&&(c(!0),y(!0))},onKeyDown:_=>{let{key:x}=_;K&&M.SubmitForm(_,I),!u&&(x==" "||x=="ArrowDown"||x=="ArrowUp"||x=="Enter")&&(c(!0),y(!0))},children:V(P.Left,{gap:0,children:[l(pe,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),V(P.Left,{flexWrap:!0,flexSizing:0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(L.Selected,m({},e)),l(L.SearchInput,m({},e))]})]})})),u&&l(L.Selector,m({},e))]})},SearchInput:e=>{let{rootStates:t,val_status:s,set_status:d}=e;return t.disabled||!e.val_openSelector&&!e.val_activeInput?null:l(E,{htmlTag:"input",id:"SearchInput_"+t.componentId,placeholder:t.SearchInputPlaceholder||"\u691C\u7D22...",opacity:e.val_openSelector?"max":"middle",transition:"middle",flexSizing:0,fontSize:"inherit",border:"unset",backgroundColor:"trans",value:e.val_keyword,freeCSS:{outline:"none"},onFocus:o=>{d(a=>g(m({},a),{eventID:D(),isFocusing:!0}))},onBlur:o=>{e.set_activeInput(!1),d(a=>g(m({},a),{eventID:D(),isFocusing:!1}))},onCompositionStart:o=>{d(a=>g(m({},a),{eventID:D(),isComposing:!0}))},onCompositionEnd:o=>{d(a=>g(m({},a),{eventID:D(),isComposing:!1}))},onKeyDown:o=>{let{key:a,metaKey:n,ctrlKey:S}=o,u=n||S;a=="Tab"?(e.set_openSelector(!1),e.set_activeInput(!1),e.set_preventOpenSelector(!1)):a==" "?p.scope(()=>{e.val_openSelector||e.val_keyword||(o.preventDefault(),e.set_openSelector(!0))}):a=="Backspace"?p.scope(()=>{if(e.val_keyword)return;let c=[...e.val_status.dataValue];c.pop(),e.set_status(i=>g(m({},i),{dataValue:c,eventType:"update",eventID:D()}))}):a=="Enter"&&p.scope(()=>{if(s.isComposing||(o==null?void 0:o.keyCode)===229)return;if(!e.val_openSelector)return e.set_openSelector(!0);if(!e.val_optionFocused)return;let c=e.val_options.find(f=>(f==null?void 0:f.id)==e.val_optionFocused);if(!c)return;let{value:i}=c;e.set_status(f=>{let v=[...f.dataValue];return p.scope(()=>{if(i===null)return v=[];f.dataValue.includes(i)?v=v.filter(C=>C!==i):t.multiSelect?v.push(i):v=[i]}),g(m({},f),{dataValue:v,eventType:"update",eventID:D()})}),e.set_optionsModified(!0),e.set_keyword("")}),p.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(a))return;if(o.preventDefault(),!e.val_openSelector)return e.set_openSelector(!0);let c=a=="ArrowDown"?1:-1,i=z.FilterSelectableOptions(e.val_options),f=i.length-1,v=null;p.scope(()=>{var C,O,h,A,I,w;let y=i.findIndex(T=>(T==null?void 0:T.id)==e.val_optionFocused);if(y==-1&&(y=0),c==1){if(v=(C=i[0])==null?void 0:C.id,u){v=(O=i[f])==null?void 0:O.id;return}if(y==-1||y==f)return;v=(h=i[y+1])==null?void 0:h.id}else{if(v=(A=i[f])==null?void 0:A.id,u){v=(I=i[0])==null?void 0:I.id;return}if(y==-1||y==0)return;v=(w=i[y-1])==null?void 0:w.id}}),e.set_optionFocused(v)}),t.enableFormSubmit&&M.SubmitForm(o,e.rootStates.form)},onChange:o=>{let n=o.target.value;e.set_openSelector(!0),e.set_keyword(n)}},"searchInput")},Selector:e=>{var S;let[t,s]=b("idle"),[d,o]=b("idle");F(()=>{if(!e.rootStates.DynamicOptionsOnSearch||!e.val_openSelector)return;if(e.val_optionsModified)return e.set_optionsModified(!1);if(e.val_status.isComposing)return;if(t=="idle")return s("ok");o("fetch");let u="autocomplete-search-"+e.rootStates.componentId;e.set_optionFocused(""),p.interval.once(()=>te(void 0,null,function*(){var f;let c=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);o("idle");let i=z.InitOptions(c||[]);e.set_options(i),e.set_optionFocused(((f=i[0])==null?void 0:f.id)||"")}),e.rootStates.DynamicOptionsOnSearchDelay||500,u)},[e.val_keyword,e.val_status.isComposing]),F(()=>{let u=p(`[data-selector-id="${e.val_status.componentId}"]`)[0];if(!u)return;let c=p(`[data-autocomplete-input-value="${e.val_optionFocused}"]`)[0];c&&(u.scrollTop=c.offsetTop-24)},[e.val_optionFocused]);let a=z.FilterSelectableOptions(e.val_options,e.rootStates.DynamicOptionsOnSearch?"":e.val_keyword,!0),n={};switch(e.rootStates.SelectorPosition){case 1:n.bottom="100%",n.left=0,n.paddingBottom="1/3";break;case 2:n.bottom="100%",n.right=0,n.paddingBottom="1/3";break;case 3:n.top="100%",n.left=0,n.paddingTop="1/3";break;case 4:n.top="100%",n.right=0,n.paddingTop="1/3";break;default:break}return l(E,g(m({position:"absolute"},n),{freeCSS:m({minWidth:"75%",zIndex:1e3},n.freeCSS),children:l(Se.Body,g(m({className:W("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto","data-selector-id":e.val_status.componentId},e.rootStates.SelectorStyles),{freeCSS:m({maxHeight:12*24},(S=e.rootStates.SelectorStyles)==null?void 0:S.freeCSS),children:V(oe,{gap:"1/12",padding:[1,0],children:[d=="fetch"&&l(P.Center,{padding:"1/2",children:l(de.Theme.R,{showInitial:!0})}),d!="fetch"&&V(X,{children:[!a.length&&l(q.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}),a.map((u,c)=>{if(!u)return null;let{type:i,value:f}=u,v=e.val_optionFocused==u.id,y=e.val_status.dataValue.includes(f),C=e.rootStates.SelectorComponent;return l(oe,{"data-autocomplete-input-value":u.id,children:l(C,{option:u,isFocused:v,isSelected:y,addCallback:()=>{e.set_status(O=>{let h=[...O.dataValue];return p.scope(()=>{if(f===null)return h=[];O.dataValue.includes(f)?h=h.filter(I=>I!==f):e.rootStates.multiSelect?h.push(f):h=[f]}),g(m({},O),{dataValue:h,eventType:"update",eventID:D()})})}})},u.id)})]})]})}))}))},Selected:e=>{let{rootStates:t,val_status:s,set_status:d,val_optionsDict:o}=e,a=[];return s.dataValue.forEach(n=>{let S=o[p.Stringify(n)];if(!S)return;let u=t.SelectedComponent,c=S.label;(S==null?void 0:S.value)===null&&(c=""),a.push(l(E,{className:W("SelectedCell"),children:l(u,{value:S==null?void 0:S.value,label:c,removeCallback:i=>{if(i.stopPropagation(),i.preventDefault(),t.disabled)return;let f=[...s.dataValue];f=f.filter(v=>v!==n),d(v=>g(m({},v),{dataValue:f,eventType:"update",eventID:D()}))}})},p.Stringify(S==null?void 0:S.value)||D()))}),l(X,{children:a})},Core:e=>{var J,j,G;let{value:t}=e,[s,d]=b(!1),[o,a]=b(!1),[n,S]=b(!1),[u,c]=b(!1),[i,f]=b(""),[v,y]=b(e.options),[C,O]=b(((J=e.options.find(R=>{var B;return(R==null?void 0:R.value)===((B=e.value)==null?void 0:B[0])}))==null?void 0:J.id)||((j=e.options[0])==null?void 0:j.id)||""),[h,A]=b({}),[I,w]=b(M.DefaultStatus(e.componentId,t)),[T,K]=b({ok:!1,notice:[]}),N=ue(!1);F(()=>{o||(N.current?y(e.options):N.current=!0)},[p.Stringify((G=e.options)==null?void 0:G.map(R=>R.value))]),F(()=>{if(!v.length)return;let R=[...v],B=m({},h);R.forEach(k=>{(k==null?void 0:k.type)!="label"&&(B[p.Stringify(k==null?void 0:k.value)]=k)}),A(B)},[v]);let $={rootStates:e,val_options:v,set_options:y,val_optionFocused:C,set_optionFocused:O,val_optionsDict:h,set_optionsDict:A,val_optionsModified:o,set_optionsModified:a,val_preventOpenSelector:s,set_preventOpenSelector:d,val_openSelector:n,set_openSelector:S,val_activeInput:u,set_activeInput:c,val_keyword:i,set_keyword:f,val_status:I,set_status:w,val_validate:T,set_validate:K},Q=!!e.multiSelect;M.CommonEffects({type:Q?"autocomplete.multi":"autocomplete.single",states:e,val_status:I,set_status:w,val_validate:T,set_validate:K,SystemValidation:_e});let U=I.dataValue.length&&I.dataValue[0]!==null;return U=U||n||u,V(me,{val_status:I,set_status:w,val_validate:T,states:e,children:[l(ye,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:U}),l(L.Shallow,m({},$)),l(L.Button,m({},$))]})}},ne=e=>{let t=m({},e);return t=g(m({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:s,isSelected:d,isFocused:o,addCallback:a})=>s?(s==null?void 0:s.type)=="label"?l(X,{children:s.label}):l(ae.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:o,isActiveStyles:{backgroundColor:"cloud"},onClick:a,children:V(P.Left,{gap:"1/2",children:[d&&l(H.Check,{fontColor:"theme"}),l(q.Supplement,{transition:"short",children:s.label})]})}):null,SelectedComponent:({value:s,label:d,removeCallback:o})=>V(P.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[l(E,{padding:[0,"1/4"],children:d}),l(ae.Clear,{flexSizing:"none",color:"nega",fontColor:"4.thin",tabIndex:-1,isRounded:!0,padding:"1/4",onClick:o,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:l(H.X,{})})]}),SelectorPosition:3},t),{freeCSS:m({cursor:"pointer"},t.freeCSS)}),t.multiSelect||(t.min=0,t.max=1),t.options=t.options||[],t.emptySelect&&(t.options=[{value:null,label:l(q.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=p.flatArray(t.value),t.options=z.InitOptions(t.options),p.is.nullish(t.rightIcon)&&(t.rightIcon=l(le,{children:l(H.Search,{})}),t.disabled&&(t.rightIcon=l(le,{fontColor:"5.translucent",children:l(H.Ban,{})}))),t.rightIcon&&(t=m({paddingRight:3},t)),t.leftIcon&&(t=m({paddingLeft:3},t)),l(fe,{componentId:t.componentId,children:L.Core,states:ve(t)})};export{ne as Autocomplete,ne as default};
|
|
1
|
+
import{b as m,c as g,d as ee,e as te}from"../../chunk-C5N2D3ZX.js";import{Fragment as X,jsx as l,jsxs as V}from"react/jsx-runtime";import{useState as b,useEffect as F,useRef as ue}from"react";import p,{UUID as D}from"jmini";import{ExtractStyles as ce}from"../../@utils";import{Box as E,Span as pe,FAI as H,Column as oe}from"../../atoms";import{Literal as q,Row as P}from"../../mols";import{Button as ae}from"../Button";import{Loader as de}from"../Loader";import{Sheet as Se}from"../Sheet";import{OptionalInputWrapper as fe,BoxWrapper as me,CoreEffects as M,DefaultBoxishStyles as ve}from"./core";import{InputAutocompleteClasses as W}from"../../@styles/componentClasses";import{InputLabel as ye}from"./Label";import{RightIcon as le}from".";function _e(e){let{value:t,states:s}=e,{required:d,options:o,min:a,max:n}=s;a=a||0,n=n||65535;let S=[],u=t.filter(c=>c!==null).length;return d&&(u||S.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),u<a&&S.push({type:"invalid",label:a+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),u>n&&S.push({type:"invalid",label:n+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!S.filter(({type:c})=>c=="invalid").length,notice:S}}const z={InitOptions:e=>{let t=[];return e.forEach(s=>{if(!s)return;let{type:d,label:o,value:a,searchValue:n}=s,S=n||p.is.string(o)&&o||""||p.is.string(a)&&a||p.Stringify(a||"")||"";p.is.nullish(o)&&(o=String(a)),t.push(g(m({id:D()},s),{searchValue:S,type:d||"selector",label:o,value:a}))}),t},FilterSelectableOptions:(e,t,s)=>{let d=e;return s||(d=e.filter(o=>(o==null?void 0:o.type)!="label")),p.scope(()=>{if(!t)return;let o=t.toLower().replace(/ /g,"");d=d.filter(a=>(a.searchValue||"").toLower().replace(/ /g,"").includes(o))}),d}},L={Shallow:e=>{let{rootStates:t,val_status:s}=e,d=ce(t);return l(E,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:l(q.Description,g(m({className:t.className},d),{position:"absolute",width:1,freeCSS:g(m({},d.freeCSS),{color:"orange"}),"data-id":"shallow_"+s.componentId,children:l(E,{"data-input-value-shallow":s.componentId,children:"A"})}))})},Button:e=>{let{rootStates:t,val_keyword:s,set_keyword:d,val_optionFocused:o,set_optionFocused:a,val_preventOpenSelector:n,set_preventOpenSelector:S,val_openSelector:u,set_openSelector:c,val_status:i,set_status:f,val_activeInput:v,set_activeInput:y,val_validate:C,set_validate:O}=e,Y=t,{tone:h,required:A,form:I,className:w,multiSelect:R,enableFormSubmit:K,checkValidationAtFirst:N,onValidate:$,onValidateDelay:Q,onUpdateValue:U,onUpdateValidValue:J,onUserAction:j,value:G="",options:T,leftIndicator:B,rightIndicator:k,leftIcon:ge,rightIcon:he,componentId:Ie,status_id:be,wrapStyles:Ce,emptySelect:De,SearchInput:Oe,SearchInputPlaceholder:we,SelectedComponent:Re,SelectorComponent:Te,SelectorStyles:ke,SelectorPosition:xe,DynamicOptionsOnSearch:Ve,DynamicOptionsOnSearchDelay:Ae}=Y,r=ee(Y,["tone","required","form","className","multiSelect","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","leftIndicator","rightIndicator","leftIcon","rightIcon","componentId","status_id","wrapStyles","emptySelect","SearchInput","SearchInputPlaceholder","SelectedComponent","SelectorComponent","SelectorStyles","SelectorPosition","DynamicOptionsOnSearch","DynamicOptionsOnSearchDelay"]);return F(()=>{var x;if(t.disabled||!u||p.is.exist(o))return;let _=z.FilterSelectableOptions(e.val_options,s,!1);a(((x=_[0])==null?void 0:x.id)||"")},[s]),F(()=>{if(i.eventType!="init"&&i.eventType!="override"){if(t.max==i.dataValue.length){c(!1),S(!0),d("");return}p("#SearchInput_"+t.componentId).focus()}},[i.dataValue]),F(()=>{if(i.eventType=="override")return;let _="autocomplete-click-"+t.componentId;if(!u){p(document).removeEvent([_]);return}p('[data-input-origin="'+t.componentId+'"]')&&(p("#SearchInput_"+t.componentId).focus(),p(document).addEvent({eventID:_,eventType:"mousedown",callback:ie=>{let Z=p(ie.target),re=!!p(Z).parent("."+W("Core")).length,se=!!p(Z).parent("."+W("Selector")).length;re||se||(c(!1),y(!1))},options:{passive:!1}}))},[u]),V(X,{children:[l(E,g(m({tabIndex:0},r),{"data-disabled":t.disabled,"data-show-validation":M.isShowValidation(C,i,!!N),"data-component-id":i.componentId,"data-input-origin":i.componentId,"data-focus":!!u||!!v,className:[w,W("Core")].join(" "),onFocus:_=>{if(r!=null&&r.onFocus&&(r==null||r.onFocus(_)),!t.disabled){if(n)return S(!1);c(!0),y(!0),_.preventDefault()}},onBlur:_=>{r!=null&&r.onBlur&&(r==null||r.onBlur(_))},onCompositionStart:_=>{r!=null&&r.onCompositionStart&&(r==null||r.onCompositionStart(_))},onCompositionEnd:_=>{r!=null&&r.onCompositionEnd&&(r==null||r.onCompositionEnd(_))},onClick:_=>{r!=null&&r.onClick&&(r==null||r.onClick(_)),!t.disabled&&(c(!0),y(!0))},onKeyDown:_=>{let{key:x}=_;K&&M.SubmitForm(_,I),!u&&(x==" "||x=="ArrowDown"||x=="ArrowUp"||x=="Enter")&&(c(!0),y(!0))},children:V(P.Left,{gap:0,children:[l(pe,{width:0,overflow:"hidden",opacity:"trans",children:"A"}),V(P.Left,{flexWrap:!0,flexSizing:0,gap:"1/3",freeCSS:{letterSpacing:".5px"},children:[l(L.Selected,m({},e)),l(L.SearchInput,m({},e))]})]})})),u&&l(L.Selector,m({},e))]})},SearchInput:e=>{let{rootStates:t,val_status:s,set_status:d}=e;return t.disabled||!e.val_openSelector&&!e.val_activeInput?null:l(E,{htmlTag:"input",id:"SearchInput_"+t.componentId,placeholder:t.SearchInputPlaceholder||"\u691C\u7D22...",opacity:e.val_openSelector?"max":"middle",transition:"middle",flexSizing:0,fontSize:"inherit",border:"unset",backgroundColor:"trans",value:e.val_keyword,freeCSS:{outline:"none"},onFocus:o=>{d(a=>g(m({},a),{eventID:D(),isFocusing:!0}))},onBlur:o=>{e.set_activeInput(!1),d(a=>g(m({},a),{eventID:D(),isFocusing:!1}))},onCompositionStart:o=>{d(a=>g(m({},a),{eventID:D(),isComposing:!0}))},onCompositionEnd:o=>{d(a=>g(m({},a),{eventID:D(),isComposing:!1}))},onKeyDown:o=>{let{key:a,metaKey:n,ctrlKey:S}=o,u=n||S;a=="Tab"?(e.set_openSelector(!1),e.set_activeInput(!1),e.set_preventOpenSelector(!1)):a==" "?p.scope(()=>{e.val_openSelector||e.val_keyword||(o.preventDefault(),e.set_openSelector(!0))}):a=="Backspace"?p.scope(()=>{if(e.val_keyword)return;let c=[...e.val_status.dataValue];c.pop(),e.set_status(i=>g(m({},i),{dataValue:c,eventType:"update",eventID:D()}))}):a=="Enter"&&p.scope(()=>{if(s.isComposing||(o==null?void 0:o.keyCode)===229)return;if(!e.val_openSelector)return e.set_openSelector(!0);if(!e.val_optionFocused)return;let c=e.val_options.find(f=>(f==null?void 0:f.id)==e.val_optionFocused);if(!c)return;let{value:i}=c;e.set_status(f=>{let v=[...f.dataValue];return p.scope(()=>{if(i===null)return v=[];f.dataValue.includes(i)?v=v.filter(C=>C!==i):t.multiSelect?v.push(i):v=[i]}),g(m({},f),{dataValue:v,eventType:"update",eventID:D()})}),e.set_optionsModified(!0),e.set_keyword("")}),p.scope(()=>{if(!["ArrowDown","ArrowUp"].includes(a))return;if(o.preventDefault(),!e.val_openSelector)return e.set_openSelector(!0);let c=a=="ArrowDown"?1:-1,i=z.FilterSelectableOptions(e.val_options),f=i.length-1,v=null;p.scope(()=>{var C,O,h,A,I,w;let y=i.findIndex(R=>(R==null?void 0:R.id)==e.val_optionFocused);if(y==-1&&(y=0),c==1){if(v=(C=i[0])==null?void 0:C.id,u){v=(O=i[f])==null?void 0:O.id;return}if(y==-1||y==f)return;v=(h=i[y+1])==null?void 0:h.id}else{if(v=(A=i[f])==null?void 0:A.id,u){v=(I=i[0])==null?void 0:I.id;return}if(y==-1||y==0)return;v=(w=i[y-1])==null?void 0:w.id}}),e.set_optionFocused(v)}),t.enableFormSubmit&&M.SubmitForm(o,e.rootStates.form)},onChange:o=>{let n=o.target.value;e.set_openSelector(!0),e.set_keyword(n)}},"searchInput")},Selector:e=>{var S;let[t,s]=b("idle"),[d,o]=b("idle");F(()=>{if(!e.rootStates.DynamicOptionsOnSearch||!e.val_openSelector)return;if(e.val_optionsModified)return e.set_optionsModified(!1);if(e.val_status.isComposing)return;if(t=="idle")return s("ok");o("fetch");let u="autocomplete-search-"+e.rootStates.componentId;e.set_optionFocused(""),p.interval.once(()=>te(void 0,null,function*(){var f;let c=yield e.rootStates.DynamicOptionsOnSearch(e.val_keyword);o("idle");let i=z.InitOptions(c||[]);e.set_options(i),e.set_optionFocused(((f=i[0])==null?void 0:f.id)||"")}),e.rootStates.DynamicOptionsOnSearchDelay||500,u)},[e.val_keyword,e.val_status.isComposing]),F(()=>{let u=p(`[data-selector-id="${e.val_status.componentId}"]`)[0];if(!u)return;let c=p(`[data-autocomplete-input-value="${e.val_optionFocused}"]`)[0];c&&(u.scrollTop=c.offsetTop-24)},[e.val_optionFocused]);let a=z.FilterSelectableOptions(e.val_options,e.rootStates.DynamicOptionsOnSearch?"":e.val_keyword,!0),n={};switch(e.rootStates.SelectorPosition){case 1:n.bottom="100%",n.left=0,n.paddingBottom="1/3";break;case 2:n.bottom="100%",n.right=0,n.paddingBottom="1/3";break;case 3:n.top="100%",n.left=0,n.paddingTop="1/3";break;case 4:n.top="100%",n.right=0,n.paddingTop="1/3";break;default:break}return l(E,g(m({position:"absolute"},n),{freeCSS:m({minWidth:"75%",zIndex:1e3},n.freeCSS),children:l(Se.Body,g(m({className:W("Selector"),borderRadius:"2.tone.secondary",ssCardBox:!0,boxShadow:"1.normal",overflow:"auto","data-selector-id":e.val_status.componentId},e.rootStates.SelectorStyles),{freeCSS:m({maxHeight:12*24},(S=e.rootStates.SelectorStyles)==null?void 0:S.freeCSS),children:V(oe,{gap:"1/12",padding:[1,0],children:[d=="fetch"&&l(P.Center,{padding:"1/2",children:l(de.Theme.R,{showInitial:!0})}),d!="fetch"&&V(X,{children:[!a.length&&l(q.Supplement,{padding:[0,1],fontColor:"4.thin",children:"\u5019\u88DC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}),a.map((u,c)=>{if(!u)return null;let{type:i,value:f}=u,v=e.val_optionFocused==u.id,y=e.val_status.dataValue.includes(f),C=e.rootStates.SelectorComponent;return l(oe,{"data-autocomplete-input-value":u.id,children:l(C,{option:u,isFocused:v,isSelected:y,addCallback:()=>{e.set_status(O=>{let h=[...O.dataValue];return p.scope(()=>{if(f===null)return h=[];O.dataValue.includes(f)?h=h.filter(I=>I!==f):e.rootStates.multiSelect?h.push(f):h=[f]}),g(m({},O),{dataValue:h,eventType:"update",eventID:D()})})}})},u.id)})]})]})}))}))},Selected:e=>{let{rootStates:t,val_status:s,set_status:d,val_optionsDict:o}=e,a=[];return s.dataValue.forEach(n=>{let S=o[p.Stringify(n)];if(!S)return;let u=t.SelectedComponent,c=S.label;(S==null?void 0:S.value)===null&&(c=""),a.push(l(E,{className:W("SelectedCell"),children:l(u,{value:S==null?void 0:S.value,label:c,removeCallback:i=>{if(i.stopPropagation(),i.preventDefault(),t.disabled)return;let f=[...s.dataValue];f=f.filter(v=>v!==n),d(v=>g(m({},v),{dataValue:f,eventType:"update",eventID:D()}))}})},p.Stringify(S==null?void 0:S.value)||D()))}),l(X,{children:a})},Core:e=>{var J,j,G;let{value:t}=e,[s,d]=b(!1),[o,a]=b(!1),[n,S]=b(!1),[u,c]=b(!1),[i,f]=b(""),[v,y]=b(e.options),[C,O]=b(((J=e.options.find(T=>{var B;return(T==null?void 0:T.value)===((B=e.value)==null?void 0:B[0])}))==null?void 0:J.id)||((j=e.options[0])==null?void 0:j.id)||""),[h,A]=b({}),[I,w]=b(M.DefaultStatus(e.componentId,t)),[R,K]=b({ok:!1,notice:[]}),N=ue(!1);F(()=>{o||(N.current?y(e.options):N.current=!0)},[p.Stringify((G=e.options)==null?void 0:G.map(T=>T.value))]),F(()=>{if(!v.length)return;let T=[...v],B=m({},h);T.forEach(k=>{(k==null?void 0:k.type)!="label"&&(B[p.Stringify(k==null?void 0:k.value)]=k)}),A(B)},[v]);let $={rootStates:e,val_options:v,set_options:y,val_optionFocused:C,set_optionFocused:O,val_optionsDict:h,set_optionsDict:A,val_optionsModified:o,set_optionsModified:a,val_preventOpenSelector:s,set_preventOpenSelector:d,val_openSelector:n,set_openSelector:S,val_activeInput:u,set_activeInput:c,val_keyword:i,set_keyword:f,val_status:I,set_status:w,val_validate:R,set_validate:K},Q=!!e.multiSelect;M.CommonEffects({type:Q?"autocomplete.multi":"autocomplete.single",states:e,val_status:I,set_status:w,val_validate:R,set_validate:K,SystemValidation:_e});let U=I.dataValue.length&&I.dataValue[0]!==null;return U=U||n||u,V(me,{val_status:I,set_status:w,val_validate:R,states:e,children:[l(ye,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:U}),l(L.Shallow,m({},$)),l(L.Button,m({},$))]})}},ne=e=>{let t=m({},e);return t=g(m({value:[],min:0,max:65535,multiSelect:!0,SearchInput:!0,emptySelect:!0,SelectorComponent:({option:s,isSelected:d,isFocused:o,addCallback:a})=>s?(s==null?void 0:s.type)=="label"?l(X,{children:s.label}):l(ae.Sub.S,{color:"cloud",backgroundColor:"trans",borderRadius:0,fontColor:"2.normal",textAlign:"left",padding:["1/2",1.5],isActive:o,isActiveStyles:{backgroundColor:"cloud"},onClick:a,children:V(P.Left,{gap:"1/2",children:[d&&l(H.Check,{fontColor:"theme"}),l(q.Supplement,{transition:"short",children:s.label})]})}):null,SelectedComponent:({value:s,label:d,removeCallback:o})=>V(P.Left,{ssCardBox:"cloud",borderRadius:"2.tone.secondary",fontSize:"1.mini",padding:"1/2",gap:0,children:[l(E,{padding:[0,"1/4"],children:d}),l(ae.Clear,{flexSizing:"none",color:"nega",fontColor:"4.thin",tabIndex:-1,isRounded:!0,padding:"1/4",onClick:o,freeCSS:{lineHeight:1,aspectRatio:"1/1"},children:l(H.X,{})})]}),SelectorPosition:3},t),{freeCSS:m({cursor:"pointer"},t.freeCSS)}),t.multiSelect||(t.min=0,t.max=1),t.options=t.options||[],t.emptySelect&&(t.options=[{value:null,label:l(q.Supplement,{fontColor:"4.thin",children:"\u9078\u629E\u3092\u89E3\u9664"})},...t.options]),t.value=p.flatArray(t.value),t.options=z.InitOptions(t.options),p.is.nullish(t.rightIcon)&&(t.rightIcon=l(le,{children:l(H.Search,{})}),t.disabled&&(t.rightIcon=l(le,{fontColor:"5.translucent",children:l(H.Ban,{})}))),t.rightIcon&&(t=m({paddingRight:3},t)),t.leftIcon&&(t=m({paddingLeft:3},t)),l(fe,{componentId:t.componentId,children:L.Core,states:ve(t)})};export{ne as Autocomplete,ne as default};
|
package/dist/fn/Input/List.d.ts
CHANGED
|
@@ -59,14 +59,14 @@ declare namespace Radio {
|
|
|
59
59
|
type Input<T = List.Value> = List.Input<T>;
|
|
60
60
|
namespace Methods {
|
|
61
61
|
type Component = {
|
|
62
|
-
<T = List.Value>(p: List.Input<List.Value<T>>): JSX.Element;
|
|
62
|
+
<T = List.Value>(p: List.Input<List.Value<T>>): React.JSX.Element;
|
|
63
63
|
};
|
|
64
64
|
type FNs = {
|
|
65
|
-
Normal: <T = List.Value>(p: List.Input<List.Value<T>>) => JSX.Element;
|
|
66
|
-
Border: <T = List.Value>(p: List.Input<List.Value<T>>) => JSX.Element;
|
|
67
|
-
Cloud: <T = List.Value>(p: List.Input<List.Value<T>>) => JSX.Element;
|
|
68
|
-
Simple: <T = List.Value>(p: List.Input<List.Value<T>>) => JSX.Element;
|
|
69
|
-
Vivid: <T = List.Value>(p: List.Input<List.Value<T>>) => JSX.Element;
|
|
65
|
+
Normal: <T = List.Value>(p: List.Input<List.Value<T>>) => React.JSX.Element;
|
|
66
|
+
Border: <T = List.Value>(p: List.Input<List.Value<T>>) => React.JSX.Element;
|
|
67
|
+
Cloud: <T = List.Value>(p: List.Input<List.Value<T>>) => React.JSX.Element;
|
|
68
|
+
Simple: <T = List.Value>(p: List.Input<List.Value<T>>) => React.JSX.Element;
|
|
69
|
+
Vivid: <T = List.Value>(p: List.Input<List.Value<T>>) => React.JSX.Element;
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
type Methods = Methods.Component & Methods.FNs;
|
|
@@ -75,14 +75,14 @@ declare namespace Checkbox {
|
|
|
75
75
|
type Input<T = List.Value, O = T[]> = List.Input<T, O>;
|
|
76
76
|
namespace Methods {
|
|
77
77
|
type Component = {
|
|
78
|
-
<T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>): JSX.Element;
|
|
78
|
+
<T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>): React.JSX.Element;
|
|
79
79
|
};
|
|
80
80
|
type FNs = {
|
|
81
|
-
Normal: <T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>) => JSX.Element;
|
|
82
|
-
Border: <T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>) => JSX.Element;
|
|
83
|
-
Cloud: <T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>) => JSX.Element;
|
|
84
|
-
Simple: <T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>) => JSX.Element;
|
|
85
|
-
Vivid: <T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>) => JSX.Element;
|
|
81
|
+
Normal: <T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>) => React.JSX.Element;
|
|
82
|
+
Border: <T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>) => React.JSX.Element;
|
|
83
|
+
Cloud: <T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>) => React.JSX.Element;
|
|
84
|
+
Simple: <T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>) => React.JSX.Element;
|
|
85
|
+
Vivid: <T = List.Value, O = T[]>(p: List.Input<List.Value<T>, List.Value<O>>) => React.JSX.Element;
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
type Methods = Methods.Component & Methods.FNs;
|
package/dist/fn/Input/List.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,c as m,d as B}from"../../chunk-C5N2D3ZX.js";import{jsx as
|
|
1
|
+
import{b as o,c as m,d as B}from"../../chunk-C5N2D3ZX.js";import{jsx as i}from"react/jsx-runtime";import C,{UUID as w}from"jmini";import{useState as ae}from"react";import{$$fromRoot as ne,GenerateHTMLProps as se}from"../../@utils";import{Box as T,Flex as re,FAI as ce,Span as ue}from"../../atoms";import{Button as de}from"../Button";import{OptionalInputWrapper as me,BoxWrapper as pe,CoreEffects as M}from"./core";import{InputListClasses as b}from"../../@styles/componentClasses";function Ce(t){let{value:l,states:a}=t,{type:e,required:s,min:n,max:p}=a;n=n||0,p=p||65535;let c=[],y=l.length;return s&&(y||e=="radio"&&c.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),y<n&&c.push({type:"invalid",label:n+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),y>p&&c.push({type:"invalid",label:p+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!c.filter(({type:V})=>V=="invalid").length,notice:c}}const h={InitOptions:t=>{let l=[];return t.forEach(a=>{if(!a)return;let{label:e,value:s}=a;C.is.nullish(e)&&(e=String(s)),l.push(m(o({},a),{label:e,value:s}))}),l},OptionalListWrapper:t=>{let{value:l,options:a=[]}=t,e=C.is.exist(l)?C.flatArray(l):[],s=[];return e.forEach(n=>{a.findIndex(c=>C.is.equal(c.value,n))!=-1&&s.push(n)}),i(h.Core,m(o({},t),{value:s,options:a}))},Core:t=>{let S=t,{type:l,tone:a,required:e,componentId:s="",form:n,override:p,icon:c,iconType:y,iconSize:V,iconPosition:P,iconColor:v,CustomIcon:X,enableFormSubmit:A,checkValidationAtFirst:$,onValidate:U,onValidateDelay:R,onUpdateValue:W,onUpdateValidValue:H,onUserAction:q,value:f,options:K,className:j,cellStyles:G,cellClassName:Q,cellCheckedStyles:Y,cellCheckedClassName:Z,min:D,max:u,hideInput:N,freeCSS:x,wrapStyles:ee}=S,L=B(S,["type","tone","required","componentId","form","override","icon","iconType","iconSize","iconPosition","iconColor","CustomIcon","enableFormSubmit","checkValidationAtFirst","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","className","cellStyles","cellClassName","cellCheckedStyles","cellCheckedClassName","min","max","hideInput","freeCSS","wrapStyles"]),[k,O]=ae(M.DefaultStatus(s,f)),[_,E]=ae({ok:!1,notice:[]});return M.CommonEffects({type:"list."+l,states:t,val_status:k,set_status:O,val_validate:_,set_validate:E,SystemValidation:Ce}),i(pe,{val_status:k,set_status:O,val_validate:_,states:t,children:i(h.List,{rootStates:t,val_status:k,set_status:O})})},List:t=>{let{rootStates:l,val_status:a,set_status:e}=t,{componentId:s,type:n,tone:p,icon:c,iconSize:y,iconColor:V,isChecker:P,options:v,name:X,form:A,tabIndex:$,hideInput:U,disabled:R,className:W,cellStyles:H,cellClassName:q="",cellCheckedStyles:f,cellCheckedClassName:K="",enableFormSubmit:j}=l,{dataValue:G}=a,Q=l.CustomIcon,Y=v.map((Z,D)=>{let le=Z,{value:u,label:N,disabled:x,className:ee="",checkedStyles:L,checkedClassName:k="",freeCSS:O}=le,_=B(le,["value","label","disabled","className","checkedStyles","checkedClassName","freeCSS"]),E=w(),S=G.findIndex(r=>r===u||C.is.equal(r,u))!=-1,I=o(o({},H),_),z=[b("Label"),q,ee];S&&(I=m(o(o(o({},I),f),L),{freeCSS:o(o(o({},I==null?void 0:I.freeCSS),f==null?void 0:f.freeCSS),L==null?void 0:L.freeCSS)}),z=[...z,K,k]);const te=()=>{if(R||x)return;let r=[];if(n=="radio")r=[u];else if(n=="checkbox"||P)if(!S)r=[...a.dataValue,u];else{let d=[...a.dataValue];d.splice(a.dataValue.findIndex(F=>F==u),1),r=d}e(d=>m(o({},d),{dataValue:r,eventType:"update",eventID:w()}))};let oe=[i(ue,{position:"relative",freeCSS:{zIndex:2},flexSizing:0,children:C.is.string(N)?i(T,{children:N}):N},"content")];return c&&oe[l.iconPosition=="right"?"push":"unshift"](i(Q,{isChecked:S,iconSize:y,iconColor:V,toggle:te},"icon")),[i(T,{htmlTag:"input",type:n=="radio"?"radio":"checkbox",className:b("Input"),name:"RadioCheckbox-"+X,"data-list-index":s+"-"+D,id:E,value:String(u),disabled:R||x,checked:S,onFocus:r=>{x||n=="radio"&&(a.dataValue.length||e(d=>m(o({},d),{dataValue:[u],eventType:"update",eventID:w()})))},onChange:()=>{te()},onKeyDown:r=>{let{key:d,shiftKey:F}=r;if((n=="checkbox"||t.rootStates.isChecker)&&d!="Tab"){if(d.match(/Arrow/)){r.preventDefault();let ie=["ArrowLeft","ArrowUp"].includes(d)?-1:1,g=D+ie;g<0?g=v.length-1:g>=v.length&&(g=0),ne(`input[data-list-index="${s}-${g}"]`).focus()}}j&&M.SubmitForm(r,A)},tabIndex:$},"List-"+C.Stringify(u)),i(T,m(o({htmlTag:"label","data-disabled":R||x,htmlFor:E,className:z.join(" "),tabIndex:-1,display:"flex",verticalAlign:"center",flexWrap:!1},I),{children:oe}),"ListTrigger-"+C.Stringify(u))]});return i(re,{flexSizing:"auto",style:l.style,freeCSS:o({},l.freeCSS),className:[W,b("CellBase"),b("HideInput_"+U),b("IconIndicator_"+!!c),b("Tone_"+p)].join(" "),children:Y})},_Icon:t=>{let l=1.5;return t.iconSize=="small"?l=1.2:t.iconSize=="large"&&(l=2),i(de.Normal,{ssPushable:!0,color:"cloud",tabIndex:-1,ssEffectsOnActive:"ripple.cloud",ssSphere:2,freeCSS:{transform:`scale(${l})`},onClick:a=>{a.preventDefault(),a.stopPropagation(),t.toggle()},children:t.children})},RadioIcon:t=>i(h._Icon,m(o({type:"radio"},t),{children:i(T,{flexCenter:!0,isRounded:!0,border:t.isChecked?"0.trans":"3.thick",borderColor:t.isChecked?t.iconColor:"3.thick",position:"relative",transition:"middle",freeCSS:{width:"50%",height:"50%"},children:i(T,{position:"absolute",transition:"middle",isRounded:!0,backgroundColor:t.iconColor,opacity:t.isChecked?"max":"trans",freeCSS:{width:"60%",height:"60%",transform:t.isChecked?"scale(1)":"scale(.4)"}})})})),CheckboxIcon:t=>i(h._Icon,m(o({type:"checkbox"},t),{children:i(T,{flexCenter:!0,boxShadow:t.isChecked?"0.remark":"none",border:t.isChecked?"0.trans":"3.thick",backgroundColor:t.isChecked?t.iconColor:"trans",position:"relative",transition:"middle",fontColor:"white",freeCSS:{borderRadius:"25%",padding:"4%",width:"50%",height:"50%"},children:i(ce.Check,{transition:"middle",opacity:t.isChecked?"max":"trans",freeCSS:{zIndex:8,width:"100%",height:"100%",transform:t.isChecked?"scale(1)":"scale(.5)"}})})}))},J=t=>{t=t||"checkbox";const l=e=>(e=m(o({gap:1,icon:!0,iconSize:"regular",iconType:t=="radio"?"radio":"checkbox",iconPosition:"left",iconColor:"theme"},e),{type:t,cellStyles:o({gap:"1/6",position:"relative",borderRadius:"2.tone.secondary",transition:"middle"},e.cellStyles)}),e.CustomIcon||(e.iconType=="radio"?e.CustomIcon=h.RadioIcon:e.iconType=="checkbox"&&(e.CustomIcon=h.CheckboxIcon)),e.iconSize=="small"?e.cellStyles.gap=0:e.iconSize=="large"&&(e.cellStyles.gap="1/2"),e.tone=="normal"?(e.cellStyles=o({padding:["1/4",1],border:"1.thin",backgroundColor:"layer.1"},e.cellStyles),e.cellCheckedStyles=o({borderColor:"theme",fontColor:"theme",boxShadow:"1.normal"},e.cellCheckedStyles)):e.tone=="border"?(e.cellStyles=o({border:"1.thin",backgroundColor:"layer.1",padding:["1/2",1,"1/2","1/2"]},e.cellStyles),e.cellCheckedStyles=o({borderColor:"theme",fontColor:"theme"},e.cellCheckedStyles)):e.tone=="cloud"&&(e.cellStyles=o({border:"1.thin",backgroundColor:"layer.2",padding:["1/2",1,"1/2","1/2"]},e.cellStyles),e.cellCheckedStyles=o({backgroundColor:"cloud",fontColor:"theme"},e.cellCheckedStyles)),e=se(e),e.options=h.InitOptions(e.options),i(me,{componentId:e.componentId,children:h.OptionalListWrapper,states:e})),a=l;return a.Normal=e=>i(l,o({type:t,tone:"normal",icon:!1},e)),a.Border=e=>i(l,o({type:t,tone:"border"},e)),a.Cloud=e=>i(l,o({type:t,tone:"cloud"},e)),a.Vivid=e=>i(l,o({type:t,tone:"normal",icon:!1,cellCheckedStyles:{backgroundColor:"theme",fontColor:"white"}},e)),a.Simple=e=>i(l,o({type:t,tone:"plain",icon:!1,cellCheckedStyles:{fontColor:"theme"}},e)),a},he=J("radio"),Se=J("checkbox"),ye=J();export{Se as Checkbox,ye as List,he as Radio};
|
|
@@ -3,7 +3,7 @@ import { Autocomplete } from './Autocomplete';
|
|
|
3
3
|
declare namespace Search {
|
|
4
4
|
type Input<T = Autocomplete.Value> = Autocomplete.Input<T>;
|
|
5
5
|
type Component = {
|
|
6
|
-
<T = Autocomplete.Value>(p: Input<Autocomplete.Value<T>>): JSX.Element;
|
|
6
|
+
<T = Autocomplete.Value>(p: Input<Autocomplete.Value<T>>): React.JSX.Element;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
declare const Search: Search.Component;
|
package/dist/fn/Input/Search.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as t}from"../../chunk-C5N2D3ZX.js";import{Fragment as
|
|
1
|
+
import{b as t}from"../../chunk-C5N2D3ZX.js";import{Fragment as r,jsx as e}from"react/jsx-runtime";import{FAI as l}from"../../atoms";import{Autocomplete as m}from"./Autocomplete";import{RightIcon as c}from".";const o=p=>e(m,t({multiSelect:!1,SelectedComponent:({value:u,label:n})=>e(r,{children:n}),rightIcon:e(c,{children:e(l.AngleDown,{})})},p));export{o as Search,o as default};
|
|
@@ -10,15 +10,15 @@ declare namespace Segmented {
|
|
|
10
10
|
type Input<T = any> = List.Input<T>;
|
|
11
11
|
namespace Methods {
|
|
12
12
|
type Component = {
|
|
13
|
-
<T = any>(p: Input<T>): JSX.Element;
|
|
13
|
+
<T = any>(p: Input<T>): React.JSX.Element;
|
|
14
14
|
};
|
|
15
15
|
type FNs = {
|
|
16
|
-
Cloud: <T = any>(p: Input<Value<T>>) => JSX.Element;
|
|
17
|
-
CloudTheme: <T = any>(p: Input<Value<T>>) => JSX.Element;
|
|
18
|
-
CloudMono: <T = any>(p: Input<Value<T>>) => JSX.Element;
|
|
19
|
-
Border: <T = any>(p: Input<Value<T>>) => JSX.Element;
|
|
20
|
-
BorderVivid: <T = any>(p: Input<Value<T>>) => JSX.Element;
|
|
21
|
-
Bottomline: <T = any>(p: Input<Value<T>>) => JSX.Element;
|
|
16
|
+
Cloud: <T = any>(p: Input<Value<T>>) => React.JSX.Element;
|
|
17
|
+
CloudTheme: <T = any>(p: Input<Value<T>>) => React.JSX.Element;
|
|
18
|
+
CloudMono: <T = any>(p: Input<Value<T>>) => React.JSX.Element;
|
|
19
|
+
Border: <T = any>(p: Input<Value<T>>) => React.JSX.Element;
|
|
20
|
+
BorderVivid: <T = any>(p: Input<Value<T>>) => React.JSX.Element;
|
|
21
|
+
Bottomline: <T = any>(p: Input<Value<T>>) => React.JSX.Element;
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
type Methods = Methods.Component & Methods.FNs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,c as n,d as C}from"../../chunk-C5N2D3ZX.js";import{jsx as r}from"react/jsx-runtime";import{UUID as
|
|
1
|
+
import{b as e,c as n,d as C}from"../../chunk-C5N2D3ZX.js";import{jsx as r}from"react/jsx-runtime";import{UUID as R}from"jmini";import{useState as a}from"react";import{Radio as w}from"./List";import{InputSegmentedClasses as c}from"../../@styles/componentClasses";const E=t=>{let m=t,{__sys_segmented_type:o,tone:B,value:d,options:S,onUpdateValue:h,onUpdateValidValue:u,onUserAction:g,enableFormSubmit:M,checkValidationAtFirst:U,cellStyles:_,cellClassName:b,cellCheckedClassName:f,cellCheckedStyles:k,freeCSS:I,wrapStyles:J}=m,T=C(m,["__sys_segmented_type","tone","value","options","onUpdateValue","onUpdateValidValue","onUserAction","enableFormSubmit","checkValidationAtFirst","cellStyles","cellClassName","cellCheckedClassName","cellCheckedStyles","freeCSS","wrapStyles"]),[V]=a(R()),[p,v]=a(d),[x,i]=a(p);return p!=d&&(v(d),i(d)),r(w,n(e({options:S,value:x,componentId:V,icon:!1,flexWrap:!1,borderRadius:"2.tone.secondary",position:"relative"},T),{freeCSS:e({whiteSpace:"nowrap"},I),cellStyles:e({flexCenter:!0,ssEffectsOnActive:"push"},_),cellCheckedStyles:e({},k),cellClassName:[b,c("Label"),c("Tone_"+o.replace(/\./ig,""))].join(" "),cellCheckedClassName:[f,c("Checked")].join(" "),tone:"custom",onUpdateValue:h,onUpdateValidValue:(...y)=>{u&&u(...y),o=="bottomline"&&i(y[0])},onUserAction:g}))},s=t=>{let{__sys_segmented_type:o}=t;return o=o||"plain",o=="plain"&&(t=n(e({padding:"1/3",gap:"1/3",ssCardBox:!0},t),{cellStyles:e({padding:["1/2","3/4"],borderRadius:"inherit",position:"relative"},t.cellStyles),cellCheckedStyles:e({backgroundColor:"theme",boxShadow:"1.normal",fontColor:"white"},t.cellCheckedStyles)})),r(E,e({__sys_segmented_type:"plain"},t))},l=s;l.Cloud=t=>{let o=n(e({__sys_segmented_type:"cloud",padding:"1/3",gap:"1/3",backgroundColor:"cloud"},t),{cellStyles:e({padding:"3/4",borderRadius:"inherit",position:"relative"},t.cellStyles),cellCheckedStyles:e({boxShadow:"1.normal",backgroundColor:"theme",fontColor:"white"},t.cellCheckedStyles)});return r(s,e({},o))},l.CloudTheme=t=>{let o=e({backgroundColor:"theme.opa.few",fontColor:"theme",__sys_segmented_type:"cloud.theme"},t);return r(l.Cloud,e({},o))},l.CloudMono=t=>{let o=n(e({fontColor:"3.blur",__sys_segmented_type:"cloud.mono"},t),{cellCheckedStyles:e({backgroundColor:"layer.1",fontColor:"1.clear"},t.cellCheckedStyles)});return r(l.Cloud,e({},o))},l.Border=t=>{let o=n(e({backgroundColor:"layer.1",border:"2.normal",overflow:"hidden",gap:0,fontColor:"3.blur",ssLastChildLossBorder:"right",boxShadow:"0.min",__sys_segmented_type:"border"},t),{cellStyles:e({padding:["3/4",1],borderRadius:0,borderRight:"2.normal"},t.cellStyles),cellCheckedStyles:e({backgroundColor:"theme.opa.few",fontColor:"theme"},t.cellCheckedStyles)});return r(s,e({},o))},l.BorderVivid=t=>{let o=n(e({border:!0,borderColor:"theme",__sys_segmented_type:"border.vivid"},t),{cellStyles:e({borderRight:!0,borderColor:"theme"},t.cellStyles),cellCheckedStyles:e({backgroundColor:"theme",fontColor:"white"},t.cellCheckedStyles)});return r(l.Border,e({},o))},l.Bottomline=t=>{let o=n(e({__sys_segmented_type:"bottomline",gap:0,fontColor:"3.blur"},t),{cellStyles:e({ssEffectsOnActive:"ripple.theme",borderRadius:0,padding:1},t.cellStyles),cellCheckedStyles:e({fontColor:"theme"},t.cellCheckedStyles)});return r(s,e({},o))};export{l as Segmented,l as default};
|
|
@@ -54,7 +54,7 @@ declare namespace Select {
|
|
|
54
54
|
set_optionFocused: React.Dispatch<React.SetStateAction<string | null>>;
|
|
55
55
|
};
|
|
56
56
|
type Component = {
|
|
57
|
-
<T = Value>(p: Input<Value<T>>): JSX.Element;
|
|
57
|
+
<T = Value>(p: Input<Value<T>>): React.JSX.Element;
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
declare const Select: Select.Component;
|
|
@@ -28,15 +28,15 @@ export declare namespace TimeTypes {
|
|
|
28
28
|
}
|
|
29
29
|
declare namespace Time {
|
|
30
30
|
type Methods = {
|
|
31
|
-
Clock: (props: Input) => JSX.Element;
|
|
32
|
-
Date: (props: Input) => JSX.Element;
|
|
33
|
-
Week: (props: Input) => JSX.Element;
|
|
34
|
-
Month: (props: Input) => JSX.Element;
|
|
35
|
-
Year: (props: Input) => JSX.Element;
|
|
36
|
-
DateWareki: (props: DateWareki) => JSX.Element;
|
|
31
|
+
Clock: (props: Input) => React.JSX.Element;
|
|
32
|
+
Date: (props: Input) => React.JSX.Element;
|
|
33
|
+
Week: (props: Input) => React.JSX.Element;
|
|
34
|
+
Month: (props: Input) => React.JSX.Element;
|
|
35
|
+
Year: (props: Input) => React.JSX.Element;
|
|
36
|
+
DateWareki: (props: DateWareki) => React.JSX.Element;
|
|
37
37
|
Periods: {
|
|
38
|
-
Date: (props: Period) => JSX.Element;
|
|
39
|
-
Month: (props: Period) => JSX.Element;
|
|
38
|
+
Date: (props: Period) => React.JSX.Element;
|
|
39
|
+
Month: (props: Period) => React.JSX.Element;
|
|
40
40
|
};
|
|
41
41
|
fn: FNs;
|
|
42
42
|
};
|
|
@@ -87,6 +87,6 @@ declare namespace Time {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
declare const Time: Time.Methods & {
|
|
90
|
-
Origin: (props: Time.Origin) => JSX.Element;
|
|
90
|
+
Origin: (props: Time.Origin) => React.JSX.Element;
|
|
91
91
|
};
|
|
92
92
|
export { Time, Time as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ie,b as s,c as k,d as K}from"../../../chunk-C5N2D3ZX.js";import{Fragment as Ae,jsx as h,jsxs as se}from"react/jsx-runtime";import ee,{UUID as F,useStore as B}from"jmini";import*as X from"jmini";import{useState as O,useEffect as z,useRef as ue}from"react";import{$$fromRoot as de,Config as ne,ExtractStyles as fe}from"../../../@utils";import{Box as H,FAI as he}from"../../../atoms";import{Literal as ge,Row as ye}from"../../../mols";import{Button as oe}from"../../Button";import ve from"../../Tooltips";import Ie from"../../Sheet";import{faClock as Se}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as Te}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{OptionalInputWrapper as De,BoxWrapper as be,CoreEffects as Y,DefaultBoxishStyles as xe}from"../core";import{RightIcon as ke}from"..";import Ee from"../Select";import{InputLabel as we}from"../Label";import Ve from"./Picker";const P=" ~ ",Re={clock:{defaultValue:"--:--",format:/^\d{2}\D\d{2}$/,ranges:[{type:"hour",from:0,length:2},{type:"minute",from:3,length:2}],sets:1},date:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2}],sets:1},week:{defaultValue:"----\u5E74\u7B2C--\u9031",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4,region:6},{type:"week",from:6,length:2,region:3}],sets:1},month:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:3}],sets:1},year:{defaultValue:"----\u5E74",format:/^\d{4}$/,ranges:[{type:"year",from:0,length:4,region:5}],sets:1},dates:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2,region:5},{type:"year",from:10+P.length,length:4},{type:"month",from:15+P.length,length:2},{type:"date",from:18+P.length,length:2}],sets:2},months:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:6},{type:"year",from:8+P.length,length:4},{type:"month",from:13+P.length,length:2,region:3}],sets:2},dateWareki:{defaultValue:"----\u5E74--\u6708--\u65E5",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"dateWareki",from:0,length:4,region:5},{type:"month",from:5,length:2,region:3},{type:"date",from:8,length:2,region:3}],sets:1}},M={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:a,value:g,era:i}=e,f=ee.flatArray(g||""),{defaultValue:E,format:v,ranges:o,sets:r}=Re[a],S=[],n=a=="clock"&&":"||"/";for(let t=0;t<f.length;t++)f[t]=String(f[t]).replace(/\D/ig,n);for(let t=0;t<r;t++){let p=f[t]||"";if(!p.match(v))f[t]="",S.push(E);else{let T=E;p.split(/\D/).forEach((x,w)=>{if(w==0&&a=="dateWareki"){let I=Number(x);i!="year"&&(I>=2019?i=="reiwa"?I-=2018:i=="heisei"&&(I=31):I>=1989?i=="heisei"?I-=1988:i=="shouwa"&&(I=64):I>=1926?i=="shouwa"?I-=1925:i=="taisho"&&(I=15):I>=1912?i=="taisho"?I-=1911:i=="meiji"&&(I=45):I>=1868&&(I-=1867)),x=I.zeroEmbed(4)}T=T.replace(new RegExp("------------------".slice(0,x.length)),x)}),S.push(T)}}return{formatValue:S.join(P),dataValue:["dates","months"].includes(a)?f:f[0],ranges:o}},SystemValidation:e=>{let{states:a}=e,{restrict:g,min:i,max:f,required:E}=a,v=[],o=ee.flatArray(e.value),r={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let S=g=="clock"&&":"||"/";for(let n=0;n<o.length;n++)o[n]=String(o[n]).replace(/\D/ig,S);for(let n=0;n<o.length;n++){let t=o[n],p=o[n-1];t.removeLetters()||(r.empty=!0),n>0&&(r.escalated&=+(t>=p))}r.escalated&&(r.empty||(g.match(/clock/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);!t||!p?r.filled=!1:(Number(t)>23||Number(p)>59)&&(r.correct=!1)}):g.match(/date/)?o.forEach(n=>{let[t,p,T]=n.split(/\D+/);if(!t||!p||!T)r.filled=!1;else{let x=X.Time(n);(!x.validate||n!=x.toFormatYMD())&&(r.correct=!1)}}):g.match(/week/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);if(!t||!p)r.filled=!1;else{let T=X.Time(t+"/01/01").weekday,w=X.Time(t+"/01/0"+(7-T+1)).addWeek(Number(p)-1);t!=String(w.year)&&(r.correct=!1)}}):g.match(/month/)?o.forEach(n=>{let[t,p]=n.split(/\D+/);!t||!p?r.filled=!1:X.Time([t,p,"01"].join("/")).validate||(r.correct=!1)}):g.match(/year/),r.filled&&r.correct&&o.forEach(n=>{{let t=Number(String(n).replace(/\D/ig,""));if(i&&Number(String(i).replace(/\D/ig,""))>t&&(r.prohibited=!0),f){let p=Number(String(f).replace(/\D/ig,""));t>p&&(r.prohibited=!0)}}})))})();{let{empty:S,escalated:n,filled:t,correct:p,prohibited:T}=r;S&&E&&(v=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),n||v.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),p||v.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),t||v.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),T&&v.push({type:"invalid",label:se(Ae,{children:[h(H,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",i||"\u4E0B\u9650\u7121\u3057","] ~ [",f||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!v.filter(({type:S})=>S=="invalid").length,notice:v}},KeyDownEvent:e=>{let{val_era:a,restrict:g,event:i,val_status:f,set_status:E,val_focus:v,set_focus:o}=e,{key:r,shiftKey:S,ctrlKey:n,metaKey:t}=i,p=n||t,{selectionStart:T,selectionEnd:x}=i.target,{index:w,prevIndex:I}=v,{ranges:q,formatValue:G}=f,V=q.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(r)){let y=0;if(r=="Tab"){let m=+!S*2-1;if(y=v.index+m,y<0||y>V)return}else{let m=r=="ArrowLeft"?-1:r=="ArrowRight"?1:0;p||T==0&&x==String(f.formatValue).length?y=m==1?V:0:y=Math.max(0,Math.min(w+m,V))}o(m=>k(s({},m),{index:y,prevIndex:w})),i.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(r)){i.preventDefault();let y=w;y=Math.max(y,0),y=Math.min(y,V);let{type:m,from:U,length:Q}=q[y],L=G.slice(U,U+Q),D;if(r=="Backspace")D="------".slice(0,Q);else if(["ArrowUp","ArrowDown"].includes(r)){let R=r=="ArrowUp"?1:-1;L=L|0,D=L+R;let[u,d,l]=m=="dateWareki"?a=="year"?[0,2999,4]:a=="reiwa"?[1,2999,4]:a=="heisei"?[1,31,4]:a=="shouwa"?[1,64,4]:a=="taisho"?[1,15,4]:a=="meiji"?[1,45,4]:[0,0,0]:m=="minute"?[0,59,2]:m=="hour"?[0,23,2]:m=="date"?[1,31,2]:m=="week"?[1,53,2]:m=="month"?[1,12,2]:m=="year"?[0,2999,4]:[0,0,0];D>d?D=u:D<u&&(D=d),D=Number(D).zeroEmbed(l)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(r)){let R=L|0,u=r,d=`${R}${u}`;if(I!=w&&(R=0,d="0"+u),m=="year"||m=="dateWareki"&&a=="year")Number(d)>1e4?D=u:D=d,(D|0)>1e3&&y++;else if(["hour","minute","date","week","month"].includes(m)||m=="dateWareki"&&a!="year"){let l=m=="dateWareki"?a=="reiwa"?100:a=="heisei"?31:a=="shouwa"?64:a=="taisho"?15:a=="meiji"?45:0:m=="minute"?59:m=="hour"?23:m=="date"?31:m=="week"?53:m=="month"?12:0;D=(d|0)>l?u:d,(Number(u)>Number(String(l)[0])||L=="0000".slice(0,String(l).length)&&(d!="0000".slice(0,String(l).length)||["minute","hour"].includes(m)&&I==w)||(d|0)>=ie(10,String(l).length-1))&&y++}m=="year"||m=="dateWareki"?D=(D|0).zeroEmbed(4):D=(D|0).zeroEmbed(2)}{let R=String(G).partReplace(U,String(D)),u=R.split(P).map(d=>d.replace(/(^\D|\D$)/,"").split(/\D+/).join(g=="clock"&&":"||"/").replace(/(^\D|\D$)/,""));if(g=="dateWareki"){let d=u[0].split(/\D/),[l,_,N]=d;d.length==3&&l&&(u=[[Number(l)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[a]),_,N].join("/")])}y=Math.max(y,0),y=Math.min(y,V),E(d=>k(s({},d),{dataValue:["dates","months"].includes(g)?u:u[0],formatValue:R,eventType:"update",eventID:F()})),o(d=>k(s({},d),{index:y,prevIndex:d.index}))}}}},le={picker:{launch:e=>{let a=e.sheetID||F(),p=e,{onValueUpdate:g,min:i,max:f,era:E,restrict:v,defaultValue:o}=p,r=K(p,["onValueUpdate","min","max","era","restrict","defaultValue"]),S=!1,n=null,t=null;Ie.open("middleCenter",k(s({sheetID:a,size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{S&&g(n,t,!0)}},r),{content:h(ye.Center,{children:h(Ve,{restrict:v,min:i,max:f,era:E,defaultValue:o,sheetID:a,onValueUpdate:(T,x,w)=>{g(T,x,w),S=!w,n=T,t=x}})})}))},remove:e=>{ve.close(e)}}},_e={Shallow:e=>{let{rootStates:a,val_status:g}=e,i=fe(a);return h(H,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:h(ge.Description,k(s({className:a.className},i),{position:"absolute",width:1,freeCSS:k(s({},i.freeCSS),{color:"orange"}),children:h(H,{"data-input-value-shallow":g.componentId,children:"A"})}))})}},Ce=e=>{let ae=e,{tone:a,required:g,restrict:i="clock",componentId:f,era:E,form:v,name:o,min:r,max:S,className:n,enableFormSubmit:t,checkValidationAtFirst:p,onKeyDown:T,onValidate:x,onValidateDelay:w,onUpdateValue:I,onUpdateValidValue:q,onUserAction:G,value:V="",leftIndicator:y,rightIndicator:m,leftIcon:U,rightIcon:Q,freeCSS:L,wrapStyles:D}=ae,R=K(ae,["tone","required","restrict","componentId","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[u,d]=O(E),[l,_]=O(k(s({componentId:e.componentId||""},M.DataLeveling({restrict:i,value:V,era:u})),{ranges:[],eventType:"init",eventID:F()})),[N,Z]=O({ok:!1,notice:[]}),[j,J]=O({active:!1,index:0,prevIndex:-1}),me={rootStates:e,val_status:l,set_status:_,val_validate:N,set_validate:Z,val_era:u,set_era:d,val_focus:j,set_focus:J};Y.CommonEffects({type:"time",states:e,val_status:l,set_status:_,val_validate:N,set_validate:Z,SystemValidation:M.SystemValidation,ExtraOverrideStates:()=>M.DataLeveling({restrict:i,value:V,era:u})}),z(()=>{_(c=>s(s({},c),M.DataLeveling({restrict:i,value:V,era:u})))},[]);const te=ue(!1);return z(()=>{if(te.current){_(b=>s(s({},b),M.DataLeveling({restrict:i,value:b.dataValue,era:u})));let c=B.get("refreshEra_"+l.componentId);c&&c.refreshEra(u)}else te.current=!0},[u]),B.update({[l.componentId]:{openPicker:c=>{e.disabled||le.picker.launch({parent:c,sheetID:"PickerTips-"+l.componentId,restrict:i,min:r,max:S,defaultValue:l.dataValue,era:u,onValueUpdate:(b,A,W)=>{W&&(_($=>k(s(s({},$),M.DataLeveling({restrict:i,value:b,era:A})),{eventType:"update",eventID:F()})),d(A))}})},resetEra:c=>{d(c),_(b=>k(s(s({},b),M.DataLeveling({restrict:i,value:"",era:u})),{eventType:"update",eventID:F()}))}}}),z(()=>{let{index:c,active:b}=j;if(b){c=Math.max(c,0),c=Math.min(c,l.ranges.length-1);let{from:A,length:W}=l.ranges[c],$=de("#"+e.id)[0];$&&$.setSelectionRange(A,A+W)}},[j]),se(be,{val_status:l,set_status:_,val_validate:N,states:e,children:[h(_e.Shallow,s({},me)),h(we,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),ne.get().isTouchDevice?h(oe.Plain,k(s({"data-show-validation":Y.isShowValidation(N,l,!!p),"data-component-id":l.componentId,"data-input-origin":l.componentId,"data-disabled":e.disabled,className:n,freeCSS:{textAlign:"left"}},R),{children:l.formatValue,onClick:c=>{let b=B.get(l.componentId);b&&b.openPicker(`[data-input-origin="${l.componentId}"]`),c.stopPropagation()}})):h(H,s({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":Y.isShowValidation(N,l,!!p),"data-input-origin":l.componentId,"data-disabled":e.disabled,value:l.formatValue,className:n,tabIndex:ne.get().isTouchDevice?-1:0,onKeyDown:c=>{M.KeyDownEvent({restrict:i,event:c,val_era:u,val_status:l,set_status:_,val_focus:j,set_focus:J}),T&&T(c),t&&Y.SubmitForm(c,v)},onKeyUp:c=>{c.key=="Tab"&&J(b=>k(s({},b),{active:!0}))},onClick:c=>{let b=c.target.selectionEnd,A=0;l.ranges.forEach((W,$)=>{let{from:re,length:pe,region:ce}=W;re<=b&&b<=re+(ce||pe)&&(A=$)}),J(W=>k(s({},W),{active:!0,index:A})),c.preventDefault()},onChange:()=>{}},R))]})},C={Origin:e=>{let a=s({fontSize:"inherit",width:1,value:""},e);a.value=a.value||"";let[g]=O(e.componentId||F());if(a.componentId=g,ee.is.nullish(a.rightIcon)){let i=(e.restrict||"").match(/clock/)?Se:Te;a.rightIcon=h(ke,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:h(oe.Sub,{color:"cloud",border:"unset",ssSphere:2,fontColor:"theme",boxShadow:"0.normal",borderRadius:"3.tone.tertiary",flexCenter:!0,ssEffectsOnActive:"push",tabIndex:-1,id:"Picker-"+a.componentId,onClick:()=>{let f=B.get(a.componentId);f&&f.openPicker("#Picker-"+a.componentId)},children:h(he,{icon:i})})})}return h(De,{componentId:a.componentId,children:Ce,states:xe(a)})},Clock:e=>h(C.Origin,s({restrict:"clock",era:"clock"},e)),Date:e=>h(C.Origin,s({restrict:"date"},e)),Week:e=>h(C.Origin,s({restrict:"week"},e)),Month:e=>h(C.Origin,s({restrict:"month"},e)),Year:e=>h(C.Origin,s({restrict:"year"},e)),DateWareki:e=>{e=s({},e);let[a]=O(e.componentId||F());e.componentId=a;let v=e,{defaultEra:g="wareki"}=v,i=K(v,["defaultEra"]),[f,E]=O((()=>{let o="year";if(g=="wareki"&&(o="reiwa",e.value)){let[r,S,n]=e.value.split(/\D/);if(r&&S&&n){let t=Number(r);t>=2019?(t-=2019,o="reiwa"):t>=1989?(t-=1989,o="heisei"):t>=1926?(t-=1926,o="shouwa"):t>=1912?(t-=1912,o="taisho"):t>=1868&&(t-=1868,o="meiji"),t+=1}}return o})());return z(()=>{B.set({["refreshEra_"+a]:{refreshEra:o=>{E(o)}}})},[]),h(C.Origin,k(s({restrict:"dateWareki",leftIndicator:h(Ee,{label:"\u5143\u53F7",emptySelect:!1,value:f,tone:e.tone||"border",override:"force",flexCenter:!0,borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",height:1,freeCSS:{whiteSpace:"nowrap"},options:[{value:"year",label:"\u897F\u66A6"},{value:"reiwa",label:"\u4EE4\u548C"},{value:"heisei",label:"\u5E73\u6210"},{value:"shouwa",label:"\u662D\u548C"},{value:"taisho",label:"\u5927\u6B63"},{value:"meiji",label:"\u660E\u6CBB"}],onUpdateValidValue:o=>{E(o);let r=B.get(e.componentId);r&&r.resetEra&&r.resetEra(o)}})},i),{era:f}))},Periods:{Date:e=>h(C.Origin,s({restrict:"dates"},e)),Month:e=>h(C.Origin,s({restrict:"months"},e))},fn:le};export{C as Time,C as default};
|
|
1
|
+
import{a as ie,b as o,c as b,d as K}from"../../../chunk-C5N2D3ZX.js";import{Fragment as Ae,jsx as h,jsxs as se}from"react/jsx-runtime";import ee,{UUID as O,useStore as U}from"jmini";import*as X from"jmini";import{useState as P,useEffect as z,useRef as pe}from"react";import{$$fromRoot as de,Config as ne,ExtractStyles as fe}from"../../../@utils";import{Box as H,FAI as he}from"../../../atoms";import{Literal as ge,Row as ye}from"../../../mols";import{Button as oe}from"../../Button";import ve from"../../Tooltips";import Ie from"../../Sheet";import{faClock as Se}from"@fortawesome/free-solid-svg-icons/faClock";import{faCalendarAlt as Te}from"@fortawesome/free-solid-svg-icons/faCalendarAlt";import{OptionalInputWrapper as De,BoxWrapper as be,CoreEffects as Y,DefaultBoxishStyles as xe}from"../core";import{RightIcon as ke}from"..";import Ee from"../Select";import{InputLabel as Re}from"../Label";import we from"./Picker";const L=" ~ ",Ve={clock:{defaultValue:"--:--",format:/^\d{2}\D\d{2}$/,ranges:[{type:"hour",from:0,length:2},{type:"minute",from:3,length:2}],sets:1},date:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2}],sets:1},week:{defaultValue:"----\u5E74\u7B2C--\u9031",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4,region:6},{type:"week",from:6,length:2,region:3}],sets:1},month:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:3}],sets:1},year:{defaultValue:"----\u5E74",format:/^\d{4}$/,ranges:[{type:"year",from:0,length:4,region:5}],sets:1},dates:{defaultValue:"----/--/--",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2},{type:"date",from:8,length:2,region:5},{type:"year",from:10+L.length,length:4},{type:"month",from:15+L.length,length:2},{type:"date",from:18+L.length,length:2}],sets:2},months:{defaultValue:"----\u5E74--\u6708",format:/^\d{4}\D\d{2}$/,ranges:[{type:"year",from:0,length:4},{type:"month",from:5,length:2,region:6},{type:"year",from:8+L.length,length:4},{type:"month",from:13+L.length,length:2,region:3}],sets:2},dateWareki:{defaultValue:"----\u5E74--\u6708--\u65E5",format:/^\d{4}\D\d{2}\D\d{2}$/,ranges:[{type:"dateWareki",from:0,length:4,region:5},{type:"month",from:5,length:2,region:3},{type:"date",from:8,length:2,region:3}],sets:1}},F={PeriodMargin:" ~ ",DataLeveling:e=>{let{restrict:a,value:g,era:i}=e,f=ee.flatArray(g||""),{defaultValue:E,format:v,ranges:l,sets:r}=Ve[a],S=[],n=a=="clock"&&":"||"/";for(let t=0;t<f.length;t++)f[t]=String(f[t]).replace(/\D/ig,n);for(let t=0;t<r;t++){let u=f[t]||"";if(!u.match(v))f[t]="",S.push(E);else{let T=E;u.split(/\D/).forEach((k,R)=>{if(R==0&&a=="dateWareki"){let I=Number(k);i!="year"&&(I>=2019?i=="reiwa"?I-=2018:i=="heisei"&&(I=31):I>=1989?i=="heisei"?I-=1988:i=="shouwa"&&(I=64):I>=1926?i=="shouwa"?I-=1925:i=="taisho"&&(I=15):I>=1912?i=="taisho"?I-=1911:i=="meiji"&&(I=45):I>=1868&&(I-=1867)),k=I.zeroEmbed(4)}T=T.replace(new RegExp("------------------".slice(0,k.length)),k)}),S.push(T)}}return{formatValue:S.join(L),dataValue:["dates","months"].includes(a)?f:f[0],ranges:l}},SystemValidation:e=>{let{states:a}=e,{restrict:g,min:i,max:f,required:E}=a,v=[],l=ee.flatArray(e.value),r={empty:!1,escalated:1,filled:!0,correct:!0,prohibited:!1};(()=>{let S=g=="clock"&&":"||"/";for(let n=0;n<l.length;n++)l[n]=String(l[n]).replace(/\D/ig,S);for(let n=0;n<l.length;n++){let t=l[n],u=l[n-1];t.removeLetters()||(r.empty=!0),n>0&&(r.escalated&=+(t>=u))}r.escalated&&(r.empty||(g.match(/clock/)?l.forEach(n=>{let[t,u]=n.split(/\D+/);!t||!u?r.filled=!1:(Number(t)>23||Number(u)>59)&&(r.correct=!1)}):g.match(/date/)?l.forEach(n=>{let[t,u,T]=n.split(/\D+/);if(!t||!u||!T)r.filled=!1;else{let k=X.Time(n);(!k.validate||n!=k.toFormatYMD())&&(r.correct=!1)}}):g.match(/week/)?l.forEach(n=>{let[t,u]=n.split(/\D+/);if(!t||!u)r.filled=!1;else{let T=X.Time(t+"/01/01").weekday,R=X.Time(t+"/01/0"+(7-T+1)).addWeek(Number(u)-1);t!=String(R.year)&&(r.correct=!1)}}):g.match(/month/)?l.forEach(n=>{let[t,u]=n.split(/\D+/);!t||!u?r.filled=!1:X.Time([t,u,"01"].join("/")).validate||(r.correct=!1)}):g.match(/year/),r.filled&&r.correct&&l.forEach(n=>{{let t=Number(String(n).replace(/\D/ig,""));if(i&&Number(String(i).replace(/\D/ig,""))>t&&(r.prohibited=!0),f){let u=Number(String(f).replace(/\D/ig,""));t>u&&(r.prohibited=!0)}}})))})();{let{empty:S,escalated:n,filled:t,correct:u,prohibited:T}=r;S&&E&&(v=[{type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"}]),n||v.push({type:"invalid",label:"\u6642\u7CFB\u5217\u3092\u6B63\u3057\u304F\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}),u||v.push({type:"invalid",label:"\u7121\u52B9\u306A\u5024\u304C\u5165\u529B\u3055\u308C\u3066\u3044\u307E\u3059"}),t||v.push({type:"invalid",label:"\u6700\u5F8C\u307E\u3067\u5024\u3092\u57CB\u3081\u3066\u304F\u3060\u3055\u3044"}),T&&v.push({type:"invalid",label:se(Ae,{children:[h(H,{children:"\u5165\u529B\u7BC4\u56F2\u304C\u5236\u9650\u3055\u308C\u3066\u3044\u307E\u3059"}),"[",i||"\u4E0B\u9650\u7121\u3057","] ~ [",f||"\u4E0A\u9650\u7121\u3057","]"]})})}return{ok:!v.filter(({type:S})=>S=="invalid").length,notice:v}},KeyDownEvent:e=>{let{val_era:a,restrict:g,event:i,val_status:f,set_status:E,val_focus:v,set_focus:l}=e,{key:r,shiftKey:S,ctrlKey:n,metaKey:t}=i,u=n||t,{selectionStart:T,selectionEnd:k}=i.target,{index:R,prevIndex:I}=v,{ranges:q,formatValue:G}=f,V=q.length-1;if(["Tab","ArrowLeft","ArrowRight"].includes(r)){let y=0;if(r=="Tab"){let c=+!S*2-1;if(y=v.index+c,y<0||y>V)return}else{let c=r=="ArrowLeft"?-1:r=="ArrowRight"?1:0;u||T==0&&k==String(f.formatValue).length?y=c==1?V:0:y=Math.max(0,Math.min(R+c,V))}l(c=>b(o({},c),{index:y,prevIndex:R})),i.preventDefault()}if(["Backspace","ArrowUp","ArrowDown","0","1","2","3","4","5","6","7","8","9"].includes(r)){i.preventDefault();let y=R;y=Math.max(y,0),y=Math.min(y,V);let{type:c,from:j,length:Q}=q[y],$=G.slice(j,j+Q),D;if(r=="Backspace")D="------".slice(0,Q);else if(["ArrowUp","ArrowDown"].includes(r)){let _=r=="ArrowUp"?1:-1;$=$|0,D=$+_;let[p,d,s]=c=="dateWareki"?a=="year"?[0,2999,4]:a=="reiwa"?[1,2999,4]:a=="heisei"?[1,31,4]:a=="shouwa"?[1,64,4]:a=="taisho"?[1,15,4]:a=="meiji"?[1,45,4]:[0,0,0]:c=="minute"?[0,59,2]:c=="hour"?[0,23,2]:c=="date"?[1,31,2]:c=="week"?[1,53,2]:c=="month"?[1,12,2]:c=="year"?[0,2999,4]:[0,0,0];D>d?D=p:D<p&&(D=d),D=Number(D).zeroEmbed(s)}else if(["0","1","2","3","4","5","6","7","8","9"].includes(r)){let _=$|0,p=r,d=`${_}${p}`;if(I!=R&&(_=0,d="0"+p),c=="year"||c=="dateWareki"&&a=="year")Number(d)>1e4?D=p:D=d,(D|0)>1e3&&y++;else if(["hour","minute","date","week","month"].includes(c)||c=="dateWareki"&&a!="year"){let s=c=="dateWareki"?a=="reiwa"?100:a=="heisei"?31:a=="shouwa"?64:a=="taisho"?15:a=="meiji"?45:0:c=="minute"?59:c=="hour"?23:c=="date"?31:c=="week"?53:c=="month"?12:0;D=(d|0)>s?p:d,(Number(p)>Number(String(s)[0])||$=="0000".slice(0,String(s).length)&&(d!="0000".slice(0,String(s).length)||["minute","hour"].includes(c)&&I==R)||(d|0)>=ie(10,String(s).length-1))&&y++}c=="year"||c=="dateWareki"?D=(D|0).zeroEmbed(4):D=(D|0).zeroEmbed(2)}{let _=String(G).partReplace(j,String(D)),p=_.split(L).map(d=>d.replace(/(^\D|\D$)/,"").split(/\D+/).join(g=="clock"&&":"||"/").replace(/(^\D|\D$)/,""));if(g=="dateWareki"){let d=p[0].split(/\D/),[s,w,M]=d;d.length==3&&s&&(p=[[Number(s)-1+Number({year:1,reiwa:2019,heisei:1989,shouwa:1926,taisho:1912,meiji:1868}[a]),w,M].join("/")])}y=Math.max(y,0),y=Math.min(y,V),E(d=>b(o({},d),{dataValue:["dates","months"].includes(g)?p:p[0],formatValue:_,eventType:"update",eventID:O()})),l(d=>b(o({},d),{index:y,prevIndex:d.index}))}}}},le={picker:{launch:e=>{let a=e.sheetID||O(),u=e,{onValueUpdate:g,min:i,max:f,era:E,restrict:v,defaultValue:l}=u,r=K(u,["onValueUpdate","min","max","era","restrict","defaultValue"]),S=!1,n=null,t=null;Ie.open("middleCenter",b(o({sheetID:a,size:"S",padding:0,closeAtAroundClick:!0,closeAtParentBlur:!1,onClose:()=>{S&&g(n,t,!0)}},r),{content:h(ye.Center,{children:h(we,{restrict:v,min:i,max:f,era:E,defaultValue:l,sheetID:a,onValueUpdate:(T,k,R)=>{g(T,k,R),S=!R,n=T,t=k}})})}))},remove:e=>{ve.close(e)}}},_e={Shallow:e=>{let{rootStates:a,val_status:g}=e,i=fe(a);return h(H,{position:"absolute",top:0,left:0,right:0,height:0,overflow:"hidden",opacity:"trans",freeCSS:{zIndex:3,pointerEvents:"none"},children:h(ge.Description,b(o({className:a.className},i),{position:"absolute",width:1,freeCSS:b(o({},i.freeCSS),{color:"orange"}),children:h(H,{"data-input-value-shallow":g.componentId,children:"A"})}))})}},Ce=e=>{let ae=e,{tone:a,required:g,restrict:i="clock",componentId:f,era:E,form:v,name:l,min:r,max:S,className:n,enableFormSubmit:t,checkValidationAtFirst:u,onKeyDown:T,onValidate:k,onValidateDelay:R,onUpdateValue:I,onUpdateValidValue:q,onUserAction:G,value:V="",leftIndicator:y,rightIndicator:c,leftIcon:j,rightIcon:Q,freeCSS:$,wrapStyles:D}=ae,_=K(ae,["tone","required","restrict","componentId","era","form","name","min","max","className","enableFormSubmit","checkValidationAtFirst","onKeyDown","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","leftIndicator","rightIndicator","leftIcon","rightIcon","freeCSS","wrapStyles"]),[p,d]=P(E),[s,w]=P(b(o({componentId:e.componentId||""},F.DataLeveling({restrict:i,value:V,era:p})),{ranges:[],eventType:"init",eventID:O()})),[M,Z]=P({ok:!1,notice:[]}),[J,N]=P({active:!1,index:0,prevIndex:-1}),me={rootStates:e,val_status:s,set_status:w,val_validate:M,set_validate:Z,val_era:p,set_era:d,val_focus:J,set_focus:N};Y.CommonEffects({type:"time",states:e,val_status:s,set_status:w,val_validate:M,set_validate:Z,SystemValidation:F.SystemValidation,ExtraOverrideStates:()=>F.DataLeveling({restrict:i,value:V,era:p})}),z(()=>{w(m=>o(o({},m),F.DataLeveling({restrict:i,value:V,era:p})))},[]);const te=pe(!1);return z(()=>{if(te.current){w(x=>o(o({},x),F.DataLeveling({restrict:i,value:x.dataValue,era:p})));let m=U.get("refreshEra_"+s.componentId);m&&m.refreshEra(p)}else te.current=!0},[p]),U.update({[s.componentId]:{openPicker:m=>{e.disabled||le.picker.launch({parent:m,sheetID:"PickerTips-"+s.componentId,restrict:i,min:r,max:S,defaultValue:s.dataValue,era:p,onValueUpdate:(x,C,W)=>{W&&(w(B=>b(o(o({},B),F.DataLeveling({restrict:i,value:x,era:C})),{eventType:"update",eventID:O()})),d(C))}})},resetEra:m=>{d(m),w(x=>b(o(o({},x),F.DataLeveling({restrict:i,value:"",era:p})),{eventType:"update",eventID:O()}))}}}),z(()=>{let{index:m,active:x}=J;if(x){m=Math.max(m,0),m=Math.min(m,s.ranges.length-1);let{from:C,length:W}=s.ranges[m],B=de("#"+e.id)[0];B&&B.setSelectionRange(C,C+W)}w(C=>b(o({},C),{isFocusing:x}))},[J]),se(be,{val_status:s,set_status:w,val_validate:M,states:e,children:[h(_e.Shallow,o({},me)),h(Re,{componentId:e.componentId,fontSize:e.fontSize,required:e.required,label:e.label,isActive:!0}),ne.get().isTouchDevice?h(oe.Plain,b(o({"data-show-validation":Y.isShowValidation(M,s,!!u),"data-component-id":s.componentId,"data-input-origin":s.componentId,"data-disabled":e.disabled,className:n,freeCSS:{textAlign:"left"}},_),{children:s.formatValue,onClick:m=>{let x=U.get(s.componentId);x&&x.openPicker(`[data-input-origin="${s.componentId}"]`),m.stopPropagation()},onFocus:()=>{N(m=>b(o({},m),{active:!0}))},onBlur:()=>{N(m=>b(o({},m),{active:!1}))}})):h(H,o({htmlTag:"input",type:"text",inputMode:"numeric","data-show-validation":Y.isShowValidation(M,s,!!u),"data-input-origin":s.componentId,"data-disabled":e.disabled,value:s.formatValue,className:n,tabIndex:ne.get().isTouchDevice?-1:0,onKeyDown:m=>{F.KeyDownEvent({restrict:i,event:m,val_era:p,val_status:s,set_status:w,val_focus:J,set_focus:N}),T&&T(m),t&&Y.SubmitForm(m,v)},onKeyUp:m=>{m.key=="Tab"&&N(x=>b(o({},x),{active:!0}))},onClick:m=>{let x=m.target.selectionEnd,C=0;s.ranges.forEach((W,B)=>{let{from:re,length:ce,region:ue}=W;re<=x&&x<=re+(ue||ce)&&(C=B)}),N(W=>b(o({},W),{active:!0,index:C})),m.preventDefault()},onBlur:()=>{N(m=>b(o({},m),{active:!1}))},onChange:()=>{}},_))]})},A={Origin:e=>{let a=o({fontSize:"inherit",width:1,value:""},e);a.value=a.value||"";let[g]=P(e.componentId||O());if(a.componentId=g,ee.is.nullish(a.rightIcon)){let i=(e.restrict||"").match(/clock/)?Se:Te;a.rightIcon=h(ke,{ssSphere:2,freeCSS:{pointerEvents:"all"},children:h(oe.Sub,{color:"cloud",border:"unset",ssSphere:2,fontColor:"theme",boxShadow:"0.normal",borderRadius:"3.tone.tertiary",flexCenter:!0,ssEffectsOnActive:"push",tabIndex:-1,id:"Picker-"+a.componentId,onClick:()=>{let f=U.get(a.componentId);f&&f.openPicker("#Picker-"+a.componentId)},children:h(he,{icon:i})})})}return h(De,{componentId:a.componentId,children:Ce,states:xe(a)})},Clock:e=>h(A.Origin,o({restrict:"clock",era:"clock"},e)),Date:e=>h(A.Origin,o({restrict:"date"},e)),Week:e=>h(A.Origin,o({restrict:"week"},e)),Month:e=>h(A.Origin,o({restrict:"month"},e)),Year:e=>h(A.Origin,o({restrict:"year"},e)),DateWareki:e=>{e=o({},e);let[a]=P(e.componentId||O());e.componentId=a;let v=e,{defaultEra:g="wareki"}=v,i=K(v,["defaultEra"]),[f,E]=P((()=>{let l="year";if(g=="wareki"&&(l="reiwa",e.value)){let[r,S,n]=e.value.split(/\D/);if(r&&S&&n){let t=Number(r);t>=2019?(t-=2019,l="reiwa"):t>=1989?(t-=1989,l="heisei"):t>=1926?(t-=1926,l="shouwa"):t>=1912?(t-=1912,l="taisho"):t>=1868&&(t-=1868,l="meiji"),t+=1}}return l})());return z(()=>{U.set({["refreshEra_"+a]:{refreshEra:l=>{E(l)}}})},[]),h(A.Origin,b(o({restrict:"dateWareki",leftIndicator:h(Ee,{label:"\u5143\u53F7",emptySelect:!1,value:f,tone:e.tone||"border",override:"force",flexCenter:!0,borderTopRightRadius:"2/3",borderBottomRightRadius:"2/3",height:1,freeCSS:{whiteSpace:"nowrap"},options:[{value:"year",label:"\u897F\u66A6"},{value:"reiwa",label:"\u4EE4\u548C"},{value:"heisei",label:"\u5E73\u6210"},{value:"shouwa",label:"\u662D\u548C"},{value:"taisho",label:"\u5927\u6B63"},{value:"meiji",label:"\u660E\u6CBB"}],onUpdateValidValue:l=>{E(l);let r=U.get(e.componentId);r&&r.resetEra&&r.resetEra(l)}})},i),{era:f}))},Periods:{Date:e=>h(A.Origin,o({restrict:"dates"},e)),Month:e=>h(A.Origin,o({restrict:"months"},e))},fn:le};export{A as Time,A as default};
|