@phila/phila-ui-filter-panel 0.1.0-beta.2 → 1.0.0-beta.4
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/FilterPanel.vue.d.ts +1 -0
- package/dist/FilterPanel.vue.d.ts.map +1 -1
- package/dist/FilterPanelSection.vue.d.ts +3 -3
- package/dist/FilterPanelSection.vue.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +107 -92
- package/package.json +6 -6
|
@@ -11,6 +11,7 @@ declare const _default: import('vue').DefineComponent<FilterPanelProps, {}, {},
|
|
|
11
11
|
title: string;
|
|
12
12
|
searchable: boolean;
|
|
13
13
|
searchPlaceholder: string;
|
|
14
|
+
showActions: boolean;
|
|
14
15
|
applyText: string;
|
|
15
16
|
resetText: string;
|
|
16
17
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterPanel.vue.d.ts","sourceRoot":"","sources":["../src/FilterPanel.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilterPanel.vue.d.ts","sourceRoot":"","sources":["../src/FilterPanel.vue"],"names":[],"mappings":"AAgMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;;AAgShD,wBASG"}
|
|
@@ -2,14 +2,14 @@ import { FilterDefinition } from '@phila/phila-ui-core';
|
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
filter: FilterDefinition;
|
|
4
4
|
collapsed: boolean;
|
|
5
|
-
modelValue:
|
|
5
|
+
modelValue: boolean | Record<string, boolean> | undefined;
|
|
6
6
|
};
|
|
7
7
|
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
8
8
|
toggle: () => any;
|
|
9
|
-
"update:modelValue": (value: string
|
|
9
|
+
"update:modelValue": (value: Record<string, boolean>) => any;
|
|
10
10
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
11
11
|
onToggle?: (() => any) | undefined;
|
|
12
|
-
"onUpdate:modelValue"?: ((value: string
|
|
12
|
+
"onUpdate:modelValue"?: ((value: Record<string, boolean>) => any) | undefined;
|
|
13
13
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLElement>;
|
|
14
14
|
export default _default;
|
|
15
15
|
//# sourceMappingURL=FilterPanelSection.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterPanelSection.vue.d.ts","sourceRoot":"","sources":["../src/FilterPanelSection.vue"],"names":[],"mappings":"AA8FA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"FilterPanelSection.vue.d.ts","sourceRoot":"","sources":["../src/FilterPanelSection.vue"],"names":[],"mappings":"AA8FA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC3D,CAAC;;;;;;;;AAiJF,wBAQG"}
|
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.phila-filter-panel__section[data-v-
|
|
1
|
+
.phila-filter-panel__section[data-v-54c0ee8c]{border-bottom:1px solid var(--Schemes-Border, #ccc);padding:.75rem 0}.phila-filter-panel__section-toggle[data-v-54c0ee8c]{display:flex;width:100%;align-items:center;justify-content:space-between;background:none;border:none;cursor:pointer;font-size:inherit;font-weight:700}.phila-filter-panel__section-toggle .is-collapsed[data-v-54c0ee8c]{transform:rotate(-90deg)}.phila-filter-panel__section-body[data-v-54c0ee8c]{padding-top:.75rem}.phila-filter-panel__section-body[data-v-54c0ee8c] .labels-container{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.phila-filter-panel[data-v-ed0fc96d]{display:flex;flex-direction:column;height:100%;background:#fff;overflow:hidden;box-sizing:border-box}.phila-filter-panel__header[data-v-ed0fc96d]{display:flex;align-items:center;justify-content:space-between;flex-shrink:0;padding:1.5rem 1.5rem .75rem}.phila-filter-panel__body[data-v-ed0fc96d]{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:1rem;padding:0 1.5rem 1.5rem}.phila-filter-panel__title[data-v-ed0fc96d]{margin:0;font-size:1.25rem;font-weight:700}.phila-filter-panel__close[data-v-ed0fc96d]{background:none;border:none;cursor:pointer;font-size:1.25rem;line-height:1}.phila-filter-panel__sections[data-v-ed0fc96d]{display:flex;flex-direction:column}.phila-filter-panel__footer[data-v-ed0fc96d]{display:flex;gap:.75rem;flex-shrink:0;padding:.75rem 1.5rem 1.5rem;border-top:1px solid var(--Schemes-Border, #e5e7eb)}.phila-filter-panel__footer[data-v-ed0fc96d]>*{flex:1}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { default as FilterPanel } from './FilterPanel.vue';
|
|
|
3
3
|
export interface FilterPanelProps extends BaseProps {
|
|
4
4
|
/** Filters to render. Only filters with a non-empty `choices` array become sections. */
|
|
5
5
|
filters: FilterDefinition[];
|
|
6
|
-
/**
|
|
6
|
+
/** Selected values (v-model). Each filter is a full map of choice value → selected. */
|
|
7
7
|
modelValue?: FilterValues;
|
|
8
8
|
/** Header title. */
|
|
9
9
|
title?: string;
|
|
@@ -11,6 +11,8 @@ export interface FilterPanelProps extends BaseProps {
|
|
|
11
11
|
searchable?: boolean;
|
|
12
12
|
/** Placeholder for the search box. */
|
|
13
13
|
searchPlaceholder?: string;
|
|
14
|
+
/** Show Reset/Apply buttons (draft + commit on Apply). Default false = live apply. */
|
|
15
|
+
showActions?: boolean;
|
|
14
16
|
/** Apply button label (an active-selection count is appended as " (N)"). */
|
|
15
17
|
applyText?: string;
|
|
16
18
|
/** Reset button label. */
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,wFAAwF;IACxF,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,wFAAwF;IACxF,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,uFAAuF;IACvF,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sFAAsF;IACtF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const e=require("vue"),h=require("@phila/phila-ui-core"),S=require("@phila/phila-ui-search"),V=require("@phila/phila-ui-button"),k=require("@phila/phila-ui-core/icons"),w=require("@phila/phila-ui-checkbox"),E=require("@phila/phila-ui-radio"),A={class:"phila-filter-panel__section"},P={class:"phila-filter-panel__section-body"},U=e.defineComponent({__name:"FilterPanelSection",props:{filter:{},collapsed:{type:Boolean},modelValue:{type:[Boolean,Object]}},emits:["toggle","update:modelValue"],setup(o,{emit:p}){const n=o,c=p,r=e.computed(()=>n.filter.choices??[]),d=e.computed(()=>n.modelValue&&typeof n.modelValue=="object"?n.modelValue:{});return(m,i)=>(e.openBlock(),e.createElementBlock("section",A,[e.createElementVNode("button",{type:"button",class:"phila-filter-panel__section-toggle",onClick:i[0]||(i[0]=s=>c("toggle"))},[e.createElementVNode("span",null,e.toDisplayString(o.filter.label),1),e.createVNode(e.unref(h.Icon),{icon:e.unref(k.IconChevronDown),size:"xxsmall",inline:"",decorative:"",class:e.normalizeClass({"is-collapsed":o.collapsed})},null,8,["icon","class"])]),e.withDirectives(e.createElementVNode("div",P,[o.filter.multiple?(e.openBlock(),e.createBlock(e.unref(w.CheckboxGroup),{key:0,"group-label":o.filter.label,choices:r.value,"model-value":d.value,"onUpdate:modelValue":i[1]||(i[1]=s=>c("update:modelValue",s))},null,8,["group-label","choices","model-value"])):(e.openBlock(),e.createBlock(e.unref(E.RadioGroup),{key:1,"group-label":o.filter.label,choices:r.value,"model-value":d.value,"onUpdate:modelValue":i[2]||(i[2]=s=>c("update:modelValue",s))},null,8,["group-label","choices","model-value"]))],512),[[e.vShow,!o.collapsed]])]))}}),g=(o,p)=>{const n=o.__vccOpts||o;for(const[c,r]of p)n[c]=r;return n},T=g(U,[["__scopeId","data-v-54c0ee8c"]]),q={class:"phila-filter-panel__header"},D={class:"phila-filter-panel__title"},F={class:"phila-filter-panel__body"},$={class:"phila-filter-panel__sections"},j={key:0,class:"phila-filter-panel__footer"},I=e.defineComponent({__name:"FilterPanel",props:{filters:{},modelValue:{default:()=>({})},title:{default:"All Filters"},searchable:{type:Boolean,default:!0},searchPlaceholder:{default:"Search"},showActions:{type:Boolean,default:!1},applyText:{default:"Apply"},resetText:{default:"Reset"},className:{}},emits:["update:modelValue","close"],setup(o,{emit:p}){const n=o,c=p,r=e.ref({}),d=e.ref(""),m=e.ref({});function i(t){const a={};for(const l of n.filters){const u=t[l.key];if(Array.isArray(l.choices)&&l.choices.length>0){const N=u&&typeof u=="object"?u:{};a[l.key]=Object.fromEntries(l.choices.map(y=>[y.value,!!N[y.value]]))}else a[l.key]=u===!0}return a}const s=e.computed(()=>n.showActions?r.value:n.modelValue);e.onMounted(()=>{const t=i(n.modelValue);r.value=t,c("update:modelValue",t)});const v=e.computed(()=>n.filters.filter(t=>Array.isArray(t.choices)&&t.choices.length>0)),b=e.computed(()=>{const t=d.value.trim().toLowerCase();return t?v.value.filter(a=>a.label.toLowerCase().includes(t)||(a.choices??[]).some(l=>l.text.toLowerCase().includes(t))):v.value}),f=e.computed(()=>v.value.reduce((t,a)=>{if(a.excludeFromCount)return t;const l=s.value[a.key];return t+(l&&typeof l=="object"?Object.values(l).filter(Boolean).length:l?1:0)},0));function B(t,a){const l=i({...s.value,[t]:a});n.showActions?r.value=l:c("update:modelValue",l)}function C(t){m.value={...m.value,[t]:!m.value[t]}}function _(){r.value=i({})}function x(){c("update:modelValue",i(r.value)),c("close")}return(t,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(h.cn)("phila-filter-panel",n.className))},[e.createElementVNode("header",q,[e.createElementVNode("h2",D,e.toDisplayString(o.title)+e.toDisplayString(f.value?` (${f.value})`:""),1),e.createElementVNode("button",{type:"button",class:"phila-filter-panel__close","aria-label":"Close filters",onClick:a[0]||(a[0]=l=>c("close"))},[e.createVNode(e.unref(h.Icon),{icon:e.unref(k.IconClose),size:"small",inline:"",decorative:""},null,8,["icon"])])]),e.createElementVNode("div",F,[o.searchable?(e.openBlock(),e.createBlock(e.unref(S.Search),{key:0,modelValue:d.value,"onUpdate:modelValue":a[1]||(a[1]=l=>d.value=l),placeholder:o.searchPlaceholder},null,8,["modelValue","placeholder"])):e.createCommentVNode("",!0),e.createElementVNode("div",$,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,l=>(e.openBlock(),e.createBlock(T,{key:l.key,filter:l,collapsed:!!m.value[l.key],"model-value":s.value[l.key],onToggle:u=>C(l.key),"onUpdate:modelValue":u=>B(l.key,u)},null,8,["filter","collapsed","model-value","onToggle","onUpdate:modelValue"]))),128))])]),o.showActions?(e.openBlock(),e.createElementBlock("footer",j,[e.createVNode(e.unref(V.PhilaButton),{variant:"secondary",onClick:_},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.resetText),1)]),_:1}),e.createVNode(e.unref(V.PhilaButton),{variant:"primary",onClick:x},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.applyText)+e.toDisplayString(f.value?` (${f.value})`:""),1)]),_:1})])):e.createCommentVNode("",!0)],2))}}),z=g(I,[["__scopeId","data-v-ed0fc96d"]]);exports.FilterPanel=z;
|
package/dist/index.mjs
CHANGED
|
@@ -1,60 +1,65 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Icon as
|
|
3
|
-
import { Search as
|
|
1
|
+
import { defineComponent as $, computed as v, createElementBlock as b, openBlock as u, createElementVNode as d, withDirectives as O, createVNode as g, toDisplayString as f, unref as c, normalizeClass as F, createBlock as k, vShow as D, ref as C, onMounted as E, createCommentVNode as w, Fragment as G, renderList as R, withCtx as A, createTextVNode as B } from "vue";
|
|
2
|
+
import { Icon as P, cn as q } from "@phila/phila-ui-core";
|
|
3
|
+
import { Search as M } from "@phila/phila-ui-search";
|
|
4
4
|
import { PhilaButton as S } from "@phila/phila-ui-button";
|
|
5
|
-
import { IconChevronDown as
|
|
6
|
-
import { CheckboxGroup as
|
|
7
|
-
import { RadioGroup as
|
|
8
|
-
import './index.css';const
|
|
5
|
+
import { IconChevronDown as H, IconClose as J } from "@phila/phila-ui-core/icons";
|
|
6
|
+
import { CheckboxGroup as K } from "@phila/phila-ui-checkbox";
|
|
7
|
+
import { RadioGroup as Q } from "@phila/phila-ui-radio";
|
|
8
|
+
import './index.css';const W = { class: "phila-filter-panel__section" }, X = { class: "phila-filter-panel__section-body" }, Y = /* @__PURE__ */ $({
|
|
9
9
|
__name: "FilterPanelSection",
|
|
10
10
|
props: {
|
|
11
11
|
filter: {},
|
|
12
12
|
collapsed: { type: Boolean },
|
|
13
|
-
modelValue: { type: [
|
|
13
|
+
modelValue: { type: [Boolean, Object] }
|
|
14
14
|
},
|
|
15
15
|
emits: ["toggle", "update:modelValue"],
|
|
16
|
-
setup(t, { emit:
|
|
17
|
-
const a = t,
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
setup(t, { emit: h }) {
|
|
17
|
+
const a = t, n = h, i = v(() => a.filter.choices ?? []), p = v(
|
|
18
|
+
() => a.modelValue && typeof a.modelValue == "object" ? a.modelValue : {}
|
|
19
|
+
);
|
|
20
|
+
return (y, s) => (u(), b("section", W, [
|
|
21
|
+
d("button", {
|
|
20
22
|
type: "button",
|
|
21
23
|
class: "phila-filter-panel__section-toggle",
|
|
22
|
-
onClick:
|
|
24
|
+
onClick: s[0] || (s[0] = (r) => n("toggle"))
|
|
23
25
|
}, [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
icon:
|
|
26
|
+
d("span", null, f(t.filter.label), 1),
|
|
27
|
+
g(c(P), {
|
|
28
|
+
icon: c(H),
|
|
27
29
|
size: "xxsmall",
|
|
28
30
|
inline: "",
|
|
29
31
|
decorative: "",
|
|
30
|
-
class:
|
|
32
|
+
class: F({ "is-collapsed": t.collapsed })
|
|
31
33
|
}, null, 8, ["icon", "class"])
|
|
32
34
|
]),
|
|
33
|
-
|
|
34
|
-
t.filter.multiple ? (u(),
|
|
35
|
+
O(d("div", X, [
|
|
36
|
+
t.filter.multiple ? (u(), k(c(K), {
|
|
35
37
|
key: 0,
|
|
36
38
|
"group-label": t.filter.label,
|
|
37
|
-
choices:
|
|
38
|
-
"model-value":
|
|
39
|
-
"onUpdate:modelValue":
|
|
40
|
-
}, null, 8, ["group-label", "choices", "model-value"])) : (u(),
|
|
39
|
+
choices: i.value,
|
|
40
|
+
"model-value": p.value,
|
|
41
|
+
"onUpdate:modelValue": s[1] || (s[1] = (r) => n("update:modelValue", r))
|
|
42
|
+
}, null, 8, ["group-label", "choices", "model-value"])) : (u(), k(c(Q), {
|
|
41
43
|
key: 1,
|
|
42
44
|
"group-label": t.filter.label,
|
|
43
|
-
choices:
|
|
44
|
-
"model-value":
|
|
45
|
-
"onUpdate:modelValue":
|
|
45
|
+
choices: i.value,
|
|
46
|
+
"model-value": p.value,
|
|
47
|
+
"onUpdate:modelValue": s[2] || (s[2] = (r) => n("update:modelValue", r))
|
|
46
48
|
}, null, 8, ["group-label", "choices", "model-value"]))
|
|
47
49
|
], 512), [
|
|
48
|
-
[
|
|
50
|
+
[D, !t.collapsed]
|
|
49
51
|
])
|
|
50
52
|
]));
|
|
51
53
|
}
|
|
52
|
-
}),
|
|
54
|
+
}), T = (t, h) => {
|
|
53
55
|
const a = t.__vccOpts || t;
|
|
54
|
-
for (const [
|
|
55
|
-
a[
|
|
56
|
+
for (const [n, i] of h)
|
|
57
|
+
a[n] = i;
|
|
56
58
|
return a;
|
|
57
|
-
},
|
|
59
|
+
}, Z = /* @__PURE__ */ T(Y, [["__scopeId", "data-v-54c0ee8c"]]), ee = { class: "phila-filter-panel__header" }, le = { class: "phila-filter-panel__title" }, te = { class: "phila-filter-panel__body" }, oe = { class: "phila-filter-panel__sections" }, ae = {
|
|
60
|
+
key: 0,
|
|
61
|
+
class: "phila-filter-panel__footer"
|
|
62
|
+
}, ne = /* @__PURE__ */ $({
|
|
58
63
|
__name: "FilterPanel",
|
|
59
64
|
props: {
|
|
60
65
|
filters: {},
|
|
@@ -62,106 +67,116 @@ import './index.css';const J = { class: "phila-filter-panel__section" }, K = { c
|
|
|
62
67
|
title: { default: "All Filters" },
|
|
63
68
|
searchable: { type: Boolean, default: !0 },
|
|
64
69
|
searchPlaceholder: { default: "Search" },
|
|
70
|
+
showActions: { type: Boolean, default: !1 },
|
|
65
71
|
applyText: { default: "Apply" },
|
|
66
72
|
resetText: { default: "Reset" },
|
|
67
73
|
className: {}
|
|
68
74
|
},
|
|
69
75
|
emits: ["update:modelValue", "close"],
|
|
70
|
-
setup(t, { emit:
|
|
71
|
-
const a = t,
|
|
72
|
-
function
|
|
76
|
+
setup(t, { emit: h }) {
|
|
77
|
+
const a = t, n = h, i = C({}), p = C(""), y = C({});
|
|
78
|
+
function s(l) {
|
|
73
79
|
const o = {};
|
|
74
|
-
for (const
|
|
75
|
-
const
|
|
76
|
-
|
|
80
|
+
for (const e of a.filters) {
|
|
81
|
+
const m = l[e.key];
|
|
82
|
+
if (Array.isArray(e.choices) && e.choices.length > 0) {
|
|
83
|
+
const L = m && typeof m == "object" ? m : {};
|
|
84
|
+
o[e.key] = Object.fromEntries(e.choices.map((x) => [x.value, !!L[x.value]]));
|
|
85
|
+
} else
|
|
86
|
+
o[e.key] = m === !0;
|
|
77
87
|
}
|
|
78
88
|
return o;
|
|
79
89
|
}
|
|
80
|
-
|
|
81
|
-
|
|
90
|
+
const r = v(() => a.showActions ? i.value : a.modelValue);
|
|
91
|
+
E(() => {
|
|
92
|
+
const l = s(a.modelValue);
|
|
93
|
+
i.value = l, n("update:modelValue", l);
|
|
82
94
|
});
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
return
|
|
86
|
-
(o) => o.label.toLowerCase().includes(
|
|
87
|
-
) :
|
|
88
|
-
}),
|
|
89
|
-
() =>
|
|
90
|
-
if (o.excludeFromCount) return
|
|
91
|
-
const
|
|
92
|
-
return
|
|
95
|
+
const _ = v(() => a.filters.filter((l) => Array.isArray(l.choices) && l.choices.length > 0)), j = v(() => {
|
|
96
|
+
const l = p.value.trim().toLowerCase();
|
|
97
|
+
return l ? _.value.filter(
|
|
98
|
+
(o) => o.label.toLowerCase().includes(l) || (o.choices ?? []).some((e) => e.text.toLowerCase().includes(l))
|
|
99
|
+
) : _.value;
|
|
100
|
+
}), V = v(
|
|
101
|
+
() => _.value.reduce((l, o) => {
|
|
102
|
+
if (o.excludeFromCount) return l;
|
|
103
|
+
const e = r.value[o.key];
|
|
104
|
+
return l + (e && typeof e == "object" ? Object.values(e).filter(Boolean).length : e ? 1 : 0);
|
|
93
105
|
}, 0)
|
|
94
106
|
);
|
|
95
|
-
function
|
|
96
|
-
|
|
107
|
+
function N(l, o) {
|
|
108
|
+
const e = s({ ...r.value, [l]: o });
|
|
109
|
+
a.showActions ? i.value = e : n("update:modelValue", e);
|
|
97
110
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
111
|
+
function I(l) {
|
|
112
|
+
y.value = { ...y.value, [l]: !y.value[l] };
|
|
100
113
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
114
|
+
function U() {
|
|
115
|
+
i.value = s({});
|
|
103
116
|
}
|
|
104
|
-
function
|
|
105
|
-
|
|
117
|
+
function z() {
|
|
118
|
+
n("update:modelValue", s(i.value)), n("close");
|
|
106
119
|
}
|
|
107
|
-
return (
|
|
108
|
-
class:
|
|
120
|
+
return (l, o) => (u(), b("div", {
|
|
121
|
+
class: F(c(q)("phila-filter-panel", a.className))
|
|
109
122
|
}, [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
d("header", ee, [
|
|
124
|
+
d("h2", le, f(t.title) + f(V.value ? ` (${V.value})` : ""), 1),
|
|
125
|
+
d("button", {
|
|
113
126
|
type: "button",
|
|
114
127
|
class: "phila-filter-panel__close",
|
|
115
128
|
"aria-label": "Close filters",
|
|
116
|
-
onClick: o[0] || (o[0] = (
|
|
129
|
+
onClick: o[0] || (o[0] = (e) => n("close"))
|
|
117
130
|
}, [
|
|
118
|
-
|
|
119
|
-
icon:
|
|
131
|
+
g(c(P), {
|
|
132
|
+
icon: c(J),
|
|
120
133
|
size: "small",
|
|
121
134
|
inline: "",
|
|
122
135
|
decorative: ""
|
|
123
136
|
}, null, 8, ["icon"])
|
|
124
137
|
])
|
|
125
138
|
]),
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
d("div", te, [
|
|
140
|
+
t.searchable ? (u(), k(c(M), {
|
|
141
|
+
key: 0,
|
|
142
|
+
modelValue: p.value,
|
|
143
|
+
"onUpdate:modelValue": o[1] || (o[1] = (e) => p.value = e),
|
|
144
|
+
placeholder: t.searchPlaceholder
|
|
145
|
+
}, null, 8, ["modelValue", "placeholder"])) : w("", !0),
|
|
146
|
+
d("div", oe, [
|
|
147
|
+
(u(!0), b(G, null, R(j.value, (e) => (u(), k(Z, {
|
|
148
|
+
key: e.key,
|
|
149
|
+
filter: e,
|
|
150
|
+
collapsed: !!y.value[e.key],
|
|
151
|
+
"model-value": r.value[e.key],
|
|
152
|
+
onToggle: (m) => I(e.key),
|
|
153
|
+
"onUpdate:modelValue": (m) => N(e.key, m)
|
|
154
|
+
}, null, 8, ["filter", "collapsed", "model-value", "onToggle", "onUpdate:modelValue"]))), 128))
|
|
155
|
+
])
|
|
141
156
|
]),
|
|
142
|
-
|
|
143
|
-
|
|
157
|
+
t.showActions ? (u(), b("footer", ae, [
|
|
158
|
+
g(c(S), {
|
|
144
159
|
variant: "secondary",
|
|
145
|
-
onClick:
|
|
160
|
+
onClick: U
|
|
146
161
|
}, {
|
|
147
|
-
default:
|
|
148
|
-
|
|
162
|
+
default: A(() => [
|
|
163
|
+
B(f(t.resetText), 1)
|
|
149
164
|
]),
|
|
150
165
|
_: 1
|
|
151
166
|
}),
|
|
152
|
-
|
|
167
|
+
g(c(S), {
|
|
153
168
|
variant: "primary",
|
|
154
|
-
onClick:
|
|
169
|
+
onClick: z
|
|
155
170
|
}, {
|
|
156
|
-
default:
|
|
157
|
-
|
|
171
|
+
default: A(() => [
|
|
172
|
+
B(f(t.applyText) + f(V.value ? ` (${V.value})` : ""), 1)
|
|
158
173
|
]),
|
|
159
174
|
_: 1
|
|
160
175
|
})
|
|
161
|
-
])
|
|
176
|
+
])) : w("", !0)
|
|
162
177
|
], 2));
|
|
163
178
|
}
|
|
164
|
-
}),
|
|
179
|
+
}), pe = /* @__PURE__ */ T(ne, [["__scopeId", "data-v-ed0fc96d"]]);
|
|
165
180
|
export {
|
|
166
|
-
|
|
181
|
+
pe as FilterPanel
|
|
167
182
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phila/phila-ui-filter-panel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Filter panel for faceted filtering",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"vue": "^3.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@phila/phila-ui-core": "3.0.0-beta.
|
|
32
|
-
"@phila/phila-ui-search": "1.2.0-beta.
|
|
33
|
-
"@phila/phila-ui-radio": "0.
|
|
34
|
-
"@phila/phila-ui-checkbox": "0.
|
|
35
|
-
"@phila/phila-ui-button": "2.3.0-beta.
|
|
31
|
+
"@phila/phila-ui-core": "3.0.0-beta.9",
|
|
32
|
+
"@phila/phila-ui-search": "1.2.0-beta.12",
|
|
33
|
+
"@phila/phila-ui-radio": "1.0.0-beta.10",
|
|
34
|
+
"@phila/phila-ui-checkbox": "1.0.0-beta.10",
|
|
35
|
+
"@phila/phila-ui-button": "2.3.0-beta.10"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^24.0.0",
|