@formkit/pro 1.0.0-alpha.9 → 1.0.0-alpha.90
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/LICENSE.md +2 -2
- package/README.md +3 -0
- package/autocomplete/autocomplete.ts +11 -4
- package/autocomplete/index.mjs +1 -1
- package/datepicker/datepicker.ts +115 -0
- package/datepicker/index.mjs +1 -0
- package/dropdown/dropdown.ts +4 -2
- package/dropdown/index.mjs +1 -1
- package/genesis.css +1 -1
- package/index.cjs +1 -1
- package/index.d.ts +29 -1
- package/index.mjs +1 -1
- package/mask/index.mjs +1 -0
- package/mask/mask.ts +61 -0
- package/package.json +2 -2
- package/rating/index.mjs +1 -1
- package/rating/rating.ts +11 -1
- package/repeater/index.mjs +1 -1
- package/repeater/repeater.ts +23 -14
- package/taglist/index.mjs +1 -0
- package/taglist/taglist.ts +102 -0
- package/toggle/index.mjs +1 -1
- package/toggle/toggle.ts +1 -0
- package/transferList/index.mjs +1 -0
- package/transferList/transferList.ts +191 -0
package/rating/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSectionFactory as e,createBaseSections as t,$if as o}from"../index.mjs";const r=e("rt"),{outer:i,wrapper:l,inner:s,label:a,prefix:n,suffix:d,help:p,
|
|
1
|
+
import{createSectionFactory as e,createBaseSections as t,$if as o}from"../index.mjs";const r=e("rt"),{outer:i,wrapper:l,inner:s,label:a,prefix:n,suffix:d,help:$,messages:p,message:f,icon:h}=t(r),m=r("input",(()=>({$el:"input",attrs:{id:"$id",type:"range",max:"$max",name:"$name",min:"0",disabled:"$disabled",step:"$step",onInput:"$handlers.DOMInput",onBlur:"$handlers.blur",value:"$_value",style:{position:"absolute",zIndex:"0",top:0,right:0,bottom:0,opacity:"0"}}}))),v=r("itemsWrapper",(()=>({$el:"div",attrs:{style:{position:"relative",zIndex:"2"},id:"$id + _items_wrapper",onMousemove:"$hoverHighlight && $handlers.ratingHoverOver",onMouseleave:"$hoverHighlight && $handlers.ratingHoverOut",onTouchstart:"$handlers.ratingHoverOver",onTouchmove:"$handlers.ratingHoverOver",onTouchend:"$handlers.handleClick",onClick:"$handlers.handleClick"}}))),u=r("onItems",(()=>({$el:"div",attrs:{id:'$id + "_on_wrapper"',style:{position:"relative",display:"flex",width:'$onWidth + "%"',top:"0",bottom:"0",left:"0",overflow:"hidden",color:"$onColor"}}}))),x=r("offItems",(()=>({$el:"div",attrs:{id:'$id + "_off_wrapper"',style:{position:"absolute",display:"flex",flexDirection:"row-reverse",width:'$offWidth + "%"',top:"0",bottom:"0",right:"0",overflow:"hidden",color:"$offColor"}}}))),g=r("onItemWrapper",(()=>({$el:"div",for:["item","index","$max"],attrs:{style:{flex:"$wrapperWidth"}}}))),c=r("offItemWrapper",(()=>({$el:"div",for:["item","index","$max"],attrs:{style:{flex:"$wrapperWidth"}}}))),I=()=>g(o("$slots.onItem",(()=>()=>"$slots.onItem"),o("$slots.default",(()=>()=>"$slots.default"),h("rating")))),w=()=>c(o("$slots.offItem",(()=>()=>"$slots.offItem"),o("$slots.default",(()=>()=>"$slots.default"),h("rating"))));export{r as createSection,$ as help,h as icon,s as inner,m as input,v as itemsWrapper,a as label,f as message,p as messages,w as offItem,x as offItems,I as onItem,u as onItems,i as outer,n as prefix,d as suffix,l as wrapper};
|
package/rating/rating.ts
CHANGED
|
@@ -15,6 +15,9 @@ import {
|
|
|
15
15
|
help,
|
|
16
16
|
messages,
|
|
17
17
|
message,
|
|
18
|
+
icon,
|
|
19
|
+
prefix,
|
|
20
|
+
suffix,
|
|
18
21
|
} from '../sections/ratingSections'
|
|
19
22
|
|
|
20
23
|
/**
|
|
@@ -28,7 +31,14 @@ export const rating: FormKitProInput = {
|
|
|
28
31
|
schema: outer(
|
|
29
32
|
wrapper(
|
|
30
33
|
label('$label'),
|
|
31
|
-
inner(
|
|
34
|
+
inner(
|
|
35
|
+
icon('prefix'),
|
|
36
|
+
prefix(),
|
|
37
|
+
itemsWrapper(onItems(onItem()), offItems(offItem())),
|
|
38
|
+
input(),
|
|
39
|
+
suffix(),
|
|
40
|
+
icon('suffix')
|
|
41
|
+
)
|
|
32
42
|
),
|
|
33
43
|
help('$help'),
|
|
34
44
|
messages(message('$message'))
|
package/repeater/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSectionFactory as e,createBaseSections as t}from"../index.mjs";const o=e("rp"),{outer:i,inner:
|
|
1
|
+
import{createSectionFactory as e,createBaseSections as t}from"../index.mjs";const o=e("rp"),{outer:i,inner:n,prefix:l,suffix:$,help:r,messages:d,message:s,icon:a}=t(o),m=o("insertControl",(()=>({$el:"button",attrs:{disabled:"$value.length >= $max",onClick:"$fns.createInsert($item.__key)",type:"button"}}))),u=o("addButton",(()=>({$formkit:"button",bind:"$addAttrs",if:"$addButton",disabled:"$value.length >= $max",onClick:"$fns.createAppend()",type:"button"}))),f=o("removeControl",(()=>({$el:"button",attrs:{disabled:"$value.length <= $min",onClick:"$fns.createRemover($item.__key)",type:"button"}}))),b=o("items",(()=>({$el:"ul",attrs:{role:"list"}}))),p=o("item",(()=>({$el:"li",for:["item","index","$value"],if:"$item.__key",attrs:{role:"listitem",key:"$item.__key","data-index":"$item.__index"}}))),_=o("downControl",(()=>({$el:"button",attrs:{disabled:"$index >= $value.length - 1",onClick:"$fns.createShift($item.__key, 1)",type:"button"}}))),C=o("upControl",(()=>({$el:"button",attrs:{disabled:"$index <= 0",onClick:"$fns.createShift($item.__key, -1)",type:"button"}}))),c=o("content","div"),k=o("fieldset",(()=>({$el:"fieldset",attrs:{id:"$id",disabled:"$disabled"}}))),y=o("legend",(()=>({$el:"legend",if:"$label"}))),x=o("group",(()=>({$formkit:"group",id:"$item.__key",index:"$item.__index"}))),v=o("controls",(()=>({$el:"ul",if:"$removeControl || $insertControl || $upControl || $downControl"}))),g=o("remove",(()=>({$el:"li",if:"$removeControl"}))),h=o("insert",(()=>({$el:"li",if:"$insertControl"}))),w=o("up",(()=>({$el:"li",if:"$upControl"}))),A=o("down",(()=>({$el:"li",if:"$downControl"}))),B=o("controlLabel","span");export{u as addButton,c as content,B as controlLabel,v as controls,o as createSection,A as down,_ as downControl,k as fieldset,x as group,r as help,a as icon,n as inner,h as insert,m as insertControl,p as item,b as items,y as legend,s as message,d as messages,i as outer,l as prefix,g as remove,f as removeControl,$ as suffix,w as up,C as upControl};
|
package/repeater/repeater.ts
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
} from '../sections/repeaterSections'
|
|
29
29
|
import repeats from '../features/repeats'
|
|
30
30
|
import { localize, defaultIcon } from '@formkit/inputs'
|
|
31
|
+
import { $if } from '../compose'
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* Input definition for a repeater input.
|
|
@@ -43,19 +44,27 @@ export const repeater: FormKitProInput = {
|
|
|
43
44
|
help('$help'),
|
|
44
45
|
inner(
|
|
45
46
|
prefix(),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
$if(
|
|
48
|
+
'$slots.default',
|
|
49
|
+
items(
|
|
50
|
+
item(
|
|
51
|
+
content(group('$slots.default')),
|
|
52
|
+
controls(
|
|
53
|
+
up(upControl(controlLabel('$ui.moveUp.value'), icon('moveUp'))),
|
|
54
|
+
remove(
|
|
55
|
+
removeControl(
|
|
56
|
+
controlLabel('$ui.remove.value'),
|
|
57
|
+
icon('remove')
|
|
58
|
+
)
|
|
59
|
+
),
|
|
60
|
+
insert(
|
|
61
|
+
insertControl(controlLabel('$ui.add.value'), icon('add'))
|
|
62
|
+
),
|
|
63
|
+
down(
|
|
64
|
+
downControl(
|
|
65
|
+
controlLabel('$ui.moveDown.value'),
|
|
66
|
+
icon('moveDown')
|
|
67
|
+
)
|
|
59
68
|
)
|
|
60
69
|
)
|
|
61
70
|
)
|
|
@@ -63,7 +72,7 @@ export const repeater: FormKitProInput = {
|
|
|
63
72
|
),
|
|
64
73
|
suffix()
|
|
65
74
|
),
|
|
66
|
-
addButton('$addLabel || ($ui.add.value + " " + $label)')
|
|
75
|
+
addButton('$addLabel || ($ui.add.value + " " + ($label || ""))')
|
|
67
76
|
),
|
|
68
77
|
messages(message('$message.value'))
|
|
69
78
|
),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$if as e,createSectionFactory as t,createBaseSections as a}from"../index.mjs";import{icon as i}from"@formkit/inputs";const o=(e,t)=>()=>i(e,t),n=t("tl"),{outer:d,wrapper:l,inner:s,icon:r,label:$,prefix:p,suffix:c,help:u,messages:b,message:x}=a(n),v=n("input",(()=>({$el:"input",bind:"$attrs",attrs:{id:"$id",type:"text",onClick:"$handlers.click",onBlur:"$handlers.blur",onKeydown:"$handlers.keydown",onInput:"$handlers.input",onFocus:"$handlers.focus",value:"$inputText",tabindex:"0",placeholder:"$isLoadingOption && $ui.isLoading.value || $placeholder || undefined",role:"combobox",autocomplete:"off",autocapitalize:"none",readonly:"$attrs.readonly || $isLoadingOption || undefined || $multiple && $max && $value && $value.length >= $max",disabled:"$disabled || undefined",onTouchmove:"$handlers.touchmove",onTouchstart:"$handlers.touchmove",onTouchend:"$handlers.touchend","aria-autocomplete":"list","aria-expanded":"$expanded","aria-controls":'$expanded && $id + "_listbox" || undefined',"aria-describedBy":"$describedBy","aria-activedescendant":"$expanded && $activeDescendant || undefined"}}))),f=n("listboxButton",(()=>({$el:"button",attrs:{style:"$visibilityStyles",id:'$id + "_listbox_button"',type:"button",onClick:"$handlers.toggleListbox",tabindex:"-1",disabled:"$disabled || undefined","aria-haspopup":"true","aria-expanded":"$expanded","aria-controls":'$expanded && $id + "_listbox" || undefined'}}))),m=n("tagWrapper",(()=>({$el:"span",for:["option","index","$selections"],attrs:{id:'$id + "_tag-wrapper_" + $index',key:"$option.value","data-value":"$option.value",tabindex:"-1",onClick:"$handlers.selectTag($option)"}}))),g=n("tag",(()=>({$el:"div",attrs:{id:'$id + "_tag_" + $index',role:"button"}}))),h=n("removeSelection",(()=>({$el:"button",if:"$_value !== undefined",attrs:{id:'$id + "_remove_selection_" + $index',tabindex:"-1",type:"button",onClick:"$disabled !== true && $handlers.removeSelection($option)","aria-controls":"$id"}}))),y=n("tagLabel",(()=>({$el:"span"}))),_=n("tags",(()=>({$el:"div",attrs:{id:'$id + "_selections"',"aria-live":"polite",onKeydown:"$handlers.keydown"}}))),k=n("tagLoading","span"),w=function(t){const a=t("dropdownWrapper",(()=>({$el:"div",attrs:{id:'$id + "_dropdown_wrapper"',"data-is-wrapper":!0,style:"$dropdownWrapperStyles",onScroll:"$handlers.scroll"}}))),i=t("listbox",(()=>({$el:"ul",if:"$expanded || $forceExpanded",attrs:{style:"$listboxStyles",id:'$id + "_listbox"',role:"listbox","aria-activedescendant":"$activeDescendant"}}))),n=t("listitem",(()=>({$el:"li",for:["option","index","$options"],bind:"$option.attrs",attrs:{id:'$id + "_listitem_" + $index',"data-disabled":"$option.attrs.disabled","data-value":"$option.value",key:"$option.value",onClick:"$handlers.selectOption($option)",role:"option","aria-selected":"$fns.isSelected($option)","data-is-active":"$fns.isActive($option)"}}))),d=t("loadMore",(()=>({$el:"li",if:"$state.loading || $state.hasNextPage",attrs:{id:'$id + "_load_more"',key:"loadMore",role:"option",onClick:"$handlers.loadMoreSelected","aria-selected":"false","data-is-active":"$fns.isActive($loadMoreOption)"}}))),l=t("loadMoreInner","span"),s=t("emptyMessage",(()=>({$el:"li",if:"$showEmptyMessage && $state.loading !== true",attrs:{id:'$id + "_empty_message"',key:"$emptyMessage",role:"presentation"}}))),r=t("emptyMessageInner","span"),$=t("option",(()=>({$el:"div",attrs:{"data-checked":"$fns.isSelected($option)"}})));return()=>a(i(s(r("$emptyMessage")),n(e("$fns.isSelected($option)",o("selected")),$("$option.label")),d(l(e("$state.loading",o("loader")),"$state.loading && $ui.isLoading.value || $ui.loadMore.value"))))}(n);export{n as createSection,u as help,r as icon,s as inner,v as input,$ as label,w as listbox,f as listboxButton,x as message,b as messages,d as outer,p as prefix,h as removeSelection,c as suffix,g as tag,y as tagLabel,k as tagLoading,m as tagWrapper,_ as tags,l as wrapper};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { default as dropdownFeature } from '../features/dropdown'
|
|
2
|
+
import { default as autocompleteFeature } from '../features/autocompletes'
|
|
3
|
+
import { default as taglistFeature } from '../features/taglist'
|
|
4
|
+
import {
|
|
5
|
+
dropdownKeyHandler,
|
|
6
|
+
dropdownDisplayHandler,
|
|
7
|
+
setSelectedOption,
|
|
8
|
+
} from '../features/dropdownFeatures'
|
|
9
|
+
import { getSelections } from '../features/taglistFeatures'
|
|
10
|
+
import { options, defaultIcon, localize } from '@formkit/inputs'
|
|
11
|
+
import { FormKitProInput } from '@formkit/pro'
|
|
12
|
+
import {
|
|
13
|
+
outer,
|
|
14
|
+
wrapper,
|
|
15
|
+
inner,
|
|
16
|
+
label,
|
|
17
|
+
prefix,
|
|
18
|
+
tag,
|
|
19
|
+
tagWrapper,
|
|
20
|
+
tagLoading,
|
|
21
|
+
suffix,
|
|
22
|
+
help,
|
|
23
|
+
messages,
|
|
24
|
+
message,
|
|
25
|
+
listbox,
|
|
26
|
+
icon,
|
|
27
|
+
input,
|
|
28
|
+
listboxButton,
|
|
29
|
+
tags,
|
|
30
|
+
tagLabel,
|
|
31
|
+
removeSelection,
|
|
32
|
+
} from '../sections/taglistSections'
|
|
33
|
+
import { $if } from '../compose'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Input definition for a taglist input.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export const taglist: FormKitProInput = {
|
|
40
|
+
/**
|
|
41
|
+
* The actual schema of the input, or a function that returns the schema.
|
|
42
|
+
*/
|
|
43
|
+
schema: outer(
|
|
44
|
+
wrapper(
|
|
45
|
+
label('$label'),
|
|
46
|
+
inner(
|
|
47
|
+
icon('prefix'),
|
|
48
|
+
prefix(),
|
|
49
|
+
tags(
|
|
50
|
+
tagWrapper(
|
|
51
|
+
tag(
|
|
52
|
+
$if(
|
|
53
|
+
'$state.loading',
|
|
54
|
+
tagLoading('$ui.isLoading.value'),
|
|
55
|
+
tagLabel('$option.label')
|
|
56
|
+
),
|
|
57
|
+
removeSelection(icon('close'))
|
|
58
|
+
)
|
|
59
|
+
),
|
|
60
|
+
input()
|
|
61
|
+
),
|
|
62
|
+
$if('$state.loading', icon('loader')),
|
|
63
|
+
listboxButton(icon('select')),
|
|
64
|
+
listbox(),
|
|
65
|
+
suffix(),
|
|
66
|
+
icon('suffix')
|
|
67
|
+
)
|
|
68
|
+
),
|
|
69
|
+
help('$help'),
|
|
70
|
+
messages(message('$message.value'))
|
|
71
|
+
),
|
|
72
|
+
/**
|
|
73
|
+
* The type of node, can be a list, group, or input.
|
|
74
|
+
*/
|
|
75
|
+
type: 'input',
|
|
76
|
+
/**
|
|
77
|
+
* In the dropdown family of inputs.
|
|
78
|
+
*/
|
|
79
|
+
family: 'dropdown',
|
|
80
|
+
/**
|
|
81
|
+
* An array of extra props to accept for this input.
|
|
82
|
+
*/
|
|
83
|
+
props: [],
|
|
84
|
+
/**
|
|
85
|
+
* Additional features that make this input work.
|
|
86
|
+
*/
|
|
87
|
+
features: [
|
|
88
|
+
options,
|
|
89
|
+
taglistFeature,
|
|
90
|
+
dropdownFeature(
|
|
91
|
+
dropdownKeyHandler,
|
|
92
|
+
dropdownDisplayHandler(getSelections, setSelectedOption)
|
|
93
|
+
),
|
|
94
|
+
autocompleteFeature(getSelections),
|
|
95
|
+
defaultIcon('select', 'select'),
|
|
96
|
+
defaultIcon('close', 'close'),
|
|
97
|
+
defaultIcon('selected', 'check'),
|
|
98
|
+
defaultIcon('loader', 'spinner'),
|
|
99
|
+
localize('isLoading'),
|
|
100
|
+
localize('loadMore'),
|
|
101
|
+
],
|
|
102
|
+
}
|
package/toggle/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSectionFactory as e,createBaseSections as l,$if as a}from"../index.mjs";const o=e("tg"),{outer:$,wrapper:t,label:i,prefix:n,suffix:r,help:
|
|
1
|
+
import{createSectionFactory as e,createBaseSections as l,$if as a}from"../index.mjs";const o=e("tg"),{outer:$,wrapper:t,label:i,prefix:n,suffix:r,help:b,messages:f,message:u,icon:d}=l(o),s=o("input",(()=>({$el:"input",bind:"$attrs",attrs:{type:"checkbox",id:"$id",value:"$_value",checked:"$checked",onInput:"$handlers.toggles",onBlur:"$handlers.blur",disabled:"$disabled"}}))),c=o("label",(()=>({if:"($label && $onValueLabel === undefined && $offValueLabel === undefined) || ($valueLabelDisplay === inner) && $altLabelPosition !== true",$el:"label",attrs:{for:"$id"},children:"$label"}))),h=o("altLabel",(()=>({$el:"label",if:"($label && ($onValueLabel || $offValueLabel) && $valueLabelDisplay !== hidden && $valueLabelDisplay !== inner) || $altLabelPosition === true",attrs:{for:"$id","data-label-alt":"true",style:{color:{if:"$checked",then:"$valueLabelColorOn",else:"$valueLabelColorOff"}}},children:"$label"}))),L=o("innerLabel",(()=>({$el:"div",if:"$valueLabelDisplay === inner && ($checked && $onValueLabel || $offValueLabel)",attrs:{style:{color:{if:"$checked",then:"$valueLabelColorOn",else:"$valueLabelColorOff"}}},children:{if:"$checked",then:"$onValueLabel",else:"$offValueLabel"}}))),k=o("valueLabel",(()=>({$el:"label",if:"$valueLabelDisplay !== hidden && $valueLabelDisplay !== inner && (($checked === true && $onValueLabel) || ($checked === false && $offValueLabel))",attrs:{for:"$id"},children:{if:"$checked && $onValueLabel",then:"$onValueLabel",else:{if:"$offValueLabel",then:"$offValueLabel"}}}))),p=o("inner",(()=>({$el:"label",attrs:{for:"$id",id:"$id + '_label'"}}))),v=o("track",(()=>({$el:"div",attrs:{style:{backgroundColor:{if:"$checked",then:"$trackColorOn",else:"$trackColorOff"}}}}))),V=o("thumb",(()=>({$el:"div",attrs:{style:{color:{if:"$checked",then:"$iconColorOn",else:"$iconColorOff"},backgroundColor:{if:"$checked",then:"$thumbColorOn",else:"$thumbColorOff"}}}}))),C=()=>V(a("$slots.default","$slots.default",d("thumb")));export{h as altLabel,o as createSection,c as defaultLabel,b as help,d as icon,p as inner,L as innerLabel,s as input,i as label,u as message,f as messages,$ as outer,n as prefix,r as suffix,C as thumbWrapper,v as track,k as valueLabel,t as wrapper};
|
package/toggle/toggle.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSectionFactory as e,createBaseSections as s}from"../index.mjs";const t=e("tf"),{outer:a,wrapper:r,inner:l,icon:i,prefix:o,suffix:n,help:d,messages:$,message:c}=s(t),u=t("fieldset",(()=>({$el:"fieldset",attrs:{id:'$id + "_fieldset"',role:"presentation","aria-describedby":{if:"$help",then:'$: "help-" + $id',else:void 0}}}))),f=t("legend",(()=>({if:"$label",$el:"legend"}))),p=t("area",(()=>({$el:"div",attrs:{id:'$id + "_area"'}}))),g=t("source",(()=>({$el:"div",attrs:{id:'$id + "_source"',class:'$classes.transferlist + " " + $classes.source'}}))),_=t("sourceHeader",(()=>({$el:"div",attrs:{id:'$id + "_source_header"',role:"presentation",class:'$classes.transferlistHeader + " " + $classes.sourceHeader'}}))),b=t("sourceHeaderLabel",(()=>({if:"$sourceLabel",$el:"label",attrs:{id:'$id + "_source_header_label"',for:'$id + "_source_search_input"',class:'$classes.transferlistHeaderLabel + " " + $classes.sourceHeaderLabel'},children:"$sourceLabel || $label"}))),h=t("sourceHeaderItemCount",(()=>({$el:"span",attrs:{id:'$id + "_source_header_item_count"',role:"presentation","aria-label":'$fns.getOptionCount() + " items"',class:'$classes.transferlistHeaderItemCount + " " + $classes.sourceHeaderItemCount'},children:"$fns.getOptionCount()"}))),m=t("targetHeaderLabel",(()=>({if:"$targetLabel",$el:"label",attrs:{id:'$id + "_target_header_label"',for:'$id + "_target_search_input"',class:'$classes.transferlistHeaderLabel + " " + $classes.targetHeaderLabel'},children:"$targetLabel || $label"}))),v=t("targetHeaderItemCount",(()=>({$el:"span",attrs:{id:'$id + "_target_header_item_count"',role:"presentation",tabindex:"0","aria-label":'$fns.getOptionCount(true) + " items"',class:'$classes.transferlistHeaderItemCount + " " + $classes.targetHeaderItemCount'},children:"$fns.getOptionCount(true)"}))),L=t("sourceControls",(()=>({$el:"div",if:"$searchable",attrs:{id:'$id + "_source_controls"',class:'$classes.transferlistControls + " " + $classes.sourceControls'}}))),y=t("sourceSearch",(()=>({if:"$searchable",$el:"div",attrs:{id:'$id + "_source_search"',class:'$classes.transferlistSearch + " " + $classes.sourceSearch'}}))),M=t("sourceSearchInput",(()=>({$el:"input",attrs:{id:'$id + "_source_search_input"',type:"text",placeholder:"$placeholder",onInput:"$handlers.onSearch",value:"$inputText",onKeydown:"$handlers.sourceKeyDown",disabled:"$disabled","aria-label":"Search",role:"searchbox",class:'$classes.transferlistSearchInput + " " + $classes.sourceSearchInput'}}))),w=t("sourceSearchClear",(()=>({$el:"button",if:"$inputText !== undefined",attrs:{id:'$id + "_source_search_clear"',type:"button",onClick:"$handlers.clearSearch","aria-label":"Clear search",class:'$classes.transferlistSearchClear + " " + $classes.sourceSearchClear'}}))),C=t("sourceListItems",(()=>({$el:"ul",attrs:{id:'$id + "_source_list_items"',"aria-activedescendant":"$activeDescendant",onMouseover:"$handlers.onMouseEnter(true)",onMouseout:"$handlers.onMouseLeave(true)",role:"listbox","aria-multiselectable":"true","aria-roledescription":"List of options to choose from.",class:'$classes.transferlistListItems + " " + $classes.sourceListItems'}}))),I=t("template",(()=>({for:["option","index","$options"],$el:null}))),S=t("sourceListItem",(()=>({if:"$targetOptionValues.includes($fns.optionValue($option)) === false",$el:"li",attrs:{id:'$id + "_source_list_item_" + $index',"data-value":"$option.value","aria-selected":"$selections && $selections.length > 0 && $fns.isSelected($option)","data-is-active":"$fns.isActive($option)","data-disabled":"$option.attrs.disabled",onKeydown:"$targetOptionValues.includes($option.value) === false && $handlers.sourceKeyDown",role:"option",onClick:"$option.attrs.disabled !== true && $handlers.selectOption($option, true)",key:"$option.value",class:'$classes.transferlistListItem + " " + $classes.sourceListItem'}}))),k=t("sourceOption",(()=>({$el:"div",attrs:{"data-checked":"$selections && $selections.length > 0 && $fns.isSelected($option)",class:'$classes.transferlistOption + " " + $classes.sourceOption'}}))),H=t("sourceLoadMore",(()=>({$el:"li",if:"$targetLoading !== true && $state.loading || $state.hasNextPage",attrs:{id:'$id + "_source_load_more"',key:"loadMore","aria-selected":"false",class:'$classes.transferlistLoadMore + " " + $classes.sourceLoadMore'}}))),x=t("loadMoreInner","span"),O=t("target",(()=>({$el:"div",attrs:{id:'$id + "_target"',class:'$classes.transferlist + " " + $classes.target'}}))),B=t("targetHeader",(()=>({$el:"div",attrs:{id:'$id + "_target_header"',role:"presentation",tabindex:"0",class:'$classes.transferlistHeader + " " + $classes.targetHeader'}}))),A=t("targetHeaderName",(()=>({if:"$target.label !== undefined",$el:"span",attrs:{id:'$id + "_target_header_name"',class:'$classes.transferlistHeaderName + " " + $classes.targetHeaderName'},children:"$target.label"}))),V=t("targetListItems",(()=>({$el:"ul",attrs:{id:"$id","aria-activedescendant":"$activeDescendant",onMouseover:"$handlers.onMouseEnter(false)",onMouseout:"$handlers.onMouseLeave(false)",class:'$classes.transferlistListItems + " " + $classes.targetListItems'}}))),E=t("targetListItem",(()=>({for:["option","index","$targetOptions"],$el:"li",attrs:{id:'$id + "_target_list_item_" + $index',"data-disabled":"$option.attrs.disabled","data-value":"$option.value","aria-selected":"$selections && $selections.length && $fns.isSelected($option, $target)","data-is-active":"$fns.isActive($option)",onKeydown:"$handlers.targetKeyDown",role:"option",onClick:"$option.attrs.disabled !== true && $handlers.selectOption($option, false)",key:"$option.value",class:'$classes.transferlistListItem + " " + $classes.targetListItem'}}))),F=t("targetOption",(()=>({$el:"div",attrs:{id:'$id + "_target_list_item_" + $index',class:'$classes.transferlistOption + " " + $classes.targetOption'}}))),K=t("targetLoadMore",(()=>({$el:"li",if:"$targetLoading && $state.loading",attrs:{id:'$id + "_target_load_more"',key:"loadMore","aria-selected":"false",class:'$classes.transferlistLoadMore + " " + $classes.targetLoadMore'}}))),D=t("transferControls",(()=>({$el:"div",attrs:{id:'$id + "_transfer_controls"'}}))),N=t("transferButtonForward",(()=>({if:"$transferOnSelect !== true",$el:"button",attrs:{id:'$id + "_transfer_button_forward"',type:"button",disabled:"$selections.length === 0 || $sourceSelected === false || $state.loading || $disabled || ($max && $value && $value.length >= $max)",onClick:"$handlers.transferForward","aria-label":"$ui.addSelectedValues.value",title:"$ui.addSelectedValues.value",class:'$classes.transferlistButton + " " + $classes.transferButtonForward'}}))),T=t("transferButtonForwardAll",(()=>({$el:"button",attrs:{id:'$id + "_transfer_button_forward_all"',type:"button",disabled:"$options.length === $targetOptions.length || $state.loading || $disabled || ($max && $value && $value.length >= $max)",onClick:"$handlers.transferForwardAll","aria-label":"$ui.addAllValues.value",title:"$ui.addAllValues.value",class:'$classes.transferlistButton + " " + $classes.transferButtonForwardAll'}}))),P=t("transferButtonBackward",(()=>({if:"$transferOnSelect !== true",$el:"button",attrs:{id:'$id + "_transfer_button_backward"',onClick:"$handlers.transferBackward",type:"button",disabled:"$selections.length === 0 || $sourceSelected === true || $state.loading || $disabled","aria-label":"$ui.removeSelectedValues.value",title:"$ui.removeSelectedValues.value",class:'$classes.transferlistButton + " " + $classes.transferButtonBackward'}}))),j=t("transferButtonBackwardAll",(()=>({$el:"button",attrs:{id:'$id + "_transfer_button_backward_all"',onClick:"$handlers.transferBackwardAll",type:"button",disabled:"$targetOptions.length === 0 || $state.loading || $disabled","aria-label":"$ui.removeAllValues.value",title:"$ui.removeAllValues.value",class:'$classes.transferlistButton + " " + $classes.transferButtonBackwardAll'}}))),q=t("controlLabel","span"),z=t("sourceEmptyMessage",(()=>({$el:"li",if:"$showSourceEmptyMessage && $sourceEmptyMessage && $state.loading !== true",attrs:{id:'$id + "_source_empty_message"',key:"$sourceEmptyMessage",role:"presentation"}}))),G=t("targetEmptyMessage",(()=>({$el:"li",if:"$showTargetEmptyMessage && $targetEmptyMessage && $state.loading !== true",attrs:{id:'$id + "_empty_message"',key:"$emptyMessage",role:"presentation"}}))),J=t("emptyMessageInner","span");export{p as area,q as controlLabel,t as createSection,J as emptyMessageInner,u as fieldset,d as help,i as icon,l as inner,f as legend,x as loadMoreInner,c as message,$ as messages,a as outer,o as prefix,g as source,L as sourceControls,z as sourceEmptyMessage,_ as sourceHeader,h as sourceHeaderItemCount,b as sourceHeaderLabel,S as sourceListItem,C as sourceListItems,H as sourceLoadMore,k as sourceOption,y as sourceSearch,w as sourceSearchClear,M as sourceSearchInput,n as suffix,O as target,G as targetEmptyMessage,B as targetHeader,v as targetHeaderItemCount,m as targetHeaderLabel,A as targetHeaderName,E as targetListItem,V as targetListItems,K as targetLoadMore,F as targetOption,I as template,P as transferButtonBackward,j as transferButtonBackwardAll,N as transferButtonForward,T as transferButtonForwardAll,D as transferControls,r as wrapper};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { FormKitProInput } from '@formkit/pro'
|
|
2
|
+
import {
|
|
3
|
+
outer,
|
|
4
|
+
fieldset,
|
|
5
|
+
wrapper,
|
|
6
|
+
help,
|
|
7
|
+
controlLabel,
|
|
8
|
+
legend,
|
|
9
|
+
messages,
|
|
10
|
+
message,
|
|
11
|
+
target,
|
|
12
|
+
targetListItems,
|
|
13
|
+
targetListItem,
|
|
14
|
+
targetOption,
|
|
15
|
+
targetHeader,
|
|
16
|
+
targetHeaderItemCount,
|
|
17
|
+
targetHeaderLabel,
|
|
18
|
+
sourceHeaderLabel,
|
|
19
|
+
source,
|
|
20
|
+
sourceHeader,
|
|
21
|
+
sourceHeaderItemCount,
|
|
22
|
+
sourceControls,
|
|
23
|
+
sourceSearch,
|
|
24
|
+
sourceSearchInput,
|
|
25
|
+
sourceSearchClear,
|
|
26
|
+
sourceListItems,
|
|
27
|
+
sourceListItem,
|
|
28
|
+
sourceOption,
|
|
29
|
+
sourceLoadMore,
|
|
30
|
+
targetLoadMore,
|
|
31
|
+
template,
|
|
32
|
+
loadMoreInner,
|
|
33
|
+
transferControls,
|
|
34
|
+
transferButtonForward,
|
|
35
|
+
transferButtonBackward,
|
|
36
|
+
transferButtonForwardAll,
|
|
37
|
+
transferButtonBackwardAll,
|
|
38
|
+
icon,
|
|
39
|
+
sourceEmptyMessage,
|
|
40
|
+
targetEmptyMessage,
|
|
41
|
+
emptyMessageInner,
|
|
42
|
+
} from '../sections/transferListSections'
|
|
43
|
+
import { default as transferListFeature } from '../features/transferlist'
|
|
44
|
+
import { options, defaultIcon, localize } from '@formkit/inputs'
|
|
45
|
+
import { $if } from '../compose'
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Input definition for a transferlist input.
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export const transferlist: FormKitProInput = {
|
|
52
|
+
/**
|
|
53
|
+
* The actual schema of the input, or a function that returns the schema.
|
|
54
|
+
*/
|
|
55
|
+
schema: outer(
|
|
56
|
+
fieldset(
|
|
57
|
+
legend('$label'),
|
|
58
|
+
help('$help'),
|
|
59
|
+
wrapper(
|
|
60
|
+
source(
|
|
61
|
+
sourceHeader(sourceHeaderLabel(), sourceHeaderItemCount()),
|
|
62
|
+
sourceControls(
|
|
63
|
+
sourceSearch(sourceSearchInput(), sourceSearchClear(icon('close')))
|
|
64
|
+
),
|
|
65
|
+
sourceListItems(
|
|
66
|
+
sourceEmptyMessage(emptyMessageInner('$sourceEmptyMessage')),
|
|
67
|
+
template(
|
|
68
|
+
sourceListItem(
|
|
69
|
+
$if(
|
|
70
|
+
'$transferOnSelect !== true && $fns.isSelected($option)',
|
|
71
|
+
icon('selected')
|
|
72
|
+
),
|
|
73
|
+
sourceOption('$option.label')
|
|
74
|
+
)
|
|
75
|
+
),
|
|
76
|
+
sourceLoadMore(
|
|
77
|
+
loadMoreInner(
|
|
78
|
+
$if(
|
|
79
|
+
'$targetLoading !== true && $state.loading',
|
|
80
|
+
icon('loader')
|
|
81
|
+
),
|
|
82
|
+
'$state.loading && $ui.isLoading.value || $ui.loadMore.value'
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
),
|
|
87
|
+
transferControls(
|
|
88
|
+
transferButtonForwardAll(
|
|
89
|
+
controlLabel('$ui.addAllValues.value'),
|
|
90
|
+
icon('fastForward')
|
|
91
|
+
),
|
|
92
|
+
transferButtonForward(
|
|
93
|
+
controlLabel('$ui.addSelectedValues.value'),
|
|
94
|
+
icon('moveRight')
|
|
95
|
+
),
|
|
96
|
+
transferButtonBackward(
|
|
97
|
+
controlLabel('$ui.removeSelectedValues.value'),
|
|
98
|
+
icon('moveLeft')
|
|
99
|
+
),
|
|
100
|
+
transferButtonBackwardAll(
|
|
101
|
+
controlLabel('$ui.removeAllValues.value'),
|
|
102
|
+
icon('rewind')
|
|
103
|
+
)
|
|
104
|
+
),
|
|
105
|
+
target(
|
|
106
|
+
targetHeader(targetHeaderLabel(), targetHeaderItemCount()),
|
|
107
|
+
targetListItems(
|
|
108
|
+
targetEmptyMessage(emptyMessageInner('$targetEmptyMessage')),
|
|
109
|
+
targetListItem(
|
|
110
|
+
$if(
|
|
111
|
+
'$transferOnSelect !== true && $fns.isSelected($option)',
|
|
112
|
+
icon('selected')
|
|
113
|
+
),
|
|
114
|
+
targetOption('$option.label')
|
|
115
|
+
),
|
|
116
|
+
targetLoadMore(
|
|
117
|
+
loadMoreInner(
|
|
118
|
+
$if('$targetLoading && $state.loading', icon('loader')),
|
|
119
|
+
'$state.loading && $ui.isLoading.value || $ui.loadMore.value'
|
|
120
|
+
)
|
|
121
|
+
)
|
|
122
|
+
)
|
|
123
|
+
)
|
|
124
|
+
),
|
|
125
|
+
messages(message('$message.value'))
|
|
126
|
+
)
|
|
127
|
+
),
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The type of node, can be a list, group, or input.
|
|
131
|
+
*/
|
|
132
|
+
type: 'input',
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* An array of extra props to accept for this input.
|
|
136
|
+
*/
|
|
137
|
+
props: [
|
|
138
|
+
'options',
|
|
139
|
+
'selections',
|
|
140
|
+
'activeValue',
|
|
141
|
+
'activeDescendant',
|
|
142
|
+
'sourceSelected',
|
|
143
|
+
'targetOptions',
|
|
144
|
+
'target',
|
|
145
|
+
'source',
|
|
146
|
+
'optionLoader',
|
|
147
|
+
'filterOptions',
|
|
148
|
+
'inputText',
|
|
149
|
+
'renderList',
|
|
150
|
+
'search',
|
|
151
|
+
'hasNextPage',
|
|
152
|
+
'page',
|
|
153
|
+
'targetOptionValues',
|
|
154
|
+
'targetLoading',
|
|
155
|
+
'searchable',
|
|
156
|
+
'sourceLabel',
|
|
157
|
+
'targetLabel',
|
|
158
|
+
'transferOnSelect',
|
|
159
|
+
'disabled',
|
|
160
|
+
'placeholder',
|
|
161
|
+
'filter',
|
|
162
|
+
'showSourceEmptyMessage',
|
|
163
|
+
'showTargetEmptyMessage',
|
|
164
|
+
'sourceEmptyMessage',
|
|
165
|
+
'targetEmptyMessage',
|
|
166
|
+
'clearOnSelect',
|
|
167
|
+
'max',
|
|
168
|
+
'debounce',
|
|
169
|
+
],
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Additional features that make this input work.
|
|
173
|
+
*/
|
|
174
|
+
features: [
|
|
175
|
+
transferListFeature,
|
|
176
|
+
options,
|
|
177
|
+
defaultIcon('moveRight', 'right'),
|
|
178
|
+
defaultIcon('moveLeft', 'left'),
|
|
179
|
+
defaultIcon('fastForward', 'fastForward'),
|
|
180
|
+
defaultIcon('rewind', 'rewind'),
|
|
181
|
+
defaultIcon('close', 'close'),
|
|
182
|
+
defaultIcon('loader', 'spinner'),
|
|
183
|
+
defaultIcon('selected', 'check'),
|
|
184
|
+
localize('isLoading'),
|
|
185
|
+
localize('loadMore'),
|
|
186
|
+
localize('addAllValues'),
|
|
187
|
+
localize('addSelectedValues'),
|
|
188
|
+
localize('removeSelectedValues'),
|
|
189
|
+
localize('removeAllValues'),
|
|
190
|
+
],
|
|
191
|
+
}
|