@formkit/pro 1.0.0-alpha.6 → 1.0.0-alpha.60-c6b72ae

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.
@@ -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
- items(
47
- item(
48
- content(group('$slots.default')),
49
- controls(
50
- up(upControl(controlLabel('$ui.moveUp.value'), icon('moveUp'))),
51
- remove(
52
- removeControl(controlLabel('$ui.remove.value'), icon('remove'))
53
- ),
54
- insert(insertControl(controlLabel('$ui.add.value'), icon('add'))),
55
- down(
56
- downControl(
57
- controlLabel('$ui.moveDown.value'),
58
- icon('moveDown')
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:x,message:b}=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",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:"$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,b as message,x 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,98 @@
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
+ } from '../features/dropdownFeatures'
8
+ import { getSelections } from '../features/taglistFeatures'
9
+ import { options, defaultIcon, localize } from '@formkit/inputs'
10
+ import { FormKitProInput } from '@formkit/pro'
11
+ import {
12
+ outer,
13
+ wrapper,
14
+ inner,
15
+ label,
16
+ prefix,
17
+ tag,
18
+ tagWrapper,
19
+ tagLoading,
20
+ suffix,
21
+ help,
22
+ messages,
23
+ message,
24
+ listbox,
25
+ icon,
26
+ input,
27
+ listboxButton,
28
+ tags,
29
+ tagLabel,
30
+ removeSelection,
31
+ } from '../sections/taglistSections'
32
+ import { $if } from '../compose'
33
+
34
+ /**
35
+ * Input definition for a taglist input.
36
+ * @public
37
+ */
38
+ export const taglist: FormKitProInput = {
39
+ /**
40
+ * The actual schema of the input, or a function that returns the schema.
41
+ */
42
+ schema: outer(
43
+ wrapper(
44
+ label('$label'),
45
+ inner(
46
+ icon('prefix'),
47
+ prefix(),
48
+ tags(
49
+ tagWrapper(
50
+ tag(
51
+ $if(
52
+ '$state.loading',
53
+ tagLoading('$ui.isLoading.value'),
54
+ tagLabel('$option.label')
55
+ ),
56
+ removeSelection(icon('close'))
57
+ )
58
+ ),
59
+ input()
60
+ ),
61
+ $if('$state.loading', icon('loader')),
62
+ listboxButton(icon('select')),
63
+ listbox(),
64
+ suffix(),
65
+ icon('suffix')
66
+ )
67
+ ),
68
+ help('$help'),
69
+ messages(message('$message.value'))
70
+ ),
71
+ /**
72
+ * The type of node, can be a list, group, or input.
73
+ */
74
+ type: 'input',
75
+ /**
76
+ * In the dropdown family of inputs.
77
+ */
78
+ family: 'dropdown',
79
+ /**
80
+ * An array of extra props to accept for this input.
81
+ */
82
+ props: [],
83
+ /**
84
+ * Additional features that make this input work.
85
+ */
86
+ features: [
87
+ options,
88
+ taglistFeature,
89
+ dropdownFeature(dropdownKeyHandler, dropdownDisplayHandler(getSelections)),
90
+ autocompleteFeature(getSelections),
91
+ defaultIcon('select', 'select'),
92
+ defaultIcon('close', 'close'),
93
+ defaultIcon('selected', 'check'),
94
+ defaultIcon('loader', 'spinner'),
95
+ localize('isLoading'),
96
+ localize('loadMore'),
97
+ ],
98
+ }
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:f,messages:b,message:d,icon:u}=l(o),c=o("input",(()=>({$el:"input",attrs:{type:"checkbox",id:"$id",value:"$_value",checked:"$checked",onInput:"$handlers.toggles",disabled:"$disabled"}}))),s=o("label",(()=>({if:"($label && $onValueLabel === undefined && $offValueLabel === undefined) || ($valueLabelDisplay === inner)",$el:"label",attrs:{for:"$id"},children:"$label"}))),h=o("altLabel",(()=>({$el:"label",if:"$label && ($onValueLabel || $offValueLabel) && $valueLabelDisplay !== hidden && $valueLabelDisplay !== inner",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",u("thumb")));export{h as altLabel,o as createSection,s as defaultLabel,f as help,u as icon,p as inner,L as innerLabel,c as input,i as label,d as message,b as messages,$ as outer,n as prefix,r as suffix,C as thumbWrapper,v as track,k as valueLabel,t as wrapper};
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",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
@@ -59,6 +59,7 @@ export const toggle: FormKitProInput = {
59
59
  'trackColorOff',
60
60
  'trackColorOn',
61
61
  'valueLabelDisplay',
62
+ 'altLabelPosition',
62
63
  ],
63
64
 
64
65
  /**