intable 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__uno.css +1 -1
- package/dist/components/AndOr.d.ts +35 -0
- package/dist/components/AndOr.js +188 -0
- package/dist/components/AndOrFields.d.ts +38 -0
- package/dist/components/AndOrFields.js +280 -0
- package/dist/components/Filter.d.ts +10 -0
- package/dist/components/Filter.js +97 -0
- package/dist/filter.js +6 -0
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/useVirtualizer.js +55 -59
- package/dist/index.d.ts +4 -3
- package/dist/index.js +245 -232
- package/dist/plugins/CommandPlugin.js +19 -21
- package/dist/plugins/EditablePlugin.js +6 -10
- package/dist/plugins/FilterPlugin.d.ts +18 -0
- package/dist/plugins/FilterPlugin.js +123 -0
- package/dist/plugins/LoadMorePlugin.d.ts +24 -0
- package/dist/plugins/LoadMorePlugin.js +62 -0
- package/dist/plugins/MenuPlugin.js +4 -3
- package/dist/plugins/RenderPlugin/index.d.ts +1 -0
- package/dist/plugins/RenderPlugin/index.js +1 -1
- package/dist/plugins/ValidatorPlugin.js +36 -35
- package/dist/plugins/VirtualScrollPlugin.js +73 -75
- package/dist/style.css +2 -2
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +42 -31
- package/package.json +1 -1
package/dist/__uno.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--un-bg-opacity:100%;--un-leading:initial;--un-content:"";--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-text-opacity:100%;--un-border-opacity:100%;--un-space-y-reverse:initial;--un-space-x-reverse:initial;--un-outline-style:solid;--un-outline-opacity:100%}}@property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-leading{syntax:"*";inherits:false}@property --un-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --un-outline-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-bg-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-translate-x{syntax:"*";inherits:false;initial-value:0}@property --un-translate-y{syntax:"*";inherits:false;initial-value:0}@property --un-translate-z{syntax:"*";inherits:false;initial-value:0}:root,:host{--spacing:.25rem;--colors-gray-DEFAULT:#99a1af;--text-sm-fontSize:.875rem;--text-sm-lineHeight:1.25rem;--default-transition-timingFunction:cubic-bezier(.4,0,.2,1);--default-transition-duration:.15s;--radius-sm:.25rem;--colors-red-DEFAULT:#ff6568;--colors-blue-DEFAULT:#54a2ff;--colors-green-DEFAULT:#05df72;--font-sans:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--default-font-family:var(--font-sans);--default-monoFont-family:var(--font-mono)}@supports (color:lab(0% 0 0)){:root,:host{--colors-gray-DEFAULT:lab(65.9269% -.832677 -8.17474);--colors-red-DEFAULT:lab(63.7053% 60.745 31.3109);--colors-blue-DEFAULT:lab(65.0361% -1.42065 -56.9802);--colors-green-DEFAULT:lab(78.503% -64.9264 39.7492)}}*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-featureSettings,normal);font-variation-settings:var(--default-font-variationSettings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-monoFont-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-monoFont-featureSettings,normal);font-variation-settings:var(--default-monoFont-variationSettings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden~=until-found])){display:none!important}.container{width:100%}.aic{align-items:center}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.text-3\.5{font-size:.875rem}.c-red\/75{color:color-mix(in srgb,var(--colors-red-DEFAULT)75%,transparent)}.lh-\[1\]{--un-leading:1;line-height:1}.m9{margin:36px}.mx-1{margin-inline:4px}.mx-3\!{margin-inline:12px!important}.my-1{margin-block:4px}.ml{margin-left:16px}.ml-\.5{margin-left:2px}.ml-1{margin-left:4px}.mr--1{margin-right:-4px}.mr-1{margin-right:4px}.mr-2{margin-right:8px}.mr-2\.5{margin-right:10px}.p-1{padding:4px}.px,.px-4{padding-inline:16px}.px-2{padding-inline:8px}.py-1{padding-block:4px}.py-2{padding-block:8px}.pl-1{padding-left:4px}.pr-4{padding-right:16px}.ps{padding-inline-start:16px}.outline-0{outline-style:var(--un-outline-style);outline-width:0}.outline-2{outline-style:var(--un-outline-style);outline-width:2px}.outline-blue{outline-color:color-mix(in srgb,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.b{border-width:1px}.rd-2{border-radius:.5rem}.rd-sm{border-radius:var(--radius-sm)}.bg-\#fff{background-color:color-mix(in oklab,#fff var(--un-bg-opacity),transparent)}.bg-gray\/20{background-color:color-mix(in srgb,var(--colors-gray-DEFAULT)20%,transparent)}.bg-green\!{background-color:color-mix(in srgb,var(--colors-green-DEFAULT)var(--un-bg-opacity),transparent)!important}.bg-red\!{background-color:color-mix(in srgb,var(--colors-red-DEFAULT)var(--un-bg-opacity),transparent)!important}.op-15{opacity:.15}.op-75{opacity:.75}.op40{opacity:.4}.flex{display:flex}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.gap-2{gap:8px}.grid{display:grid}.size-4\!{width:16px!important;height:16px!important}.size-full{width:100%;height:100%}.h-1\!{height:4px!important}.h-a\!{height:auto!important}.h-full{height:100%}.max-h-100{max-height:400px}.min-h-40{min-height:160px}.min-h-a\!{min-height:auto!important}.w-10px\!{width:10px!important}.after\:h-1:after{height:4px}.after\:w-1:after{width:4px}.inline{display:inline}.block{display:block}.hidden{display:none}.visible{visibility:visible}.collapse{visibility:collapse}.cursor-s-resize{cursor:s-resize}.cursor-w-resize{cursor:w-resize}.pointer-events-none{pointer-events:none}.resize{resize:both}.resize-none{resize:none}.select-none{-webkit-user-select:none;user-select:none}.translate-x-1\/2{--un-translate-x:50%;translate:var(--un-translate-x)var(--un-translate-y)}.transform{transform:var(--un-rotate-x)var(--un-rotate-y)var(--un-rotate-z)var(--un-skew-x)var(--un-skew-y)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,--un-gradient-from,--un-gradient-via,--un-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--un-ease,var(--default-transition-timingFunction));transition-duration:var(--un-duration,var(--default-transition-duration))}.items-center{align-items:center}.box-border{box-sizing:border-box}.inset-0{inset:0}.bottom-0{bottom:0}.left-0{left:0}.right-0{right:0}.top-0{top:0}.justify-end\!{justify-content:flex-end!important}.justify-center{justify-content:center}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.z--1{z-index:-1}.z-1{z-index:1}.z-9{z-index:9}.overflow-auto{overflow:auto}.table{display:table}.table-cell{display:table-cell}@supports (color:color-mix(in lab, red, red)){.c-red\/75{color:color-mix(in oklab,var(--colors-red-DEFAULT)75%,transparent)}.outline-blue{outline-color:color-mix(in oklab,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.bg-gray\/20{background-color:color-mix(in oklab,var(--colors-gray-DEFAULT)20%,transparent)}.bg-green\!{background-color:color-mix(in oklab,var(--colors-green-DEFAULT)var(--un-bg-opacity),transparent)!important}.bg-red\!{background-color:color-mix(in oklab,var(--colors-red-DEFAULT)var(--un-bg-opacity),transparent)!important}}
|
|
1
|
+
@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--un-bg-opacity:100%;--un-leading:initial;--un-content:"";--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-text-opacity:100%;--un-border-opacity:100%;--un-space-y-reverse:initial;--un-space-x-reverse:initial;--un-outline-style:solid;--un-outline-opacity:100%}}@property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-leading{syntax:"*";inherits:false}@property --un-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --un-outline-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-border-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-bg-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-inset-ring-color{syntax:"*";inherits:false}@property --un-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-shadow-color{syntax:"*";inherits:false}@property --un-ring-color{syntax:"*";inherits:false}@property --un-ring-inset{syntax:"*";inherits:false}@property --un-ring-offset-color{syntax:"*";inherits:false}@property --un-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --un-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-shadow-color{syntax:"*";inherits:false}@property --un-translate-x{syntax:"*";inherits:false;initial-value:0}@property --un-translate-y{syntax:"*";inherits:false;initial-value:0}@property --un-translate-z{syntax:"*";inherits:false;initial-value:0}@property --un-space-y-reverse{syntax:"*";inherits:false;initial-value:0}:root,:host{--spacing:.25rem;--radius-DEFAULT:.25rem;--colors-gray-DEFAULT:#99a1af;--text-sm-fontSize:.875rem;--text-sm-lineHeight:1.25rem;--default-transition-timingFunction:cubic-bezier(.4,0,.2,1);--default-transition-duration:.15s;--radius-md:.375rem;--radius-xl:.75rem;--fontWeight-medium:500;--radius-sm:.25rem;--colors-blue-DEFAULT:#54a2ff;--colors-red-DEFAULT:#ff6568;--colors-green-DEFAULT:#05df72;--colors-black:#000;--font-sans:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--default-font-family:var(--font-sans);--default-monoFont-family:var(--font-mono)}@supports (color:lab(0% 0 0)){:root,:host{--colors-gray-DEFAULT:lab(65.9269% -.832677 -8.17474);--colors-blue-DEFAULT:lab(65.0361% -1.42065 -56.9802);--colors-red-DEFAULT:lab(63.7053% 60.745 31.3109);--colors-green-DEFAULT:lab(78.503% -64.9264 39.7492)}}*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-featureSettings,normal);font-variation-settings:var(--default-font-variationSettings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-monoFont-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-monoFont-featureSettings,normal);font-variation-settings:var(--default-monoFont-variationSettings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden~=until-found])){display:none!important}.container{width:100%}.aic{align-items:center}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.text-3{font-size:.75rem}.text-3\.5{font-size:.875rem}.text-4{font-size:1rem}.c-\#1e3a8a{color:color-mix(in oklab,#1e3a8a var(--un-text-opacity),transparent)}.c-\#7c2d12{color:color-mix(in oklab,#7c2d12 var(--un-text-opacity),transparent)}.c-blue{color:color-mix(in srgb,var(--colors-blue-DEFAULT)var(--un-text-opacity),transparent)}.c-red\/75{color:color-mix(in srgb,var(--colors-red-DEFAULT)75%,transparent)}.leading-5{--un-leading:calc(4px*5);line-height:20px}.lh-\[1\]{--un-leading:1;line-height:1}.font-medium{--un-font-weight:var(--fontWeight-medium);font-weight:var(--fontWeight-medium)}.m9{margin:36px}.mx-1{margin-inline:4px}.mx-3\!{margin-inline:12px!important}.my-1{margin-block:4px}.ml{margin-left:16px}.ml-\.5{margin-left:2px}.ml-1{margin-left:4px}.mr--1{margin-right:-4px}.mr-1{margin-right:4px}.mr-2{margin-right:8px}.mr-2\.5{margin-right:10px}.mt-1{margin-top:4px}.p-1{padding:4px}.p-4\!{padding:16px!important}.px,.px-4{padding-inline:16px}.px-1\.5{padding-inline:6px}.px-2{padding-inline:8px}.py-1{padding-block:4px}.py-1\.5{padding-block:6px}.py-2{padding-block:8px}.pl-1{padding-left:4px}.pl-4{padding-left:16px}.pr-4{padding-right:16px}.ps{padding-inline-start:16px}.outline-0{outline-style:var(--un-outline-style);outline-width:0}.outline-2{outline-style:var(--un-outline-style);outline-width:2px}.outline-blue{outline-color:color-mix(in srgb,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.outline-none{--un-outline-style:none;outline-style:none}.b,.b-1,.border{border-width:1px}.b-r-0{border-right-width:0}.b-\#00000000\!{border-color:color-mix(in oklab,#0000 var(--un-border-opacity),transparent)!important}.b-\#4f7ff0{border-color:color-mix(in oklab,#4f7ff0 var(--un-border-opacity),transparent)}.b-\#f59e0b{border-color:color-mix(in oklab,#f59e0b var(--un-border-opacity),transparent)}.rd-2{border-radius:.5rem}.rd-sm{border-radius:var(--radius-sm)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.rd-l-4{border-top-left-radius:1rem;border-bottom-left-radius:1rem}.b-dashed{--un-border-style:dashed;border-style:dashed}.b-solid{--un-border-style:solid;border-style:solid}.bg-\#dbe6ff\/75{background-color:#dbe6ffbf;background-color:lab(91.0303% -.143617 -13.4803/.75)}.bg-\#fff{background-color:color-mix(in oklab,#fff var(--un-bg-opacity),transparent)}.bg-\#fff3d6\/85{background-color:#fff3d6d9;background-color:lab(96.236% .744313 15.5662/.85)}.bg-blue\/20\!{background-color:color-mix(in srgb,var(--colors-blue-DEFAULT)20%,transparent)!important}.bg-gray\/20{background-color:color-mix(in srgb,var(--colors-gray-DEFAULT)20%,transparent)}.bg-green\!{background-color:color-mix(in srgb,var(--colors-green-DEFAULT)var(--un-bg-opacity),transparent)!important}.bg-red\!{background-color:color-mix(in srgb,var(--colors-red-DEFAULT)var(--un-bg-opacity),transparent)!important}.bg-transparent{background-color:#0000}.hover\:bg-black\/8:hover{background-color:color-mix(in srgb,var(--colors-black)8%,transparent)}.op-0{opacity:0}.op-15{opacity:.15}.op-60{opacity:.6}.op-75{opacity:.75}.op40{opacity:.4}.group:hover .group-hover\:op-100{opacity:1}.flex{display:flex}.flex-1{flex:1}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.gap-1{gap:4px}.gap-1\.5{gap:6px}.gap-2{gap:8px}.grid{display:grid}.size-3\.5{width:14px;height:14px}.size-4\!{width:16px!important;height:16px!important}.size-full{width:100%;height:100%}.h-1\!{height:4px!important}.h-a\!{height:auto!important}.h-full{height:100%}.max-h-100{max-height:400px}.min-h-16{min-height:64px}.min-h-40{min-height:160px}.min-h-a\!{min-height:auto!important}.min-w-24{min-width:96px}.min-w-52{min-width:208px}.w-10{width:40px}.w-10px\!{width:10px!important}.w-a\!{width:auto!important}.after\:h-1:after{height:4px}.after\:w-1:after{width:4px}.inline{display:inline}.block{display:block}.inline-block{display:inline-block}.contents{display:contents}.hidden{display:none}.visible{visibility:visible}.collapse{visibility:collapse}.cursor-s-resize{cursor:s-resize}.cursor-w-resize{cursor:w-resize}.pointer-events-none{pointer-events:none}.resize{resize:both}.resize-none{resize:none}.select-none{-webkit-user-select:none;user-select:none}.shadow-sm{--un-shadow:0 1px 3px 0 var(--un-shadow-color,#0000001a),0 1px 2px -1px var(--un-shadow-color,#0000001a);box-shadow:var(--un-inset-shadow),var(--un-inset-ring-shadow),var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}.translate-x--1\/2{--un-translate-x:-50%;translate:var(--un-translate-x)var(--un-translate-y)}.translate-x-1\/2{--un-translate-x:50%;translate:var(--un-translate-x)var(--un-translate-y)}.translate-y--1\/2{--un-translate-y:-50%;translate:var(--un-translate-x)var(--un-translate-y)}.transform{transform:var(--un-rotate-x)var(--un-rotate-y)var(--un-rotate-z)var(--un-skew-x)var(--un-skew-y)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,--un-gradient-from,--un-gradient-via,--un-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--un-ease,var(--default-transition-timingFunction));transition-duration:var(--un-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--un-ease,var(--default-transition-timingFunction));transition-duration:var(--un-duration,var(--default-transition-duration))}.items-start{align-items:flex-start}.items-center{align-items:center}.box-border{box-sizing:border-box}.inset-0{inset:0}.bottom-0{bottom:0}.left--0,.left-0{left:0}.right-0{right:0}.top-0{top:0}.top-1\/2{top:50%}.justify-end\!{justify-content:flex-end!important}.justify-center{justify-content:center}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.sticky{position:sticky}.z--1{z-index:-1}.z-1{z-index:1}.z-2{z-index:2}.z-9{z-index:9}.overflow-auto{overflow:auto}.filter{filter:var(--un-blur,)var(--un-brightness,)var(--un-contrast,)var(--un-grayscale,)var(--un-hue-rotate,)var(--un-invert,)var(--un-saturate,)var(--un-sepia,)var(--un-drop-shadow,)}.table{display:table}.table-cell{display:table-cell}:where(.space-y-5>:not(:last-child)){--un-space-y-reverse:0;margin-block-start:calc(calc(4px*5)*var(--un-space-y-reverse));margin-block-end:calc(calc(4px*5)*calc(1 - var(--un-space-y-reverse)))}@supports (color:color-mix(in lab, red, red)){.c-blue{color:color-mix(in oklab,var(--colors-blue-DEFAULT)var(--un-text-opacity),transparent)}.c-red\/75{color:color-mix(in oklab,var(--colors-red-DEFAULT)75%,transparent)}.outline-blue{outline-color:color-mix(in oklab,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.bg-blue\/20\!{background-color:color-mix(in oklab,var(--colors-blue-DEFAULT)20%,transparent)!important}.bg-gray\/20{background-color:color-mix(in oklab,var(--colors-gray-DEFAULT)20%,transparent)}.bg-green\!{background-color:color-mix(in oklab,var(--colors-green-DEFAULT)var(--un-bg-opacity),transparent)!important}.bg-red\!{background-color:color-mix(in oklab,var(--colors-red-DEFAULT)var(--un-bg-opacity),transparent)!important}.hover\:bg-black\/8:hover{background-color:color-mix(in oklab,var(--colors-black)8%,transparent)}}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
export type AndOrNode = GroupNode | RuleNode;
|
|
3
|
+
type GroupNode = {
|
|
4
|
+
op?: 'and' | 'or';
|
|
5
|
+
children?: AndOrNode[];
|
|
6
|
+
};
|
|
7
|
+
export type RuleNode = {
|
|
8
|
+
field: string;
|
|
9
|
+
op: string;
|
|
10
|
+
value: any;
|
|
11
|
+
};
|
|
12
|
+
export type AndOrProps = {
|
|
13
|
+
value?: AndOrNode;
|
|
14
|
+
onChange?: (value: AndOrNode) => void;
|
|
15
|
+
renderRule: (ctx: {
|
|
16
|
+
node: RuleNode;
|
|
17
|
+
update: (patch: Partial<RuleNode>) => void;
|
|
18
|
+
}) => JSX.Element;
|
|
19
|
+
renderGroup?: (ctx: {
|
|
20
|
+
node: GroupNode;
|
|
21
|
+
update: (patch: Partial<GroupNode>) => void;
|
|
22
|
+
}) => JSX.Element;
|
|
23
|
+
class?: string;
|
|
24
|
+
style?: string;
|
|
25
|
+
newRule?: (current: RuleNode) => RuleNode;
|
|
26
|
+
};
|
|
27
|
+
declare const GroupNode: (props: {
|
|
28
|
+
class?: string;
|
|
29
|
+
node: GroupNode;
|
|
30
|
+
content: JSX.Element;
|
|
31
|
+
onAdd: (op: "and" | "or") => void;
|
|
32
|
+
onRemove: () => void;
|
|
33
|
+
}) => JSX.Element;
|
|
34
|
+
export declare const AndOr: (_props: AndOrProps) => JSX.Element;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { addEventListener, className, createComponent, delegateEvents, effect, insert, template } from "solid-js/web";
|
|
2
|
+
import { For, Match, Show, Switch, createEffect, mergeProps as mergeProps$1 } from "solid-js";
|
|
3
|
+
import { createMutable } from "solid-js/store";
|
|
4
|
+
var _tmpl$ = /* @__PURE__ */ template("<div class=\"group flex items-center gap-2 min-w-52\"><div class=\"flex items-center gap-1 transition-opacity op-0 group-hover:op-100\"><button class=\"text-3 px-1.5 py-1 rounded-md hover:bg-black/8\">+与</button><button class=\"text-3 px-1.5 py-1 rounded-md hover:bg-black/8\">+或</button><button class=\"text-3 px-2 py-1 rounded-md hover:bg-black/8\">x"), _tmpl$2 = /* @__PURE__ */ template("<div>"), _tmpl$3 = /* @__PURE__ */ template("<div class=\"flex flex-col items-start space-y-5\">"), _tmpl$4 = /* @__PURE__ */ template("<div class=\"relative min-h-16 flex pl-4\"><div>"), _tmpl$5 = /* @__PURE__ */ template("<select class=\"bg-transparent text-4 leading-5 font-medium outline-none\"style=appearance:none><option value=and>与</option><option value=or>或");
|
|
5
|
+
function isRuleNode(a) {
|
|
6
|
+
return "field" in a;
|
|
7
|
+
}
|
|
8
|
+
function isGroupNode(a) {
|
|
9
|
+
return !isRuleNode(a);
|
|
10
|
+
}
|
|
11
|
+
function createRule(a = "", S = "eq", C = null) {
|
|
12
|
+
return {
|
|
13
|
+
field: a,
|
|
14
|
+
op: S,
|
|
15
|
+
value: C
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function createGroup(a = "and", S = []) {
|
|
19
|
+
return {
|
|
20
|
+
op: a,
|
|
21
|
+
children: S
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function defaultTree() {
|
|
25
|
+
return createRule("name", "contains", "");
|
|
26
|
+
}
|
|
27
|
+
function updateNode(a, S) {
|
|
28
|
+
let C = S(a);
|
|
29
|
+
return C !== a && Object.assign(a, C), a;
|
|
30
|
+
}
|
|
31
|
+
function removeNode(a, S) {
|
|
32
|
+
if (!isGroupNode(a) || !a.children?.length) return !1;
|
|
33
|
+
for (let C = 0; C < a.children.length; C++) {
|
|
34
|
+
let w = a.children[C];
|
|
35
|
+
if (w === S) return a.children.splice(C, 1), !0;
|
|
36
|
+
if (isGroupNode(w) && removeNode(w, S)) return !0;
|
|
37
|
+
}
|
|
38
|
+
return !1;
|
|
39
|
+
}
|
|
40
|
+
function normalizeNode(a) {
|
|
41
|
+
if (!isGroupNode(a)) return a;
|
|
42
|
+
let S = a.children ?? [];
|
|
43
|
+
a.children = S;
|
|
44
|
+
for (let a = 0; a < S.length; a++) S[a] = normalizeNode(S[a]);
|
|
45
|
+
return S.length === 1 ? S[0] : a;
|
|
46
|
+
}
|
|
47
|
+
function normalizeTree(a) {
|
|
48
|
+
return normalizeNode(a);
|
|
49
|
+
}
|
|
50
|
+
function addByCurrentGroup(a, S, C, w) {
|
|
51
|
+
if (a === S) {
|
|
52
|
+
if (!isGroupNode(a)) return {
|
|
53
|
+
next: createGroup(C, [a, w]),
|
|
54
|
+
found: !0
|
|
55
|
+
};
|
|
56
|
+
let S = a.children ??= [];
|
|
57
|
+
return a.op === C ? (S.push(w), {
|
|
58
|
+
next: a,
|
|
59
|
+
found: !0
|
|
60
|
+
}) : {
|
|
61
|
+
next: createGroup(C, [a, w]),
|
|
62
|
+
found: !0
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (!isGroupNode(a) || !a.children?.length) return {
|
|
66
|
+
next: a,
|
|
67
|
+
found: !1
|
|
68
|
+
};
|
|
69
|
+
let T = a.children;
|
|
70
|
+
for (let E = 0; E < T.length; E++) {
|
|
71
|
+
let D = T[E];
|
|
72
|
+
if (D === S) return a.op === C ? T.splice(E + 1, 0, w) : T[E] = createGroup(C, [D, w]), {
|
|
73
|
+
next: a,
|
|
74
|
+
found: !0
|
|
75
|
+
};
|
|
76
|
+
if (isGroupNode(D)) {
|
|
77
|
+
let O = addByCurrentGroup(D, S, C, w);
|
|
78
|
+
if (O.found) return O.next !== D && (T[E] = O.next), {
|
|
79
|
+
next: a,
|
|
80
|
+
found: !0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
next: a,
|
|
86
|
+
found: !1
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
var RuleEditor = (S) => (() => {
|
|
90
|
+
var C = _tmpl$(), w = C.firstChild, T = w.firstChild, D = T.nextSibling, O = D.nextSibling;
|
|
91
|
+
return insert(C, () => S.content, w), T.$$click = () => S.onAdd("and"), D.$$click = () => S.onAdd("or"), addEventListener(O, "click", S.onRemove, !0), C;
|
|
92
|
+
})(), GroupNode = (a) => (() => {
|
|
93
|
+
var C = _tmpl$2();
|
|
94
|
+
return insert(C, () => a.content), effect(() => className(C, `flex items-center gap-1.5 px-2 py-1.5 rounded-xl shadow-sm ${a.node.op === "or" ? "b-1 b-solid b-#f59e0b bg-#fff3d6/85 c-#7c2d12" : "b-1 b-solid b-#4f7ff0 bg-#dbe6ff/75 c-#1e3a8a"} ${a.class ?? ""}`)), C;
|
|
95
|
+
})();
|
|
96
|
+
const AndOr = (a) => {
|
|
97
|
+
let w = mergeProps$1({ value: defaultTree() }, a), D = createMutable({ tree: w.value }), k = (a) => {
|
|
98
|
+
let S = normalizeTree(a);
|
|
99
|
+
D.tree = S, w.onChange?.(S);
|
|
100
|
+
}, A = (a, S) => {
|
|
101
|
+
updateNode(a, S), k(D.tree);
|
|
102
|
+
}, j = (a, S) => {
|
|
103
|
+
let C = D.tree;
|
|
104
|
+
if (isRuleNode(C)) {
|
|
105
|
+
k(createGroup(S, [C, w.newRule?.(C) ?? createRule("")]));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
let T = addByCurrentGroup(C, a, S, w.newRule?.(a) ?? createRule(""));
|
|
109
|
+
k(T.next);
|
|
110
|
+
}, M = (a) => {
|
|
111
|
+
a !== D.tree && removeNode(D.tree, a) && k(D.tree);
|
|
112
|
+
};
|
|
113
|
+
createEffect(() => {
|
|
114
|
+
w.value && (D.tree = w.value);
|
|
115
|
+
});
|
|
116
|
+
let N = (a) => createComponent(Switch, { get children() {
|
|
117
|
+
return [createComponent(Match, {
|
|
118
|
+
get when() {
|
|
119
|
+
return isRuleNode(a.node);
|
|
120
|
+
},
|
|
121
|
+
get children() {
|
|
122
|
+
return createComponent(RuleEditor, {
|
|
123
|
+
get node() {
|
|
124
|
+
return a.node;
|
|
125
|
+
},
|
|
126
|
+
get content() {
|
|
127
|
+
return createComponent(w.renderRule, {
|
|
128
|
+
get node() {
|
|
129
|
+
return a.node;
|
|
130
|
+
},
|
|
131
|
+
update: (S) => A(a.node, (a) => ({
|
|
132
|
+
...a,
|
|
133
|
+
...S
|
|
134
|
+
}))
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
onAdd: (S) => j(a.node, S),
|
|
138
|
+
onRemove: () => M(a.node)
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}), createComponent(Match, {
|
|
142
|
+
get when() {
|
|
143
|
+
return isGroupNode(a.node);
|
|
144
|
+
},
|
|
145
|
+
get children() {
|
|
146
|
+
var w = _tmpl$4(), D = w.firstChild;
|
|
147
|
+
return insert(D, createComponent(GroupNode, {
|
|
148
|
+
class: "absolute left--0 top-1/2 translate-y--1/2 translate-x--1/2 z-1",
|
|
149
|
+
get node() {
|
|
150
|
+
return a.node;
|
|
151
|
+
},
|
|
152
|
+
get content() {
|
|
153
|
+
return (() => {
|
|
154
|
+
var S = _tmpl$5();
|
|
155
|
+
return S.$$input = (S) => A(a.node, (a) => ({
|
|
156
|
+
...a,
|
|
157
|
+
op: S.target.value
|
|
158
|
+
})), effect(() => S.value = a.node.op ?? "and"), S;
|
|
159
|
+
})();
|
|
160
|
+
},
|
|
161
|
+
onAdd: (S) => j(a.node, S),
|
|
162
|
+
onRemove: () => M(a.node)
|
|
163
|
+
})), insert(w, createComponent(Show, {
|
|
164
|
+
get when() {
|
|
165
|
+
return a.node.children?.length;
|
|
166
|
+
},
|
|
167
|
+
get children() {
|
|
168
|
+
var S = _tmpl$3();
|
|
169
|
+
return insert(S, createComponent(For, {
|
|
170
|
+
get each() {
|
|
171
|
+
return a.node.children;
|
|
172
|
+
},
|
|
173
|
+
children: (a) => createComponent(N, { node: a })
|
|
174
|
+
})), S;
|
|
175
|
+
}
|
|
176
|
+
}), null), effect(() => className(D, `relative b-r-0 w-10 rd-l-4 ${a.node.op === "or" ? "b-1 b-dashed b-#f59e0b" : "b-1 b-dashed b-#4f7ff0"}`)), w;
|
|
177
|
+
}
|
|
178
|
+
})];
|
|
179
|
+
} });
|
|
180
|
+
return (() => {
|
|
181
|
+
var a = _tmpl$2();
|
|
182
|
+
return insert(a, createComponent(N, { get node() {
|
|
183
|
+
return D.tree;
|
|
184
|
+
} })), effect(() => className(a, `and-or-builder ${w.class ?? ""}`)), a;
|
|
185
|
+
})();
|
|
186
|
+
};
|
|
187
|
+
delegateEvents(["click", "input"]);
|
|
188
|
+
export { AndOr };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AndOrNode, RuleNode } from './AndOr';
|
|
2
|
+
export type RuleOp = 'contains' | 'eq' | 'neq' | 'startwith' | 'endwith' | 'blank' | 'noblank' | 'lt' | 'gt' | 'lte' | 'gte' | 'true' | 'false';
|
|
3
|
+
export type Field = {
|
|
4
|
+
id: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
enum?: Record<string, any> | {
|
|
8
|
+
label?: string;
|
|
9
|
+
value: any;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
type Props = {
|
|
13
|
+
fields: Field[];
|
|
14
|
+
value?: AndOrNode;
|
|
15
|
+
onChange?: (value: AndOrNode) => void;
|
|
16
|
+
class?: any;
|
|
17
|
+
hideFields?: boolean;
|
|
18
|
+
newRule?: (current: RuleNode) => RuleNode;
|
|
19
|
+
};
|
|
20
|
+
export declare function isValueFreeOp(op?: string): boolean;
|
|
21
|
+
export declare const RULES_BY_TYPE: Record<string, Array<{
|
|
22
|
+
label: string;
|
|
23
|
+
value: RuleOp;
|
|
24
|
+
}>>;
|
|
25
|
+
type RuleValueEditorProps = {
|
|
26
|
+
field?: Field;
|
|
27
|
+
op?: string;
|
|
28
|
+
value: any;
|
|
29
|
+
enum?: Field['enum'];
|
|
30
|
+
class?: string;
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
onChange: (value: any) => void;
|
|
33
|
+
};
|
|
34
|
+
export declare const RuleValueEditor: (props: RuleValueEditorProps) => import("solid-js").JSX.Element;
|
|
35
|
+
export declare function normalizeType(field?: Field): string;
|
|
36
|
+
export declare function newRule(field: Field, current?: Partial<RuleNode>): RuleNode;
|
|
37
|
+
export declare const AndOrFields: (props: Props) => import("solid-js").JSX.Element;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { resolveOptions } from "../utils.js";
|
|
2
|
+
import { AndOr } from "./AndOr.js";
|
|
3
|
+
import { className, createComponent, delegateEvents, effect, insert, mergeProps, setAttribute, template } from "solid-js/web";
|
|
4
|
+
import { Match, Switch, createMemo } from "solid-js";
|
|
5
|
+
var _tmpl$ = /* @__PURE__ */ template("<input type=number>"), _tmpl$2 = /* @__PURE__ */ template("<input type=date>"), _tmpl$3 = /* @__PURE__ */ template("<select><option value>"), _tmpl$4 = /* @__PURE__ */ template("<input>"), _tmpl$5 = /* @__PURE__ */ template("<option>"), _tmpl$6 = /* @__PURE__ */ template("<div class=\"flex items-center gap-2\"><select><option value disabled>选择字段</option></select><select class=\"px-2 py-1 rounded-md border\">"), VALUE_FREE_RULES = ["blank", "noblank"];
|
|
6
|
+
function isValueFreeOp(e) {
|
|
7
|
+
return VALUE_FREE_RULES.includes(e);
|
|
8
|
+
}
|
|
9
|
+
const RULES_BY_TYPE = {
|
|
10
|
+
text: [
|
|
11
|
+
{
|
|
12
|
+
label: "包含",
|
|
13
|
+
value: "contains"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: "等于",
|
|
17
|
+
value: "eq"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: "不等于",
|
|
21
|
+
value: "neq"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: "开头是",
|
|
25
|
+
value: "startwith"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: "结尾是",
|
|
29
|
+
value: "endwith"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: "为空",
|
|
33
|
+
value: "blank"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: "不为空",
|
|
37
|
+
value: "noblank"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
number: [
|
|
41
|
+
{
|
|
42
|
+
label: "等于",
|
|
43
|
+
value: "eq"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: "不等于",
|
|
47
|
+
value: "neq"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: "小于",
|
|
51
|
+
value: "lt"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: "大于",
|
|
55
|
+
value: "gt"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: "小于等于",
|
|
59
|
+
value: "lte"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: "大于等于",
|
|
63
|
+
value: "gte"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
label: "为空",
|
|
67
|
+
value: "blank"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: "不为空",
|
|
71
|
+
value: "noblank"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
date: [
|
|
75
|
+
{
|
|
76
|
+
label: "等于",
|
|
77
|
+
value: "eq"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
label: "不等于",
|
|
81
|
+
value: "neq"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
label: "早于",
|
|
85
|
+
value: "lt"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: "晚于",
|
|
89
|
+
value: "gt"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
label: "不晚于",
|
|
93
|
+
value: "lte"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
label: "不早于",
|
|
97
|
+
value: "gte"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
label: "为空",
|
|
101
|
+
value: "blank"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
label: "不为空",
|
|
105
|
+
value: "noblank"
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
enum: [
|
|
109
|
+
{
|
|
110
|
+
label: "等于",
|
|
111
|
+
value: "eq"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: "不等于",
|
|
115
|
+
value: "neq"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
label: "为空",
|
|
119
|
+
value: "blank"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
label: "不为空",
|
|
123
|
+
value: "noblank"
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
checkbox: [
|
|
127
|
+
{
|
|
128
|
+
label: "等于",
|
|
129
|
+
value: "eq"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
label: "不等于",
|
|
133
|
+
value: "neq"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
label: "为空",
|
|
137
|
+
value: "blank"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
label: "不为空",
|
|
141
|
+
value: "noblank"
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}, RuleValueEditor = (_) => {
|
|
145
|
+
let b = () => normalizeType(_.field), S = () => resolveOptions(_.enum ?? []);
|
|
146
|
+
return createComponent(Switch, {
|
|
147
|
+
get fallback() {
|
|
148
|
+
return (() => {
|
|
149
|
+
var e = _tmpl$4();
|
|
150
|
+
return e.$$input = (e) => _.onChange(e.target.value), effect((y) => {
|
|
151
|
+
var b = _.class ?? "flex-1 px-2 py-1 rounded-md border", x = _.placeholder;
|
|
152
|
+
return b !== y.e && className(e, y.e = b), x !== y.t && setAttribute(e, "placeholder", y.t = x), y;
|
|
153
|
+
}, {
|
|
154
|
+
e: void 0,
|
|
155
|
+
t: void 0
|
|
156
|
+
}), effect(() => e.value = _.value ?? ""), e;
|
|
157
|
+
})();
|
|
158
|
+
},
|
|
159
|
+
get children() {
|
|
160
|
+
return [
|
|
161
|
+
createComponent(Match, {
|
|
162
|
+
get when() {
|
|
163
|
+
return isValueFreeOp(_.op || defaultOp(b()));
|
|
164
|
+
},
|
|
165
|
+
get children() {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
}),
|
|
169
|
+
createComponent(Match, {
|
|
170
|
+
get when() {
|
|
171
|
+
return b() === "number";
|
|
172
|
+
},
|
|
173
|
+
get children() {
|
|
174
|
+
var e = _tmpl$();
|
|
175
|
+
return e.$$input = (e) => _.onChange(e.target.value), effect((y) => {
|
|
176
|
+
var b = _.class ?? "flex-1 px-2 py-1 rounded-md border", x = _.placeholder;
|
|
177
|
+
return b !== y.e && className(e, y.e = b), x !== y.t && setAttribute(e, "placeholder", y.t = x), y;
|
|
178
|
+
}, {
|
|
179
|
+
e: void 0,
|
|
180
|
+
t: void 0
|
|
181
|
+
}), effect(() => e.value = _.value ?? ""), e;
|
|
182
|
+
}
|
|
183
|
+
}),
|
|
184
|
+
createComponent(Match, {
|
|
185
|
+
get when() {
|
|
186
|
+
return b() === "date";
|
|
187
|
+
},
|
|
188
|
+
get children() {
|
|
189
|
+
var e = _tmpl$2();
|
|
190
|
+
return e.$$input = (e) => _.onChange(e.target.value), effect(() => className(e, _.class ?? "flex-1 px-2 py-1 rounded-md border")), effect(() => e.value = _.value ?? ""), e;
|
|
191
|
+
}
|
|
192
|
+
}),
|
|
193
|
+
createComponent(Match, {
|
|
194
|
+
get when() {
|
|
195
|
+
return b() === "enum";
|
|
196
|
+
},
|
|
197
|
+
get children() {
|
|
198
|
+
var e = _tmpl$3();
|
|
199
|
+
return e.firstChild, e.$$input = (e) => _.onChange(e.target.value), insert(e, () => S().map((e) => (() => {
|
|
200
|
+
var _ = _tmpl$5();
|
|
201
|
+
return insert(_, () => String(e.label)), effect(() => _.value = String(e.value)), _;
|
|
202
|
+
})()), null), effect(() => className(e, _.class ?? "flex-1 px-2 py-1 rounded-md border")), effect(() => e.value = _.value ?? ""), e;
|
|
203
|
+
}
|
|
204
|
+
}),
|
|
205
|
+
createComponent(Match, {
|
|
206
|
+
get when() {
|
|
207
|
+
return [
|
|
208
|
+
"checkbox",
|
|
209
|
+
"switch",
|
|
210
|
+
"boolean"
|
|
211
|
+
].includes(b());
|
|
212
|
+
},
|
|
213
|
+
get children() {
|
|
214
|
+
var e = _tmpl$3();
|
|
215
|
+
return e.firstChild, e.$$input = (e) => _.onChange(e.target.value), insert(e, () => [!0, !1].map((e) => (() => {
|
|
216
|
+
var _ = _tmpl$5();
|
|
217
|
+
return insert(_, () => String(e)), effect(() => _.value = String(e)), _;
|
|
218
|
+
})()), null), effect(() => className(e, _.class ?? "flex-1 px-2 py-1 rounded-md border")), effect(() => e.value = _.value ?? ""), e;
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
function normalizeType(e) {
|
|
226
|
+
return e?.enum ? "enum" : e?.type ?? "text";
|
|
227
|
+
}
|
|
228
|
+
function defaultOp(e) {
|
|
229
|
+
return RULES_BY_TYPE[e]?.[0]?.value;
|
|
230
|
+
}
|
|
231
|
+
function newRule(e, _) {
|
|
232
|
+
let v = normalizeType(e), y = defaultOp(v);
|
|
233
|
+
return {
|
|
234
|
+
field: e.id,
|
|
235
|
+
op: y,
|
|
236
|
+
value: VALUE_FREE_RULES.includes(y) ? null : "",
|
|
237
|
+
..._
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
const AndOrFields = (e) => createComponent(AndOr, mergeProps(e, { renderRule: (_) => {
|
|
241
|
+
let b = createMemo(() => e.fields.find((e) => e.id === _.node.field)), S = createMemo(() => normalizeType(b())), C = createMemo(() => RULES_BY_TYPE[S()]);
|
|
242
|
+
return (() => {
|
|
243
|
+
var w = _tmpl$6(), T = w.firstChild;
|
|
244
|
+
T.firstChild;
|
|
245
|
+
var E = T.nextSibling;
|
|
246
|
+
return T.$$input = (v) => {
|
|
247
|
+
let y = v.target.value, b = e.fields.find((e) => e.id === y);
|
|
248
|
+
_.update(newRule(b, { field: y }));
|
|
249
|
+
}, insert(T, () => e.fields.map((e) => (() => {
|
|
250
|
+
var _ = _tmpl$5();
|
|
251
|
+
return insert(_, () => e.name), effect(() => _.value = e.id), _;
|
|
252
|
+
})()), null), E.$$input = (e) => {
|
|
253
|
+
let v = e.target.value;
|
|
254
|
+
_.update({
|
|
255
|
+
op: v,
|
|
256
|
+
value: VALUE_FREE_RULES.includes(v) ? null : _.node.value ?? ""
|
|
257
|
+
});
|
|
258
|
+
}, insert(E, () => C().map((e) => (() => {
|
|
259
|
+
var _ = _tmpl$5();
|
|
260
|
+
return insert(_, () => e.label), effect(() => _.value = e.value), _;
|
|
261
|
+
})())), insert(w, createComponent(RuleValueEditor, {
|
|
262
|
+
get field() {
|
|
263
|
+
return b();
|
|
264
|
+
},
|
|
265
|
+
get op() {
|
|
266
|
+
return _.node.op;
|
|
267
|
+
},
|
|
268
|
+
get value() {
|
|
269
|
+
return _.node.value;
|
|
270
|
+
},
|
|
271
|
+
get enum() {
|
|
272
|
+
return b()?.enum;
|
|
273
|
+
},
|
|
274
|
+
class: "flex-1 px-2 py-1 rounded-md border",
|
|
275
|
+
onChange: (e) => _.update({ value: e })
|
|
276
|
+
}), null), effect(() => className(T, `px-2 py-1 rounded-md border ${e.hideFields ? "hidden" : ""}`)), effect(() => T.value = _.node.field), effect(() => E.value = _.node.op || defaultOp(S())), w;
|
|
277
|
+
})();
|
|
278
|
+
} }));
|
|
279
|
+
delegateEvents(["input"]);
|
|
280
|
+
export { AndOrFields, RULES_BY_TYPE, RuleValueEditor, isValueFreeOp, newRule, normalizeType };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Field } from './AndOrFields';
|
|
2
|
+
import type { AndOrNode } from './AndOr';
|
|
3
|
+
export type FilterRule = 'contains' | 'eq' | 'neq' | 'startwith' | 'endwith' | 'blank' | 'noblank' | 'lt' | 'gt' | 'lte' | 'gte' | 'true' | 'false';
|
|
4
|
+
type FilterProps = {
|
|
5
|
+
col: Field;
|
|
6
|
+
tree: AndOrNode | undefined;
|
|
7
|
+
setTree: (tree?: AndOrNode) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const Filter: (props: FilterProps) => import("solid-js").JSX.Element;
|
|
10
|
+
export {};
|