@plastic-js/tsumiki 0.1.1 → 0.1.2
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.
|
@@ -123,11 +123,13 @@ var Root = (props = {}) => {
|
|
|
123
123
|
"onOpen",
|
|
124
124
|
"onClose",
|
|
125
125
|
"onOpenChange",
|
|
126
|
-
"closeOnInteractOutside"
|
|
126
|
+
"closeOnInteractOutside",
|
|
127
|
+
"lazyMount"
|
|
127
128
|
]);
|
|
128
129
|
return OriginalRoot({
|
|
129
130
|
...rest,
|
|
130
131
|
closeOnInteractOutside: local.closeOnInteractOutside ?? false,
|
|
132
|
+
lazyMount: local.lazyMount ?? true,
|
|
131
133
|
onOpenChange: (open) => {
|
|
132
134
|
local.onOpenChange?.(open);
|
|
133
135
|
if (open) local.onOpen?.();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":["css","Dialog","splitProps","Portal","Icon","_tmpl4","_template","_tmpl3","_tmpl2","_tmpl","backdropClass","position","inset","background","backdropFilter","zIndex","display","positionerClass","alignItems","justifyContent","padding","contentClass","border","borderRadius","width","maxWidth","maxHeight","flexDirection","color","boxShadow","headClass","borderBottom","titleWrapClass","gap","minWidth","titleIconClass","flexShrink","titleClass","fontSize","fontWeight","margin","closeBtnClass","height","lineHeight","cursor","bodyClass","overflowY","footClass","borderTop","btnClass","flex","fontFamily","borderColor","btnPrimaryClass","filter","opacity","OriginalRoot","Root","props","local","rest","closeOnInteractOutside","onOpenChange","open","onOpen","onClose","Preset","rootProps","_jsx","_mergeProps","children","Backdrop","className","Positioner","Content","_el0","cloneNode","_el1","firstChild","_el2","_el3","nextSibling","_el4","_insert","icon","size","svg","Title","title","_setProp","CloseTrigger","hidden","cancelText","confirmText","type","loading","onConfirm","Object","assign"],"sources":["../../src/components/Dialog.jsx"],"sourcesContent":["import { css } from '@emotion/css'\nimport { Dialog } from '@plastic-js/ark'\nimport { splitProps } from '@plastic-js/plastic'\nimport Portal from './Portal.jsx'\nimport Icon from './Icon.jsx'\n\nconst backdropClass = css({\n\tposition: 'fixed',\n\tinset: 0,\n\tbackground: 'rgba(0, 0, 0, 0.6)',\n\tbackdropFilter: 'blur(4px)',\n\tzIndex: 9998,\n\t'&[hidden]': { display: 'none' },\n})\n\nconst positionerClass = css({\n\tposition: 'fixed',\n\tinset: 0,\n\tdisplay: 'flex',\n\talignItems: 'flex-end',\n\tjustifyContent: 'center',\n\tzIndex: 9999,\n\t'@media (min-width: 640px)': {\n\t\talignItems: 'center',\n\t\tpadding: '24px',\n\t},\n})\n\nconst contentClass = css({\n\tbackground: 'var(--surface)',\n\tborder: '1px solid var(--border)',\n\tborderRadius: '20px 20px 0 0',\n\twidth: '100%',\n\tmaxWidth: '480px',\n\tmaxHeight: '92vh',\n\tdisplay: 'flex',\n\tflexDirection: 'column',\n\tcolor: 'var(--ink)',\n\tboxShadow: '0 -8px 32px rgba(0,0,0,0.4)',\n\t'&[hidden]': { display: 'none' },\n\t'@media (min-width: 640px)': {\n\t\tborderRadius: '20px',\n\t},\n})\n\nconst headClass = css({\n\tdisplay: 'flex',\n\talignItems: 'center',\n\tjustifyContent: 'space-between',\n\tpadding: '18px 20px',\n\tborderBottom: '1px solid var(--border)',\n})\n\nconst titleWrapClass = css({\n\tdisplay: 'flex',\n\talignItems: 'center',\n\tgap: '10px',\n\tminWidth: 0,\n})\n\nconst titleIconClass = css({\n\tflexShrink: 0,\n\tcolor: 'var(--accent)',\n})\n\nconst titleClass = css({\n\tfontSize: '18px',\n\tfontWeight: 700,\n\tmargin: 0,\n})\n\nconst closeBtnClass = css({\n\twidth: '32px',\n\theight: '32px',\n\tborderRadius: '50%',\n\tbackground: 'transparent',\n\tborder: 'none',\n\tcolor: 'var(--muted)',\n\tfontSize: '22px',\n\tlineHeight: 1,\n\tcursor: 'pointer',\n\tdisplay: 'flex',\n\talignItems: 'center',\n\tjustifyContent: 'center',\n\t'&:hover': { background: 'rgba(255,255,255,0.06)', color: 'var(--ink)' },\n\t'&[hidden]': { display: 'none' },\n})\n\nconst bodyClass = css({\n\tpadding: '20px',\n\toverflowY: 'auto',\n})\n\nconst footClass = css({\n\tdisplay: 'flex',\n\tgap: '10px',\n\tpadding: '14px 20px 20px',\n\tborderTop: '1px solid var(--border)',\n})\n\nconst btnClass = css({\n\tflex: 1,\n\theight: '46px',\n\tborderRadius: '10px',\n\tborder: '1px solid var(--border)',\n\tbackground: 'transparent',\n\tcolor: 'var(--ink)',\n\tfontSize: '15px',\n\tfontWeight: 600,\n\tfontFamily: 'inherit',\n\tcursor: 'pointer',\n\t'&:hover': { borderColor: 'rgba(255,255,255,0.2)' },\n})\n\nconst btnPrimaryClass = css({\n\tbackground: 'var(--accent)',\n\tborderColor: 'var(--accent)',\n\tcolor: '#fff',\n\t'&:hover': { filter: 'brightness(1.08)' },\n\t'&:disabled': { opacity: 0.5, cursor: 'not-allowed' },\n})\n\nconst OriginalRoot = Dialog.Root\n\nconst Root = (props = {})=> {\n\tconst [local, rest] = splitProps(props, ['onOpen', 'onClose', 'onOpenChange', 'closeOnInteractOutside'])\n\treturn OriginalRoot({\n\t\t...rest,\n\t\tcloseOnInteractOutside: local.closeOnInteractOutside ?? false,\n\t\tonOpenChange: (open)=> {\n\t\t\tlocal.onOpenChange?.(open)\n\t\t\tif (open){ local.onOpen?.() } else { local.onClose?.() }\n\t\t},\n\t})\n}\n\nconst Preset = (props)=> {\n\tconst [local, rootProps] = splitProps(props, ['title', 'icon', 'cancelText', 'confirmText', 'onConfirm', 'loading', 'children'])\n\treturn (\n\t\t<Root {...rootProps}>\n\t\t\t<Portal>\n\t\t\t\t<Dialog.Backdrop className={backdropClass} />\n\t\t\t\t<Dialog.Positioner className={positionerClass}>\n\t\t\t\t\t<Dialog.Content className={contentClass}>\n\t\t\t\t\t\t<div className={headClass}>\n\t\t\t\t\t\t\t<div className={titleWrapClass}>\n\t\t\t\t\t\t\t\t{local.icon && <Icon className={titleIconClass} size={20} svg={local.icon} />}\n\t\t\t\t\t\t\t\t<Dialog.Title className={titleClass}>\n\t\t\t\t\t\t\t\t\t{local.title}\n\t\t\t\t\t\t\t\t</Dialog.Title>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<Dialog.CloseTrigger aria-label='Close' className={closeBtnClass} hidden>×</Dialog.CloseTrigger>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className={bodyClass}>\n\t\t\t\t\t\t\t{local.children}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{((local.cancelText ?? 'Cancel') || (local.confirmText ?? 'Confirm')) && (\n\t\t\t\t\t\t\t<div className={footClass}>\n\t\t\t\t\t\t\t\t<Dialog.CloseTrigger className={btnClass} type='button'>\n\t\t\t\t\t\t\t\t\t{local.cancelText ?? 'Cancel'}\n\t\t\t\t\t\t\t\t</Dialog.CloseTrigger>\n\t\t\t\t\t\t\t\t{(local.confirmText ?? 'Confirm') && (\n\t\t\t\t\t\t\t\t\t<button className={`${btnClass} ${btnPrimaryClass}`} disabled={local.loading?.()} onClick={local.onConfirm} type='button'>\n\t\t\t\t\t\t\t\t\t\t{local.loading?.() ? 'Loading…' : local.confirmText ?? 'Confirm'}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</Dialog.Content>\n\t\t\t\t</Dialog.Positioner>\n\t\t\t</Portal>\n\t\t</Root>\n\t)\n}\n\nexport default Object.assign(Root, {\n\t...Dialog, OriginalRoot: Root, Root: Preset,\n})\n"],"mappings":";;;;;;;AAI6B,IAAAK,SAAAC,SAAA,mCAAA;AAAA,IAAAC,SAAAD,SAAA,mBAAA;AAAA,IAAAE,SAAAF,SAAA,aAAA;AAAA,IAAAG,QAAAH,SAAA,iCAAA;AAE7B,IAAMI,gBAAgBV,IAAI;CACzBW,UAAU;CACVC,OAAO;CACPC,YAAY;CACZC,gBAAgB;CAChBC,QAAQ;CACR,aA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,iBAAiB;MAAAoC,QAAAd,MAAA,kBAAYhB,MAAMoC,UAAU,CAAC;MAAAN,QAAAd,MAAA,iBAAWhB,MAAMqC,SAAS;MAAA,OAAArB;KAAA,IAG1GI,IAAA;KAAAU,QAAAd,MAAA,mBARc5B,SAAS;KAAA,OAAA4B;IAAA;GAUzB;EAAA,CAAA,CAAA;CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA;AAMP;AAEA,IAAA,iBAAesB,OAAOC,OAAOzC,MAAM;CAClC,GAAGxD;CAAQuD,cAAcC;CAAMA,MAAMS;AACtC,CAAC"}
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["css","Dialog","splitProps","Portal","Icon","_tmpl4","_template","_tmpl3","_tmpl2","_tmpl","backdropClass","position","inset","background","backdropFilter","zIndex","display","positionerClass","alignItems","justifyContent","padding","contentClass","border","borderRadius","width","maxWidth","maxHeight","flexDirection","color","boxShadow","headClass","borderBottom","titleWrapClass","gap","minWidth","titleIconClass","flexShrink","titleClass","fontSize","fontWeight","margin","closeBtnClass","height","lineHeight","cursor","bodyClass","overflowY","footClass","borderTop","btnClass","flex","fontFamily","borderColor","btnPrimaryClass","filter","opacity","OriginalRoot","Root","props","local","rest","closeOnInteractOutside","lazyMount","onOpenChange","open","onOpen","onClose","Preset","rootProps","_jsx","_mergeProps","children","Backdrop","className","Positioner","Content","_el0","cloneNode","_el1","firstChild","_el2","_el3","nextSibling","_el4","_insert","icon","size","svg","Title","title","_setProp","CloseTrigger","hidden","cancelText","confirmText","type","loading","onConfirm","Object","assign"],"sources":["../../src/components/Dialog.jsx"],"sourcesContent":["import { css } from '@emotion/css'\nimport { Dialog } from '@plastic-js/ark'\nimport { splitProps } from '@plastic-js/plastic'\nimport Portal from './Portal.jsx'\nimport Icon from './Icon.jsx'\n\nconst backdropClass = css({\n\tposition: 'fixed',\n\tinset: 0,\n\tbackground: 'rgba(0, 0, 0, 0.6)',\n\tbackdropFilter: 'blur(4px)',\n\tzIndex: 9998,\n\t'&[hidden]': { display: 'none' },\n})\n\nconst positionerClass = css({\n\tposition: 'fixed',\n\tinset: 0,\n\tdisplay: 'flex',\n\talignItems: 'flex-end',\n\tjustifyContent: 'center',\n\tzIndex: 9999,\n\t'@media (min-width: 640px)': {\n\t\talignItems: 'center',\n\t\tpadding: '24px',\n\t},\n})\n\nconst contentClass = css({\n\tbackground: 'var(--surface)',\n\tborder: '1px solid var(--border)',\n\tborderRadius: '20px 20px 0 0',\n\twidth: '100%',\n\tmaxWidth: '480px',\n\tmaxHeight: '92vh',\n\tdisplay: 'flex',\n\tflexDirection: 'column',\n\tcolor: 'var(--ink)',\n\tboxShadow: '0 -8px 32px rgba(0,0,0,0.4)',\n\t'&[hidden]': { display: 'none' },\n\t'@media (min-width: 640px)': {\n\t\tborderRadius: '20px',\n\t},\n})\n\nconst headClass = css({\n\tdisplay: 'flex',\n\talignItems: 'center',\n\tjustifyContent: 'space-between',\n\tpadding: '18px 20px',\n\tborderBottom: '1px solid var(--border)',\n})\n\nconst titleWrapClass = css({\n\tdisplay: 'flex',\n\talignItems: 'center',\n\tgap: '10px',\n\tminWidth: 0,\n})\n\nconst titleIconClass = css({\n\tflexShrink: 0,\n\tcolor: 'var(--accent)',\n})\n\nconst titleClass = css({\n\tfontSize: '18px',\n\tfontWeight: 700,\n\tmargin: 0,\n})\n\nconst closeBtnClass = css({\n\twidth: '32px',\n\theight: '32px',\n\tborderRadius: '50%',\n\tbackground: 'transparent',\n\tborder: 'none',\n\tcolor: 'var(--muted)',\n\tfontSize: '22px',\n\tlineHeight: 1,\n\tcursor: 'pointer',\n\tdisplay: 'flex',\n\talignItems: 'center',\n\tjustifyContent: 'center',\n\t'&:hover': { background: 'rgba(255,255,255,0.06)', color: 'var(--ink)' },\n\t'&[hidden]': { display: 'none' },\n})\n\nconst bodyClass = css({\n\tpadding: '20px',\n\toverflowY: 'auto',\n})\n\nconst footClass = css({\n\tdisplay: 'flex',\n\tgap: '10px',\n\tpadding: '14px 20px 20px',\n\tborderTop: '1px solid var(--border)',\n})\n\nconst btnClass = css({\n\tflex: 1,\n\theight: '46px',\n\tborderRadius: '10px',\n\tborder: '1px solid var(--border)',\n\tbackground: 'transparent',\n\tcolor: 'var(--ink)',\n\tfontSize: '15px',\n\tfontWeight: 600,\n\tfontFamily: 'inherit',\n\tcursor: 'pointer',\n\t'&:hover': { borderColor: 'rgba(255,255,255,0.2)' },\n})\n\nconst btnPrimaryClass = css({\n\tbackground: 'var(--accent)',\n\tborderColor: 'var(--accent)',\n\tcolor: '#fff',\n\t'&:hover': { filter: 'brightness(1.08)' },\n\t'&:disabled': { opacity: 0.5, cursor: 'not-allowed' },\n})\n\nconst OriginalRoot = Dialog.Root\n\nconst Root = (props = {})=> {\n\tconst [local, rest] = splitProps(props, ['onOpen', 'onClose', 'onOpenChange', 'closeOnInteractOutside', 'lazyMount'])\n\treturn OriginalRoot({\n\t\t...rest,\n\t\tcloseOnInteractOutside: local.closeOnInteractOutside ?? false,\n\t\t// Defer rendering the dialog body until it is first opened, then keep it\n\t\t// mounted. ark's Positioner gates its subtree on this via presence strategy.\n\t\tlazyMount: local.lazyMount ?? true,\n\t\tonOpenChange: (open)=> {\n\t\t\tlocal.onOpenChange?.(open)\n\t\t\tif (open){ local.onOpen?.() } else { local.onClose?.() }\n\t\t},\n\t})\n}\n\nconst Preset = (props)=> {\n\tconst [local, rootProps] = splitProps(props, ['title', 'icon', 'cancelText', 'confirmText', 'onConfirm', 'loading', 'children'])\n\treturn (\n\t\t<Root {...rootProps}>\n\t\t\t<Portal>\n\t\t\t\t<Dialog.Backdrop className={backdropClass} />\n\t\t\t\t<Dialog.Positioner className={positionerClass}>\n\t\t\t\t\t<Dialog.Content className={contentClass}>\n\t\t\t\t\t\t<div className={headClass}>\n\t\t\t\t\t\t\t<div className={titleWrapClass}>\n\t\t\t\t\t\t\t\t{local.icon && <Icon className={titleIconClass} size={20} svg={local.icon} />}\n\t\t\t\t\t\t\t\t<Dialog.Title className={titleClass}>\n\t\t\t\t\t\t\t\t\t{local.title}\n\t\t\t\t\t\t\t\t</Dialog.Title>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<Dialog.CloseTrigger aria-label='Close' className={closeBtnClass} hidden>×</Dialog.CloseTrigger>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className={bodyClass}>\n\t\t\t\t\t\t\t{local.children}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{((local.cancelText ?? 'Cancel') || (local.confirmText ?? 'Confirm')) && (\n\t\t\t\t\t\t\t<div className={footClass}>\n\t\t\t\t\t\t\t\t<Dialog.CloseTrigger className={btnClass} type='button'>\n\t\t\t\t\t\t\t\t\t{local.cancelText ?? 'Cancel'}\n\t\t\t\t\t\t\t\t</Dialog.CloseTrigger>\n\t\t\t\t\t\t\t\t{(local.confirmText ?? 'Confirm') && (\n\t\t\t\t\t\t\t\t\t<button className={`${btnClass} ${btnPrimaryClass}`} disabled={local.loading?.()} onClick={local.onConfirm} type='button'>\n\t\t\t\t\t\t\t\t\t\t{local.loading?.() ? 'Loading…' : local.confirmText ?? 'Confirm'}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</Dialog.Content>\n\t\t\t\t</Dialog.Positioner>\n\t\t\t</Portal>\n\t\t</Root>\n\t)\n}\n\nexport default Object.assign(Root, {\n\t...Dialog, OriginalRoot: Root, Root: Preset,\n})\n"],"mappings":";;;;;;;AAI6B,IAAAK,SAAAC,SAAA,mCAAA;AAAA,IAAAC,SAAAD,SAAA,mBAAA;AAAA,IAAAE,SAAAF,SAAA,aAAA;AAAA,IAAAG,QAAAH,SAAA,iCAAA;AAE7B,IAAMI,gBAAgBV,IAAI;CACzBW,UAAU;CACVC,OAAO;CACPC,YAAY;CACZC,gBAAgB;CAChBC,QAAQ;CACR,aAAa,EAAEC,SAAS,OAAO;AAChC,CAAC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iB;MAAAqC,QAAAd,MAAA,kBAAYjB,MAAMqC,UAAU,CAAC;MAAAN,QAAAd,MAAA,iBAAWjB,MAAMsC,SAAS;MAAA,OAAArB;KAAA,IAG1GI,IAAA;KAAAU,QAAAd,MAAA,mBARc7B,SAAS;KAAA,OAAA6B;IAAA;GAUzB;EAAA,CAAA,CAAA;CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA;AAMP;AAEA,IAAA,iBAAesB,OAAOC,OAAO1C,MAAM;CAClC,GAAGxD;CAAQuD,cAAcC;CAAMA,MAAMU;AACtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteredSelect.js","names":["Combobox","useComboboxContext","Loop","createComputed","createContext","createEffect","createSignal","splitProps","useContext","collection","createCollection","_tmpl3","_template","_tmpl2","_tmpl","access","value","FilterContext","defaultItemToValue","item","String","id","defaultItemToString","label","name","defaultFilter","query","itemToString","toLowerCase","includes","Root","props","local","rest","itemToValue","filter","inputValue","filteredItems","q","trim","list","items","_jsx","Provider","_mergeProps","children","onInputValueChange","HighlightSingleMatch","combobox","api","open","length","highlightedValue","setHighlightValue","Input","onInput","event","getInputProps","onChange","Items","each","ChevronIcon","cloneNode","CheckIcon","FilteredSelect","cn","classNames","openOnClick","Label","className","Control","control","input","disabled","placeholder","Trigger","trigger","type","Content","content","Empty","empty","emptyText","Item","key","ItemText","itemText","_el0","_insert","_setProp","check"],"sources":["../../src/components/FilteredSelect.jsx"],"sourcesContent":["import { Combobox, useComboboxContext } from '@plastic-js/ark'\nimport {\n\tLoop, createComputed, createContext, createEffect, createSignal, splitProps, useContext,\n} from '@plastic-js/plastic'\nimport { collection as createCollection } from '@zag-js/combobox'\n\n// FilteredSelect — a filterable single-select built on the pure `Combobox`\n// primitive's underlying headless machine.\n//\n// This file owns two things:\n// 1. The filter plumbing. The headless component is \"controlled collection\"\n// only: it expects you to build a @zag-js collection yourself and narrow it\n// down as the user types. The internal <Root> keeps a query in sync with the\n// input, filters the list and feeds a reactive collection back to the\n// headless Root.\n// 2. The public API / contract. The default-exported <FilteredSelect> assembles\n// the full structure (label, control, input, trigger, content, items) and\n// exposes a flat prop API. It is intentionally style-agnostic: every visual\n// slot is themed through the `classNames` map, so the styling layer\n// (MyFilteredSelect) only has to supply CSS.\n\nconst access = (value)=> {\n\treturn typeof value === 'function' ? value() : value\n}\n\n// Exposes the filtered items to <Items> without forcing the caller to thread\n// them through props.\nconst FilterContext = createContext(null)\n\nconst defaultItemToValue = item=> String(item?.value ?? item?.id ?? item)\nconst defaultItemToString = item=> String(item?.label ?? item?.name ?? item)\n\n// Substring match on the item's display string. Override via the `filter` prop\n// for fuzzy/score-based matching.\nconst defaultFilter = (item, query, itemToString)=> itemToString(item).toLowerCase().includes(query)\n\nconst Root = (props = {})=> {\n\tconst [local, rest] = splitProps(props, [\n\t\t'items', 'itemToValue', 'itemToString', 'filter', 'inputValue', 'onInputValueChange', 'children',\n\t])\n\n\tconst itemToValue = local.itemToValue ?? defaultItemToValue\n\tconst itemToString = local.itemToString ?? defaultItemToString\n\tconst filter = local.filter ?? defaultFilter\n\n\t// Internal query mirrors the input. We seed it from any `inputValue` the\n\t// caller passed so an initial/controlled value still filters correctly.\n\tconst query = createSignal(access(local.inputValue) ?? '')\n\n\t// Recomputes on typing and whenever the source `items` change. An empty\n\t// query shows everything; otherwise only the matches survive.\n\tconst filteredItems = createComputed(()=> {\n\t\tconst q = query().trim().toLowerCase()\n\t\tconst list = access(local.items) ?? []\n\t\treturn q ? list.filter(item=> filter(item, q, itemToString)) : list\n\t})\n\n\tconst collection = createComputed(()=> createCollection({\n\t\titems: filteredItems(),\n\t\titemToValue,\n\t\titemToString,\n\t}))\n\n\treturn (\n\t\t<FilterContext.Provider value={filteredItems}>\n\t\t\t<Combobox.Root\n\t\t\t\t{...rest}\n\t\t\t\tcollection={collection}\n\t\t\t\tinputValue={query}\n\t\t\t\tonInputValueChange={(value)=> {\n\t\t\t\t\tquery(value)\n\t\t\t\t\tlocal.onInputValueChange?.(value)\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<HighlightSingleMatch itemToValue={itemToValue} items={filteredItems} />\n\t\t\t\t{local.children}\n\t\t\t</Combobox.Root>\n\t\t</FilterContext.Provider>\n\t)\n}\n\n// When the open list narrows to a single match, pre-highlight it so the user\n// can confirm with Enter/Tab without arrowing down. We nudge the machine's own\n// (uncontrolled) highlight imperatively rather than controlling `highlightedValue`\n// — controlling it would pin the highlight in place and fight the machine, e.g.\n// blocking the highlight-clear on the next keystroke and the select-and-close on\n// Enter. We only set it; the machine still clears/moves it on input and navigation.\nconst HighlightSingleMatch = (props = {})=> {\n\tconst combobox = useComboboxContext()\n\tcreateEffect(()=> {\n\t\tconst api = combobox()\n\t\tconst list = props.items()\n\t\tif (!api.open || list.length !== 1){ return }\n\t\tconst value = props.itemToValue(list[0])\n\t\tif (api.highlightedValue !== value){ api.setHighlightValue(value) }\n\t})\n\treturn null\n}\n\n// The headless input only fires zag's INPUT.CHANGE on the native `change`\n// event — which, unlike React's onChange, fires on blur, not per keystroke. So\n// typing never reached the machine and the list never filtered. We bridge the\n// per-keystroke `input` event to zag's own onChange handler so every character\n// drives the same INPUT.CHANGE (open + filter) behaviour.\nconst Input = (props = {})=> {\n\tconst combobox = useComboboxContext()\n\treturn (\n\t\t<Combobox.Input\n\t\t\t{...props}\n\t\t\tonInput={event=> combobox().getInputProps().onChange?.(event)}\n\t\t/>\n\t)\n}\n\n// Render-prop over the filtered items. Place inside <Combobox.Content> and\n// return a <Combobox.Item> for each match. Backed by <Loop> so the list stays\n// reactive — a bare thunk returned from a component is unwrapped once and would\n// never re-filter.\nconst Items = (props = {})=> {\n\tconst items = useContext(FilterContext)\n\treturn (\n\t\t<Loop each={items ?? []}>\n\t\t\t{item=> props.children?.(item)}\n\t\t</Loop>\n\t)\n}\n\nfunction ChevronIcon(){\n\treturn (\n\t\t<svg\n\t\t\tfill='none' stroke='currentColor' strokeLinecap='round' strokeLinejoin='round'\n\t\t\tstrokeWidth='2' viewBox='0 0 24 24'\n\t\t>\n\t\t\t<polyline points='6 9 12 15 18 9' />\n\t\t</svg>\n\t)\n}\n\nfunction CheckIcon(){\n\treturn (\n\t\t<svg\n\t\t\tfill='none' stroke='currentColor' strokeLinecap='round' strokeLinejoin='round'\n\t\t\tstrokeWidth='2.5' viewBox='0 0 24 24'\n\t\t>\n\t\t\t<polyline points='20 6 9 17 4 12' />\n\t\t</svg>\n\t)\n}\n\n// Public component. `classNames` themes each slot (control/input/trigger/content/\n// empty/item/itemText/check/label); anything not split here (e.g. `filter`,\n// `name`) flows through to the filter Root.\nconst FilteredSelect = (props = {})=> {\n\tconst [local, rest] = splitProps(props, [\n\t\t'items',\n\t\t'itemToString',\n\t\t'itemToValue',\n\t\t'placeholder',\n\t\t'label',\n\t\t'openOnClick',\n\t\t'disabled',\n\t\t'classNames',\n\t\t'emptyText',\n\t])\n\n\tconst cn = local.classNames ?? {}\n\n\t// `value`, `onValueChange`, `filter`, `name`, … are not transformed here, so\n\t// they ride `rest` straight through to the underlying machine.\n\treturn (\n\t\t<Root\n\t\t\titemToString={local.itemToString}\n\t\t\titemToValue={local.itemToValue}\n\t\t\titems={local.items}\n\t\t\topenOnClick={local.openOnClick ?? true}\n\t\t\t{...rest}\n\t\t>\n\t\t\t{local.label && (\n\t\t\t\t<Combobox.Label className={cn.label}>\n\t\t\t\t\t{local.label}\n\t\t\t\t</Combobox.Label>\n\t\t\t)}\n\t\t\t<Combobox.Control className={cn.control}>\n\t\t\t\t<Input\n\t\t\t\t\tclassName={cn.input}\n\t\t\t\t\tdisabled={local.disabled}\n\t\t\t\t\tplaceholder={local.placeholder ?? 'Type to search...'}\n\t\t\t\t/>\n\t\t\t\t<Combobox.Trigger className={cn.trigger} type='button'>\n\t\t\t\t\t<ChevronIcon />\n\t\t\t\t</Combobox.Trigger>\n\t\t\t</Combobox.Control>\n\t\t\t<Combobox.Content className={cn.content}>\n\t\t\t\t<Combobox.Empty className={cn.empty}>\n\t\t\t\t\t{local.emptyText ?? 'No results found'}\n\t\t\t\t</Combobox.Empty>\n\t\t\t\t<Items>\n\t\t\t\t\t{item=> (\n\t\t\t\t\t\t<Combobox.Item className={cn.item} item={item} key={local.itemToValue?.(item) ?? item}>\n\t\t\t\t\t\t\t<Combobox.ItemText className={cn.itemText}>\n\t\t\t\t\t\t\t\t{local.itemToString?.(item) ?? String(item)}\n\t\t\t\t\t\t\t</Combobox.ItemText>\n\t\t\t\t\t\t\t<span className={cn.check}>\n\t\t\t\t\t\t\t\t<CheckIcon />\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Combobox.Item>\n\t\t\t\t\t)}\n\t\t\t\t</Items>\n\t\t\t</Combobox.Content>\n\t\t</Root>\n\t)\n}\n\nexport default FilteredSelect\n"],"mappings":";;;;;AAmBA,IAAAW,SAAAC,SAAA,eAAA;AAAA,IAAAC,SAAAD,SAAA,6LAAA;AAAA,IAAAE,QAAAF,SAAA,2LAAA;AAEA,IAAMG,UAAUC,UAAS;CACxB,OAAO,OAAOA,UAAU,aAAaA,MAAM,IAAIA;AAChD;AAIA,IAAMC,gBAAgBb,cAAc,IAAI;AAExC,IAAMc,sBAAqBC,SAAOC,OAAOD,MAAMH,SAASG,MAAME,MAAMF,IAAI;AACxE,IAAMG,uBAAsBH,SAAOC,OAAOD,MAAMI,SAASJ,MAAMK,QAAQL,IAAI;AAI3E,IAAMM,iBAAiBN,MAAMO,OAAOC,iBAAgBA,aAAaR,IAAI,EAAES,YAAY,EAAEC,SAASH,KAAK;AAEnG,IAAMI,QAAQC,QAAQ,CAAC,MAAK;CAC3B,MAAM,CAACC,OAAOC,QAAQ1B,WAAWwB,OAAO;EACvC;EAAS;EAAe;EAAgB;EAAU;EAAc;EAAsB;CAAU,CAChG;CAED,MAAMG,cAAcF,MAAME,eAAehB;CACzC,MAAMS,eAAeK,MAAML,gBAAgBL;CAC3C,MAAMa,SAASH,MAAMG,UAAUV;CAI/B,MAAMC,QA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KAAA,OACX1C,MAAM0C,eAAe;IAAmB;GAAA,CAAA,CAAA,GAAAhC,IAAA1C,SAAA2E,SAAA/B,WAAA;IAAA,IAAAyB,YAAA;KAAA,OAEzBJ,GAAGW;IAAO;IAAAC,MAAO;IAAQhC,UAAAH,IAAAmB,aAAA,CAAA,CAAA;GAAA,CAAA,CAAA,CAAA;EAAA,CAAA,CAAA;EAAAnB,IAAA1C,SAAA8E,SAAAlC,WAAA;GAAA,IAAAyB,YAAA;IAAA,OAI1BJ,GAAGc;GAAO;GAAAlC,UAAA,CAAAH,IAAA1C,SAAAgF,OAAApC,WAAA;IAAA,IAAAyB,YAAA;KAAA,OACXJ,GAAGgB;IAAK;IAAApC,gBACjCb,MAAMkD,aAAa;GAAkB,CAAA,CAAA,GAAAxC,IAAAiB,OAAAf,WAAA,EAAAC,WAGrC1B,SAAIuB,IAAA1C,SAAAmF,MAAAvC,WAAA;IAAA,IAAAyB,YAAA;KAAA,OACsBJ,GAAG9C;IAAI;IAAQA;IAAI,IAAAiE,MAAA;KAAA,OAAOpD,MAAME,cAAcf,IAAI,KAAKA;IAAI;IAAA0B,UAAA,CAAAH,IAAA1C,SAAAqF,UAAAzC,WAAA;KAAA,IAAAyB,YAAA;MAAA,OACtDJ,GAAGqB;KAAQ;KAAAzC,gBACvCb,MAAML,eAAeR,IAAI,KAAKC,OAAOD,IAAI;IAAC,CAAA,CAAA,SAAA;KAAA,MAAAoE,OAAA5E,OAAAmD,UAAA,IAAA;KAAA0B,OAAAD,YAAA7C,IAAAqB,WAAA,CAAA,CAAA,CAAA;KAAA0B,QAAAF,MAAA,mBAE3BtB,GAAGyB,KAAK;KAAA,OAAAH;IAAA,CAAA;GAAA,CAAA,CAAA,EAI1B,CAAA,CAAA,CAAA;EAAA,CAAA,CAAA;CAAA,EAAA,CAAA,CAAA;AAKN"}
|
|
1
|
+
{"version":3,"file":"FilteredSelect.js","names":["Combobox","useComboboxContext","Loop","createComputed","createContext","createEffect","createSignal","splitProps","useContext","collection","createCollection","_tmpl3","_template","_tmpl2","_tmpl","access","value","FilterContext","defaultItemToValue","item","String","id","defaultItemToString","label","name","defaultFilter","query","itemToString","toLowerCase","includes","Root","props","local","rest","itemToValue","filter","inputValue","filteredItems","q","trim","list","items","_jsx","Provider","_mergeProps","children","onInputValueChange","HighlightSingleMatch","combobox","api","open","length","highlightedValue","setHighlightValue","Input","onInput","event","getInputProps","onChange","Items","each","ChevronIcon","cloneNode","CheckIcon","FilteredSelect","cn","classNames","openOnClick","Label","className","Control","control","input","disabled","placeholder","Trigger","trigger","type","Content","content","Empty","empty","emptyText","Item","key","ItemText","itemText","_el0","_insert","_setProp","check"],"sources":["../../src/components/FilteredSelect.jsx"],"sourcesContent":["import { Combobox, useComboboxContext } from '@plastic-js/ark'\nimport {\n\tLoop, createComputed, createContext, createEffect, createSignal, splitProps, useContext,\n} from '@plastic-js/plastic'\nimport { collection as createCollection } from '@zag-js/combobox'\n\n// FilteredSelect — a filterable single-select built on the pure `Combobox`\n// primitive's underlying headless machine.\n//\n// This file owns two things:\n// 1. The filter plumbing. The headless component is \"controlled collection\"\n// only: it expects you to build a @zag-js collection yourself and narrow it\n// down as the user types. The internal <Root> keeps a query in sync with the\n// input, filters the list and feeds a reactive collection back to the\n// headless Root.\n// 2. The public API / contract. The default-exported <FilteredSelect> assembles\n// the full structure (label, control, input, trigger, content, items) and\n// exposes a flat prop API. It is intentionally style-agnostic: every visual\n// slot is themed through the `classNames` map, so the styling layer\n// only has to supply CSS.\n\nconst access = (value)=> {\n\treturn typeof value === 'function' ? value() : value\n}\n\n// Exposes the filtered items to <Items> without forcing the caller to thread\n// them through props.\nconst FilterContext = createContext(null)\n\nconst defaultItemToValue = item=> String(item?.value ?? item?.id ?? item)\nconst defaultItemToString = item=> String(item?.label ?? item?.name ?? item)\n\n// Substring match on the item's display string. Override via the `filter` prop\n// for fuzzy/score-based matching.\nconst defaultFilter = (item, query, itemToString)=> itemToString(item).toLowerCase().includes(query)\n\nconst Root = (props = {})=> {\n\tconst [local, rest] = splitProps(props, [\n\t\t'items', 'itemToValue', 'itemToString', 'filter', 'inputValue', 'onInputValueChange', 'children',\n\t])\n\n\tconst itemToValue = local.itemToValue ?? defaultItemToValue\n\tconst itemToString = local.itemToString ?? defaultItemToString\n\tconst filter = local.filter ?? defaultFilter\n\n\t// Internal query mirrors the input. We seed it from any `inputValue` the\n\t// caller passed so an initial/controlled value still filters correctly.\n\tconst query = createSignal(access(local.inputValue) ?? '')\n\n\t// Recomputes on typing and whenever the source `items` change. An empty\n\t// query shows everything; otherwise only the matches survive.\n\tconst filteredItems = createComputed(()=> {\n\t\tconst q = query().trim().toLowerCase()\n\t\tconst list = access(local.items) ?? []\n\t\treturn q ? list.filter(item=> filter(item, q, itemToString)) : list\n\t})\n\n\tconst collection = createComputed(()=> createCollection({\n\t\titems: filteredItems(),\n\t\titemToValue,\n\t\titemToString,\n\t}))\n\n\treturn (\n\t\t<FilterContext.Provider value={filteredItems}>\n\t\t\t<Combobox.Root\n\t\t\t\t{...rest}\n\t\t\t\tcollection={collection}\n\t\t\t\tinputValue={query}\n\t\t\t\tonInputValueChange={(value)=> {\n\t\t\t\t\tquery(value)\n\t\t\t\t\tlocal.onInputValueChange?.(value)\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<HighlightSingleMatch itemToValue={itemToValue} items={filteredItems} />\n\t\t\t\t{local.children}\n\t\t\t</Combobox.Root>\n\t\t</FilterContext.Provider>\n\t)\n}\n\n// When the open list narrows to a single match, pre-highlight it so the user\n// can confirm with Enter/Tab without arrowing down. We nudge the machine's own\n// (uncontrolled) highlight imperatively rather than controlling `highlightedValue`\n// — controlling it would pin the highlight in place and fight the machine, e.g.\n// blocking the highlight-clear on the next keystroke and the select-and-close on\n// Enter. We only set it; the machine still clears/moves it on input and navigation.\nconst HighlightSingleMatch = (props = {})=> {\n\tconst combobox = useComboboxContext()\n\tcreateEffect(()=> {\n\t\tconst api = combobox()\n\t\tconst list = props.items()\n\t\tif (!api.open || list.length !== 1){ return }\n\t\tconst value = props.itemToValue(list[0])\n\t\tif (api.highlightedValue !== value){ api.setHighlightValue(value) }\n\t})\n\treturn null\n}\n\n// The headless input only fires zag's INPUT.CHANGE on the native `change`\n// event — which, unlike React's onChange, fires on blur, not per keystroke. So\n// typing never reached the machine and the list never filtered. We bridge the\n// per-keystroke `input` event to zag's own onChange handler so every character\n// drives the same INPUT.CHANGE (open + filter) behaviour.\nconst Input = (props = {})=> {\n\tconst combobox = useComboboxContext()\n\treturn (\n\t\t<Combobox.Input\n\t\t\t{...props}\n\t\t\tonInput={event=> combobox().getInputProps().onChange?.(event)}\n\t\t/>\n\t)\n}\n\n// Render-prop over the filtered items. Place inside <Combobox.Content> and\n// return a <Combobox.Item> for each match. Backed by <Loop> so the list stays\n// reactive — a bare thunk returned from a component is unwrapped once and would\n// never re-filter.\nconst Items = (props = {})=> {\n\tconst items = useContext(FilterContext)\n\treturn (\n\t\t<Loop each={items ?? []}>\n\t\t\t{item=> props.children?.(item)}\n\t\t</Loop>\n\t)\n}\n\nfunction ChevronIcon(){\n\treturn (\n\t\t<svg\n\t\t\tfill='none' stroke='currentColor' strokeLinecap='round' strokeLinejoin='round'\n\t\t\tstrokeWidth='2' viewBox='0 0 24 24'\n\t\t>\n\t\t\t<polyline points='6 9 12 15 18 9' />\n\t\t</svg>\n\t)\n}\n\nfunction CheckIcon(){\n\treturn (\n\t\t<svg\n\t\t\tfill='none' stroke='currentColor' strokeLinecap='round' strokeLinejoin='round'\n\t\t\tstrokeWidth='2.5' viewBox='0 0 24 24'\n\t\t>\n\t\t\t<polyline points='20 6 9 17 4 12' />\n\t\t</svg>\n\t)\n}\n\n// Public component. `classNames` themes each slot (control/input/trigger/content/\n// empty/item/itemText/check/label); anything not split here (e.g. `filter`,\n// `name`) flows through to the filter Root.\nconst FilteredSelect = (props = {})=> {\n\tconst [local, rest] = splitProps(props, [\n\t\t'items',\n\t\t'itemToString',\n\t\t'itemToValue',\n\t\t'placeholder',\n\t\t'label',\n\t\t'openOnClick',\n\t\t'disabled',\n\t\t'classNames',\n\t\t'emptyText',\n\t])\n\n\tconst cn = local.classNames ?? {}\n\n\t// `value`, `onValueChange`, `filter`, `name`, … are not transformed here, so\n\t// they ride `rest` straight through to the underlying machine.\n\treturn (\n\t\t<Root\n\t\t\titemToString={local.itemToString}\n\t\t\titemToValue={local.itemToValue}\n\t\t\titems={local.items}\n\t\t\topenOnClick={local.openOnClick ?? true}\n\t\t\t{...rest}\n\t\t>\n\t\t\t{local.label && (\n\t\t\t\t<Combobox.Label className={cn.label}>\n\t\t\t\t\t{local.label}\n\t\t\t\t</Combobox.Label>\n\t\t\t)}\n\t\t\t<Combobox.Control className={cn.control}>\n\t\t\t\t<Input\n\t\t\t\t\tclassName={cn.input}\n\t\t\t\t\tdisabled={local.disabled}\n\t\t\t\t\tplaceholder={local.placeholder ?? 'Type to search...'}\n\t\t\t\t/>\n\t\t\t\t<Combobox.Trigger className={cn.trigger} type='button'>\n\t\t\t\t\t<ChevronIcon />\n\t\t\t\t</Combobox.Trigger>\n\t\t\t</Combobox.Control>\n\t\t\t<Combobox.Content className={cn.content}>\n\t\t\t\t<Combobox.Empty className={cn.empty}>\n\t\t\t\t\t{local.emptyText ?? 'No results found'}\n\t\t\t\t</Combobox.Empty>\n\t\t\t\t<Items>\n\t\t\t\t\t{item=> (\n\t\t\t\t\t\t<Combobox.Item className={cn.item} item={item} key={local.itemToValue?.(item) ?? item}>\n\t\t\t\t\t\t\t<Combobox.ItemText className={cn.itemText}>\n\t\t\t\t\t\t\t\t{local.itemToString?.(item) ?? String(item)}\n\t\t\t\t\t\t\t</Combobox.ItemText>\n\t\t\t\t\t\t\t<span className={cn.check}>\n\t\t\t\t\t\t\t\t<CheckIcon />\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Combobox.Item>\n\t\t\t\t\t)}\n\t\t\t\t</Items>\n\t\t\t</Combobox.Content>\n\t\t</Root>\n\t)\n}\n\nexport default FilteredSelect\n"],"mappings":";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AAC,WAGrC1B,SAAIuB,IAAA1C,SAAAmF,MAAAvC,WAAA;IAAA,IAAAyB,YAAA;KAAA,OACsBJ,GAAG9C;IAAI;IAAQA;IAAI,IAAAiE,MAAA;KAAA,OAAOpD,MAAME,cAAcf,IAAI,KAAKA;IAAI;IAAA0B,UAAA,CAAAH,IAAA1C,SAAAqF,UAAAzC,WAAA;KAAA,IAAAyB,YAAA;MAAA,OACtDJ,GAAGqB;KAAQ;KAAAzC,gBACvCb,MAAML,eAAeR,IAAI,KAAKC,OAAOD,IAAI;IAAC,CAAA,CAAA,SAAA;KAAA,MAAAoE,OAAA5E,OAAAmD,UAAA,IAAA;KAAA0B,OAAAD,YAAA7C,IAAAqB,WAAA,CAAA,CAAA,CAAA;KAAA0B,QAAAF,MAAA,mBAE3BtB,GAAGyB,KAAK;KAAA,OAAAH;IAAA,CAAA;GAAA,CAAA,CAAA,EAI1B,CAAA,CAAA,CAAA;EAAA,CAAA,CAAA;CAAA,EAAA,CAAA,CAAA;AAKN"}
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,6 @@ import HoverCard_default from "./components/HoverCard.js";
|
|
|
23
23
|
import Listbox_default from "./components/Listbox.js";
|
|
24
24
|
import Menu_default from "./components/Menu.js";
|
|
25
25
|
import MoneyInput from "./components/MoneyInput.js";
|
|
26
|
-
import MyFilteredSelect from "./components/MyFilteredSelect.js";
|
|
27
26
|
import NumberInput_default from "./components/NumberInput.js";
|
|
28
27
|
import Pagination_default from "./components/Pagination.js";
|
|
29
28
|
import Popover_default from "./components/Popover.js";
|
|
@@ -48,4 +47,4 @@ import ToggleGroup_default from "./components/ToggleGroup.js";
|
|
|
48
47
|
import Tooltip_default from "./components/Tooltip.js";
|
|
49
48
|
import Tour_default from "./components/Tour.js";
|
|
50
49
|
import TreeView_default from "./components/TreeView.js";
|
|
51
|
-
export { Accordion_default as Accordion, Avatar_default as Avatar, CardNumberInput, Carousel_default as Carousel, Checkbox_default as Checkbox, Clipboard_default as Clipboard, Collapsible_default as Collapsible, ColorPicker_default as ColorPicker, Combobox_default as Combobox, ConfirmDialog, DateInput_default as DateInput, DatePicker_default as DatePicker, Dialog_default as Dialog, Drawer_default as Drawer, Field_default as Field, Fieldset_default as Fieldset, FileUpload_default as FileUpload, FilteredSelect, FocusTrap_default as FocusTrap, HoverCard_default as HoverCard, Icon, Listbox_default as Listbox, Menu_default as Menu, MoneyInput,
|
|
50
|
+
export { Accordion_default as Accordion, Avatar_default as Avatar, CardNumberInput, Carousel_default as Carousel, Checkbox_default as Checkbox, Clipboard_default as Clipboard, Collapsible_default as Collapsible, ColorPicker_default as ColorPicker, Combobox_default as Combobox, ConfirmDialog, DateInput_default as DateInput, DatePicker_default as DatePicker, Dialog_default as Dialog, Drawer_default as Drawer, Field_default as Field, Fieldset_default as Fieldset, FileUpload_default as FileUpload, FilteredSelect, FocusTrap_default as FocusTrap, HoverCard_default as HoverCard, Icon, Listbox_default as Listbox, Menu_default as Menu, MoneyInput, NumberInput_default as NumberInput, Pagination_default as Pagination, Popover_default as Popover, Portal_default as Portal, Presence_default as Presence, Progress_default as Progress, RadioGroup_default as RadioGroup, RatingGroup_default as RatingGroup, SearchInput, Select_default as Select, SignaturePad_default as SignaturePad, Skeleton, Slider_default as Slider, Splitter_default as Splitter, Steps_default as Steps, SwipeReveal, Switch_default as Switch, Tabs_default as Tabs, TagsInput_default as TagsInput, Toast_default as Toast, Toggle_default as Toggle, ToggleGroup_default as ToggleGroup, Tooltip_default as Tooltip, Tour_default as Tour, TreeView_default as TreeView };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plastic-js/tsumiki",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A UI component library for Plastic JS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "tigre",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"@zag-js/combobox": "1.40.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@zag-js/combobox": "1.40.0",
|
|
50
49
|
"@babel/core": "^7.29.7",
|
|
51
50
|
"@plastic-js/babel-preset-plastic": "^0.1.9",
|
|
51
|
+
"@zag-js/combobox": "1.40.0",
|
|
52
52
|
"puppeteer-core": "^25.1.0",
|
|
53
53
|
"vite": "^8.0.15"
|
|
54
54
|
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import FilteredSelect from "./FilteredSelect.js";
|
|
2
|
-
import { jsx, mergeProps } from "@plastic-js/plastic/jsx-runtime";
|
|
3
|
-
import { css } from "@emotion/css";
|
|
4
|
-
//#region src/components/MyFilteredSelect.jsx
|
|
5
|
-
var classNames = {
|
|
6
|
-
control: css({
|
|
7
|
-
position: "relative",
|
|
8
|
-
display: "flex",
|
|
9
|
-
alignItems: "center",
|
|
10
|
-
width: "100%",
|
|
11
|
-
height: "46px",
|
|
12
|
-
background: "var(--surface)",
|
|
13
|
-
border: "1px solid var(--border)",
|
|
14
|
-
borderRadius: "10px",
|
|
15
|
-
transition: "border-color 150ms ease",
|
|
16
|
-
"&:focus-within": { borderColor: "var(--accent)" }
|
|
17
|
-
}),
|
|
18
|
-
input: css({
|
|
19
|
-
flex: 1,
|
|
20
|
-
minWidth: 0,
|
|
21
|
-
height: "100%",
|
|
22
|
-
background: "transparent",
|
|
23
|
-
border: "none",
|
|
24
|
-
outline: "none",
|
|
25
|
-
padding: "0 0 0 14px",
|
|
26
|
-
color: "var(--ink)",
|
|
27
|
-
fontSize: "15px",
|
|
28
|
-
fontFamily: "inherit",
|
|
29
|
-
"&::placeholder": { color: "var(--muted)" }
|
|
30
|
-
}),
|
|
31
|
-
trigger: css({
|
|
32
|
-
flexShrink: 0,
|
|
33
|
-
width: "36px",
|
|
34
|
-
height: "100%",
|
|
35
|
-
display: "flex",
|
|
36
|
-
alignItems: "center",
|
|
37
|
-
justifyContent: "center",
|
|
38
|
-
background: "transparent",
|
|
39
|
-
border: "none",
|
|
40
|
-
color: "var(--muted)",
|
|
41
|
-
cursor: "pointer",
|
|
42
|
-
padding: 0,
|
|
43
|
-
transition: "transform 180ms ease, color 180ms ease",
|
|
44
|
-
"&[data-state=\"open\"]": {
|
|
45
|
-
transform: "rotate(180deg)",
|
|
46
|
-
color: "var(--accent)"
|
|
47
|
-
},
|
|
48
|
-
"& svg": {
|
|
49
|
-
width: "18px",
|
|
50
|
-
height: "18px"
|
|
51
|
-
}
|
|
52
|
-
}),
|
|
53
|
-
content: css({
|
|
54
|
-
background: "var(--surface)",
|
|
55
|
-
border: "1px solid var(--border)",
|
|
56
|
-
borderRadius: "12px",
|
|
57
|
-
padding: "6px",
|
|
58
|
-
boxShadow: "0 8px 32px rgba(0,0,0,0.5)",
|
|
59
|
-
maxHeight: "280px",
|
|
60
|
-
overflowY: "auto",
|
|
61
|
-
minWidth: "220px",
|
|
62
|
-
zIndex: 9999,
|
|
63
|
-
marginTop: "4px",
|
|
64
|
-
"&[hidden]": { display: "none" },
|
|
65
|
-
"&::-webkit-scrollbar": { width: "4px" },
|
|
66
|
-
"&::-webkit-scrollbar-track": { background: "transparent" },
|
|
67
|
-
"&::-webkit-scrollbar-thumb": {
|
|
68
|
-
background: "var(--border)",
|
|
69
|
-
borderRadius: "4px"
|
|
70
|
-
}
|
|
71
|
-
}),
|
|
72
|
-
item: css({
|
|
73
|
-
display: "flex",
|
|
74
|
-
alignItems: "center",
|
|
75
|
-
gap: "10px",
|
|
76
|
-
padding: "10px 12px",
|
|
77
|
-
borderRadius: "8px",
|
|
78
|
-
cursor: "pointer",
|
|
79
|
-
color: "var(--ink)",
|
|
80
|
-
fontSize: "14px",
|
|
81
|
-
transition: "background 120ms ease",
|
|
82
|
-
"&[data-highlighted]": { background: "var(--surface-2)" },
|
|
83
|
-
"&[data-selected]": {
|
|
84
|
-
color: "var(--accent)",
|
|
85
|
-
background: "rgba(47, 123, 255, 0.1)"
|
|
86
|
-
}
|
|
87
|
-
}),
|
|
88
|
-
itemText: css({
|
|
89
|
-
flex: 1,
|
|
90
|
-
minWidth: 0
|
|
91
|
-
}),
|
|
92
|
-
check: css({
|
|
93
|
-
flexShrink: 0,
|
|
94
|
-
width: "18px",
|
|
95
|
-
height: "18px",
|
|
96
|
-
color: "var(--accent)",
|
|
97
|
-
opacity: 0,
|
|
98
|
-
transition: "opacity 120ms ease",
|
|
99
|
-
"[data-selected] &": { opacity: 1 }
|
|
100
|
-
}),
|
|
101
|
-
empty: css({
|
|
102
|
-
padding: "24px 12px",
|
|
103
|
-
textAlign: "center",
|
|
104
|
-
color: "var(--muted)",
|
|
105
|
-
fontSize: "14px"
|
|
106
|
-
}),
|
|
107
|
-
label: css({
|
|
108
|
-
display: "block",
|
|
109
|
-
fontSize: "13px",
|
|
110
|
-
fontWeight: 600,
|
|
111
|
-
color: "var(--muted)",
|
|
112
|
-
marginBottom: "6px"
|
|
113
|
-
})
|
|
114
|
-
};
|
|
115
|
-
var MyFilteredSelect = (props = {}) => jsx(FilteredSelect, mergeProps({ classNames }, props));
|
|
116
|
-
//#endregion
|
|
117
|
-
export { MyFilteredSelect as default };
|
|
118
|
-
|
|
119
|
-
//# sourceMappingURL=MyFilteredSelect.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MyFilteredSelect.js","names":["css","FilteredSelect","controlClass","position","display","alignItems","width","height","background","border","borderRadius","transition","borderColor","inputClass","flex","minWidth","outline","padding","color","fontSize","fontFamily","triggerClass","flexShrink","justifyContent","cursor","transform","contentClass","boxShadow","maxHeight","overflowY","zIndex","marginTop","itemClass","gap","itemTextClass","checkClass","opacity","emptyClass","textAlign","labelClass","fontWeight","marginBottom","classNames","control","input","trigger","content","item","itemText","check","empty","label","MyFilteredSelect","props","_jsx","_mergeProps"],"sources":["../../src/components/MyFilteredSelect.jsx"],"sourcesContent":["import { css } from '@emotion/css'\nimport FilteredSelect from './FilteredSelect.jsx'\n\n// MyFilteredSelect — the project's themed FilteredSelect. It owns nothing but\n// style: it supplies a `classNames` slot map to FilteredSelect, which holds all\n// the structure, behaviour and the public API/contract.\n\nconst controlClass = css({\n\tposition: 'relative',\n\tdisplay: 'flex',\n\talignItems: 'center',\n\twidth: '100%',\n\theight: '46px',\n\tbackground: 'var(--surface)',\n\tborder: '1px solid var(--border)',\n\tborderRadius: '10px',\n\ttransition: 'border-color 150ms ease',\n\t'&:focus-within': {\n\t\tborderColor: 'var(--accent)',\n\t},\n})\n\nconst inputClass = css({\n\tflex: 1,\n\tminWidth: 0,\n\theight: '100%',\n\tbackground: 'transparent',\n\tborder: 'none',\n\toutline: 'none',\n\tpadding: '0 0 0 14px',\n\tcolor: 'var(--ink)',\n\tfontSize: '15px',\n\tfontFamily: 'inherit',\n\t'&::placeholder': { color: 'var(--muted)' },\n})\n\nconst triggerClass = css({\n\tflexShrink: 0,\n\twidth: '36px',\n\theight: '100%',\n\tdisplay: 'flex',\n\talignItems: 'center',\n\tjustifyContent: 'center',\n\tbackground: 'transparent',\n\tborder: 'none',\n\tcolor: 'var(--muted)',\n\tcursor: 'pointer',\n\tpadding: 0,\n\ttransition: 'transform 180ms ease, color 180ms ease',\n\t'&[data-state=\"open\"]': {\n\t\ttransform: 'rotate(180deg)',\n\t\tcolor: 'var(--accent)',\n\t},\n\t'& svg': { width: '18px', height: '18px' },\n})\n\nconst contentClass = css({\n\tbackground: 'var(--surface)',\n\tborder: '1px solid var(--border)',\n\tborderRadius: '12px',\n\tpadding: '6px',\n\tboxShadow: '0 8px 32px rgba(0,0,0,0.5)',\n\tmaxHeight: '280px',\n\toverflowY: 'auto',\n\tminWidth: '220px',\n\tzIndex: 9999,\n\tmarginTop: '4px',\n\t'&[hidden]': { display: 'none' },\n\t'&::-webkit-scrollbar': { width: '4px' },\n\t'&::-webkit-scrollbar-track': { background: 'transparent' },\n\t'&::-webkit-scrollbar-thumb': {\n\t\tbackground: 'var(--border)',\n\t\tborderRadius: '4px',\n\t},\n})\n\nconst itemClass = css({\n\tdisplay: 'flex',\n\talignItems: 'center',\n\tgap: '10px',\n\tpadding: '10px 12px',\n\tborderRadius: '8px',\n\tcursor: 'pointer',\n\tcolor: 'var(--ink)',\n\tfontSize: '14px',\n\ttransition: 'background 120ms ease',\n\t'&[data-highlighted]': {\n\t\tbackground: 'var(--surface-2)',\n\t},\n\t'&[data-selected]': {\n\t\tcolor: 'var(--accent)',\n\t\tbackground: 'rgba(47, 123, 255, 0.1)',\n\t},\n})\n\nconst itemTextClass = css({\n\tflex: 1,\n\tminWidth: 0,\n})\n\nconst checkClass = css({\n\tflexShrink: 0,\n\twidth: '18px',\n\theight: '18px',\n\tcolor: 'var(--accent)',\n\topacity: 0,\n\ttransition: 'opacity 120ms ease',\n\t'[data-selected] &': { opacity: 1 },\n})\n\nconst emptyClass = css({\n\tpadding: '24px 12px',\n\ttextAlign: 'center',\n\tcolor: 'var(--muted)',\n\tfontSize: '14px',\n})\n\nconst labelClass = css({\n\tdisplay: 'block',\n\tfontSize: '13px',\n\tfontWeight: 600,\n\tcolor: 'var(--muted)',\n\tmarginBottom: '6px',\n})\n\nconst classNames = {\n\tcontrol: controlClass,\n\tinput: inputClass,\n\ttrigger: triggerClass,\n\tcontent: contentClass,\n\titem: itemClass,\n\titemText: itemTextClass,\n\tcheck: checkClass,\n\tempty: emptyClass,\n\tlabel: labelClass,\n}\n\nconst MyFilteredSelect = (props = {})=> <FilteredSelect classNames={classNames} {...props} />\n\nexport default MyFilteredSelect\n"],"mappings":";;;;AA6HA,IAAM0C,aAAa;CAClBC,SAvHoB3C,IAAI;EACxBG,UAAU;EACVC,SAAS;EACTC,YAAY;EACZC,OAAO;EACPC,QAAQ;EACRC,YAAY;EACZC,QAAQ;EACRC,cAAc;EACdC,YAAY;EACZ,kBAAkB,EACjBC,aAAa,gBACd;CACD,CA0GUV;CACT0C,OAzGkB5C,IAAI;EACtBc,MAAM;EACNC,UAAU;EACVR,QAAQ;EACRC,YAAY;EACZC,QAAQ;EACRO,SAAS;EACTC,SAAS;EACTC,OAAO;EAC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