@phila/phila-ui-filter-panel 0.1.0-beta.0
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/README.md +84 -0
- package/dist/FilterPanel.vue.d.ts +18 -0
- package/dist/FilterPanel.vue.d.ts.map +1 -0
- package/dist/FilterPanelSection.vue.d.ts +15 -0
- package/dist/FilterPanelSection.vue.d.ts.map +1 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +167 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# FilterPanel Component
|
|
2
|
+
|
|
3
|
+
<!-- status-badge-start -->
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
<!-- status-badge-end -->
|
|
8
|
+
|
|
9
|
+
`@phila/phila-ui-filter-panel` — filter panel for faceted filtering — the "All Filters" panel (header, optional search, collapsible checkbox/radio sections, deferred Reset/Apply).
|
|
10
|
+
|
|
11
|
+
**Presentational:** the app controls visibility and placement by mounting/unmounting `FilterPanel`. The component emits `close` and does not hide itself.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @phila/phila-ui-filter-panel
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage with FilterChipGroup
|
|
20
|
+
|
|
21
|
+
```vue
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
import { ref } from "vue";
|
|
24
|
+
import { FilterChipGroup } from "@phila/phila-ui-filter-chip";
|
|
25
|
+
import { FilterPanel } from "@phila/phila-ui-filter-panel";
|
|
26
|
+
import type { FilterDefinition, FilterValues } from "@phila/phila-ui-core";
|
|
27
|
+
|
|
28
|
+
const filters: FilterDefinition[] = [
|
|
29
|
+
/* ... */
|
|
30
|
+
];
|
|
31
|
+
const values = ref<FilterValues>({});
|
|
32
|
+
const panelOpen = ref(false);
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<FilterChipGroup :filters="filters" v-model="values" filter-button @open-filters="panelOpen = true" />
|
|
37
|
+
<FilterPanel v-if="panelOpen" :filters="filters" v-model="values" @close="panelOpen = false" />
|
|
38
|
+
</template>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`FilterDefinition` and `FilterValues` are shared types from `@phila/phila-ui-core`. The chip row and the panel share the same `values` ref — two views over one piece of state.
|
|
42
|
+
|
|
43
|
+
## Props
|
|
44
|
+
|
|
45
|
+
| Prop | Type | Default | Description |
|
|
46
|
+
| ------------------- | -------------------- | --------------- | -------------------------------------- |
|
|
47
|
+
| `filters` | `FilterDefinition[]` | — | Required. Ordered list of filter axes. |
|
|
48
|
+
| `modelValue` | `FilterValues` | `{}` | Current filter state (`v-model`). |
|
|
49
|
+
| `title` | `string` | `"All Filters"` | Panel header title. |
|
|
50
|
+
| `searchable` | `boolean` | `true` | Show the in-panel search box. |
|
|
51
|
+
| `searchPlaceholder` | `string` | `"Search"` | Placeholder text for the search input. |
|
|
52
|
+
| `applyText` | `string` | `"Apply"` | Label for the Apply button. |
|
|
53
|
+
| `resetText` | `string` | `"Reset"` | Label for the Reset button. |
|
|
54
|
+
|
|
55
|
+
## Events
|
|
56
|
+
|
|
57
|
+
| Event | Payload | Description |
|
|
58
|
+
| ------------------- | -------------- | ---------------------------------------------------------------------------- |
|
|
59
|
+
| `update:modelValue` | `FilterValues` | Emitted when Apply is clicked. Carries the confirmed filter state. |
|
|
60
|
+
| `close` | — | Emitted when ✕ is clicked and after Apply. The app should unmount the panel. |
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
|
|
64
|
+
### Install Dependencies
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pnpm install
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Build Library
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pnpm build
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Type Check
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pnpm type-check
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FilterValues } from '@phila/phila-ui-core';
|
|
2
|
+
import { FilterPanelProps } from './index';
|
|
3
|
+
declare const _default: import('vue').DefineComponent<FilterPanelProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
4
|
+
"update:modelValue": (value: FilterValues) => any;
|
|
5
|
+
close: () => any;
|
|
6
|
+
}, string, import('vue').PublicProps, Readonly<FilterPanelProps> & Readonly<{
|
|
7
|
+
"onUpdate:modelValue"?: ((value: FilterValues) => any) | undefined;
|
|
8
|
+
onClose?: (() => any) | undefined;
|
|
9
|
+
}>, {
|
|
10
|
+
modelValue: FilterValues;
|
|
11
|
+
title: string;
|
|
12
|
+
searchable: boolean;
|
|
13
|
+
searchPlaceholder: string;
|
|
14
|
+
applyText: string;
|
|
15
|
+
resetText: string;
|
|
16
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
17
|
+
export default _default;
|
|
18
|
+
//# sourceMappingURL=FilterPanel.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterPanel.vue.d.ts","sourceRoot":"","sources":["../src/FilterPanel.vue"],"names":[],"mappings":"AAkKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;AAyQhD,wBASG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FilterDefinition } from '@phila/phila-ui-core';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
filter: FilterDefinition;
|
|
4
|
+
collapsed: boolean;
|
|
5
|
+
modelValue: string | string[] | boolean | undefined;
|
|
6
|
+
};
|
|
7
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
8
|
+
toggle: () => any;
|
|
9
|
+
"update:modelValue": (value: string | string[]) => any;
|
|
10
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
11
|
+
onToggle?: (() => any) | undefined;
|
|
12
|
+
"onUpdate:modelValue"?: ((value: string | string[]) => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLElement>;
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=FilterPanelSection.vue.d.ts.map
|
|
@@ -0,0 +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,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,GAAG,SAAS,CAAC;CACrD,CAAC;;;;;;;;AAkJF,wBAQG"}
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.phila-filter-panel__section[data-v-1b64f401]{border-bottom:1px solid var(--Schemes-Border, #ccc);padding:.75rem 0}.phila-filter-panel__section-toggle[data-v-1b64f401]{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-1b64f401]{transform:rotate(-90deg)}.phila-filter-panel__section-body[data-v-1b64f401]{padding-top:.75rem}.phila-filter-panel__section-body[data-v-1b64f401] .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-ec98ee74]{display:flex;flex-direction:column;gap:1rem;padding:1.5rem;height:100%;background:#fff;overflow-y:auto;box-sizing:border-box}.phila-filter-panel__header[data-v-ec98ee74]{display:flex;align-items:center;justify-content:space-between}.phila-filter-panel__title[data-v-ec98ee74]{margin:0;font-size:1.25rem;font-weight:700}.phila-filter-panel__close[data-v-ec98ee74]{background:none;border:none;cursor:pointer;font-size:1.25rem;line-height:1}.phila-filter-panel__sections[data-v-ec98ee74]{display:flex;flex-direction:column}.phila-filter-panel__footer[data-v-ec98ee74]{display:flex;gap:.75rem;margin-top:auto}.phila-filter-panel__footer[data-v-ec98ee74]>*{flex:1}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseProps, FilterDefinition, FilterValues } from '@phila/phila-ui-core';
|
|
2
|
+
export { default as FilterPanel } from './FilterPanel.vue';
|
|
3
|
+
export interface FilterPanelProps extends BaseProps {
|
|
4
|
+
/** Filters to render. Only filters with a non-empty `choices` array become sections. */
|
|
5
|
+
filters: FilterDefinition[];
|
|
6
|
+
/** Committed/applied values (v-model). The panel edits a draft and emits this on Apply. */
|
|
7
|
+
modelValue?: FilterValues;
|
|
8
|
+
/** Header title. */
|
|
9
|
+
title?: string;
|
|
10
|
+
/** Show the in-panel search box that filters sections by label/choice text. */
|
|
11
|
+
searchable?: boolean;
|
|
12
|
+
/** Placeholder for the search box. */
|
|
13
|
+
searchPlaceholder?: string;
|
|
14
|
+
/** Apply button label (an active-selection count is appended as " (N)"). */
|
|
15
|
+
applyText?: string;
|
|
16
|
+
/** Reset button label. */
|
|
17
|
+
resetText?: string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,2FAA2F;IAC3F,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,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const e=require("vue"),v=require("@phila/phila-ui-core"),x=require("@phila/phila-ui-search"),y=require("@phila/phila-ui-button"),V=require("@fortawesome/pro-solid-svg-icons"),S=require("@phila/phila-ui-checkbox"),_=require("@phila/phila-ui-radio"),N={class:"phila-filter-panel__section"},A={class:"phila-filter-panel__section-body"},E=e.defineComponent({__name:"FilterPanelSection",props:{filter:{},collapsed:{type:Boolean},modelValue:{type:[String,Array,Boolean]}},emits:["toggle","update:modelValue"],setup(o,{emit:p}){const n=o,c=p,r=e.computed(()=>n.filter.choices??[]),m=e.computed(()=>Array.isArray(n.modelValue)?n.modelValue:[]),s=e.computed(()=>typeof n.modelValue=="string"?n.modelValue:"");return(f,i)=>(e.openBlock(),e.createElementBlock("section",N,[e.createElementVNode("button",{type:"button",class:"phila-filter-panel__section-toggle",onClick:i[0]||(i[0]=u=>c("toggle"))},[e.createElementVNode("span",null,e.toDisplayString(o.filter.label),1),e.createVNode(e.unref(v.Icon),{"icon-definition":e.unref(V.faChevronDown),size:"xxsmall",inline:"",decorative:"",class:e.normalizeClass({"is-collapsed":o.collapsed})},null,8,["icon-definition","class"])]),e.withDirectives(e.createElementVNode("div",A,[o.filter.multiple?(e.openBlock(),e.createBlock(e.unref(S.CheckboxGroup),{key:0,"group-label":o.filter.label,choices:r.value,"model-value":m.value,"onUpdate:modelValue":i[1]||(i[1]=u=>c("update:modelValue",u))},null,8,["group-label","choices","model-value"])):(e.openBlock(),e.createBlock(e.unref(_.RadioGroup),{key:1,"group-label":o.filter.label,choices:r.value,"model-value":s.value,"onUpdate:modelValue":i[2]||(i[2]=u=>c("update:modelValue",u))},null,8,["group-label","choices","model-value"]))],512),[[e.vShow,!o.collapsed]])]))}}),k=(o,p)=>{const n=o.__vccOpts||o;for(const[c,r]of p)n[c]=r;return n},P=k(E,[["__scopeId","data-v-1b64f401"]]),U={class:"phila-filter-panel__header"},T={class:"phila-filter-panel__title"},q={class:"phila-filter-panel__sections"},w={class:"phila-filter-panel__footer"},F=e.defineComponent({__name:"FilterPanel",props:{filters:{},modelValue:{default:()=>({})},title:{default:"All Filters"},searchable:{type:Boolean,default:!0},searchPlaceholder:{default:"Search"},applyText:{default:"Apply"},resetText:{default:"Reset"},className:{}},emits:["update:modelValue","close"],setup(o,{emit:p}){const n=o,c=p,r=e.ref({}),m=e.ref(""),s=e.ref({});function f(l){const a={};for(const t of Object.keys(l)){const d=l[t];a[t]=Array.isArray(d)?[...d]:d}return a}e.onMounted(()=>{r.value=f(n.modelValue)});const i=e.computed(()=>n.filters.filter(l=>Array.isArray(l.choices)&&l.choices.length>0)),u=e.computed(()=>{const l=m.value.trim().toLowerCase();return l?i.value.filter(a=>a.label.toLowerCase().includes(l)||(a.choices??[]).some(t=>t.text.toLowerCase().includes(l))):i.value}),h=e.computed(()=>i.value.reduce((l,a)=>{if(a.excludeFromCount)return l;const t=r.value[a.key];return l+(Array.isArray(t)?t.length:t?1:0)},0));function g(l,a){r.value={...r.value,[l]:a}}function b(l){s.value={...s.value,[l]:!s.value[l]}}function C(){r.value={}}function B(){c("update:modelValue",f(r.value)),c("close")}return(l,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(v.cn)("phila-filter-panel",n.className))},[e.createElementVNode("header",U,[e.createElementVNode("h2",T,e.toDisplayString(o.title),1),e.createElementVNode("button",{type:"button",class:"phila-filter-panel__close","aria-label":"Close filters",onClick:a[0]||(a[0]=t=>c("close"))},[e.createVNode(e.unref(v.Icon),{"icon-definition":e.unref(V.faXmark),size:"small",inline:"",decorative:""},null,8,["icon-definition"])])]),o.searchable?(e.openBlock(),e.createBlock(e.unref(x.Search),{key:0,modelValue:m.value,"onUpdate:modelValue":a[1]||(a[1]=t=>m.value=t),placeholder:o.searchPlaceholder},null,8,["modelValue","placeholder"])):e.createCommentVNode("",!0),e.createElementVNode("div",q,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,t=>(e.openBlock(),e.createBlock(P,{key:t.key,filter:t,collapsed:!!s.value[t.key],"model-value":r.value[t.key],onToggle:d=>b(t.key),"onUpdate:modelValue":d=>g(t.key,d)},null,8,["filter","collapsed","model-value","onToggle","onUpdate:modelValue"]))),128))]),e.createElementVNode("footer",w,[e.createVNode(e.unref(y.PhilaButton),{variant:"secondary",onClick:C},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.resetText),1)]),_:1}),e.createVNode(e.unref(y.PhilaButton),{variant:"primary",onClick:B},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.applyText)+e.toDisplayString(h.value?` (${h.value})`:""),1)]),_:1})])],2))}}),D=k(F,[["__scopeId","data-v-ec98ee74"]]);exports.FilterPanel=D;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { defineComponent as w, computed as f, createElementBlock as _, openBlock as u, createElementVNode as c, withDirectives as L, createVNode as V, toDisplayString as y, unref as r, normalizeClass as B, createBlock as g, vShow as z, ref as b, onMounted as D, createCommentVNode as I, Fragment as E, renderList as G, withCtx as C, createTextVNode as A } from "vue";
|
|
2
|
+
import { Icon as F, cn as O } from "@phila/phila-ui-core";
|
|
3
|
+
import { Search as R } from "@phila/phila-ui-search";
|
|
4
|
+
import { PhilaButton as S } from "@phila/phila-ui-button";
|
|
5
|
+
import { faChevronDown as j, faXmark as q } from "@fortawesome/pro-solid-svg-icons";
|
|
6
|
+
import { CheckboxGroup as M } from "@phila/phila-ui-checkbox";
|
|
7
|
+
import { RadioGroup as X } from "@phila/phila-ui-radio";
|
|
8
|
+
import './index.css';const H = { class: "phila-filter-panel__section" }, J = { class: "phila-filter-panel__section-body" }, K = /* @__PURE__ */ w({
|
|
9
|
+
__name: "FilterPanelSection",
|
|
10
|
+
props: {
|
|
11
|
+
filter: {},
|
|
12
|
+
collapsed: { type: Boolean },
|
|
13
|
+
modelValue: { type: [String, Array, Boolean] }
|
|
14
|
+
},
|
|
15
|
+
emits: ["toggle", "update:modelValue"],
|
|
16
|
+
setup(t, { emit: v }) {
|
|
17
|
+
const a = t, s = v, n = f(() => a.filter.choices ?? []), h = f(() => Array.isArray(a.modelValue) ? a.modelValue : []), d = f(() => typeof a.modelValue == "string" ? a.modelValue : "");
|
|
18
|
+
return (k, i) => (u(), _("section", H, [
|
|
19
|
+
c("button", {
|
|
20
|
+
type: "button",
|
|
21
|
+
class: "phila-filter-panel__section-toggle",
|
|
22
|
+
onClick: i[0] || (i[0] = (m) => s("toggle"))
|
|
23
|
+
}, [
|
|
24
|
+
c("span", null, y(t.filter.label), 1),
|
|
25
|
+
V(r(F), {
|
|
26
|
+
"icon-definition": r(j),
|
|
27
|
+
size: "xxsmall",
|
|
28
|
+
inline: "",
|
|
29
|
+
decorative: "",
|
|
30
|
+
class: B({ "is-collapsed": t.collapsed })
|
|
31
|
+
}, null, 8, ["icon-definition", "class"])
|
|
32
|
+
]),
|
|
33
|
+
L(c("div", J, [
|
|
34
|
+
t.filter.multiple ? (u(), g(r(M), {
|
|
35
|
+
key: 0,
|
|
36
|
+
"group-label": t.filter.label,
|
|
37
|
+
choices: n.value,
|
|
38
|
+
"model-value": h.value,
|
|
39
|
+
"onUpdate:modelValue": i[1] || (i[1] = (m) => s("update:modelValue", m))
|
|
40
|
+
}, null, 8, ["group-label", "choices", "model-value"])) : (u(), g(r(X), {
|
|
41
|
+
key: 1,
|
|
42
|
+
"group-label": t.filter.label,
|
|
43
|
+
choices: n.value,
|
|
44
|
+
"model-value": d.value,
|
|
45
|
+
"onUpdate:modelValue": i[2] || (i[2] = (m) => s("update:modelValue", m))
|
|
46
|
+
}, null, 8, ["group-label", "choices", "model-value"]))
|
|
47
|
+
], 512), [
|
|
48
|
+
[z, !t.collapsed]
|
|
49
|
+
])
|
|
50
|
+
]));
|
|
51
|
+
}
|
|
52
|
+
}), P = (t, v) => {
|
|
53
|
+
const a = t.__vccOpts || t;
|
|
54
|
+
for (const [s, n] of v)
|
|
55
|
+
a[s] = n;
|
|
56
|
+
return a;
|
|
57
|
+
}, Q = /* @__PURE__ */ P(K, [["__scopeId", "data-v-1b64f401"]]), W = { class: "phila-filter-panel__header" }, Y = { class: "phila-filter-panel__title" }, Z = { class: "phila-filter-panel__sections" }, ee = { class: "phila-filter-panel__footer" }, le = /* @__PURE__ */ w({
|
|
58
|
+
__name: "FilterPanel",
|
|
59
|
+
props: {
|
|
60
|
+
filters: {},
|
|
61
|
+
modelValue: { default: () => ({}) },
|
|
62
|
+
title: { default: "All Filters" },
|
|
63
|
+
searchable: { type: Boolean, default: !0 },
|
|
64
|
+
searchPlaceholder: { default: "Search" },
|
|
65
|
+
applyText: { default: "Apply" },
|
|
66
|
+
resetText: { default: "Reset" },
|
|
67
|
+
className: {}
|
|
68
|
+
},
|
|
69
|
+
emits: ["update:modelValue", "close"],
|
|
70
|
+
setup(t, { emit: v }) {
|
|
71
|
+
const a = t, s = v, n = b({}), h = b(""), d = b({});
|
|
72
|
+
function k(e) {
|
|
73
|
+
const o = {};
|
|
74
|
+
for (const l of Object.keys(e)) {
|
|
75
|
+
const p = e[l];
|
|
76
|
+
o[l] = Array.isArray(p) ? [...p] : p;
|
|
77
|
+
}
|
|
78
|
+
return o;
|
|
79
|
+
}
|
|
80
|
+
D(() => {
|
|
81
|
+
n.value = k(a.modelValue);
|
|
82
|
+
});
|
|
83
|
+
const i = f(() => a.filters.filter((e) => Array.isArray(e.choices) && e.choices.length > 0)), m = f(() => {
|
|
84
|
+
const e = h.value.trim().toLowerCase();
|
|
85
|
+
return e ? i.value.filter(
|
|
86
|
+
(o) => o.label.toLowerCase().includes(e) || (o.choices ?? []).some((l) => l.text.toLowerCase().includes(e))
|
|
87
|
+
) : i.value;
|
|
88
|
+
}), x = f(
|
|
89
|
+
() => i.value.reduce((e, o) => {
|
|
90
|
+
if (o.excludeFromCount) return e;
|
|
91
|
+
const l = n.value[o.key];
|
|
92
|
+
return e + (Array.isArray(l) ? l.length : l ? 1 : 0);
|
|
93
|
+
}, 0)
|
|
94
|
+
);
|
|
95
|
+
function T(e, o) {
|
|
96
|
+
n.value = { ...n.value, [e]: o };
|
|
97
|
+
}
|
|
98
|
+
function $(e) {
|
|
99
|
+
d.value = { ...d.value, [e]: !d.value[e] };
|
|
100
|
+
}
|
|
101
|
+
function N() {
|
|
102
|
+
n.value = {};
|
|
103
|
+
}
|
|
104
|
+
function U() {
|
|
105
|
+
s("update:modelValue", k(n.value)), s("close");
|
|
106
|
+
}
|
|
107
|
+
return (e, o) => (u(), _("div", {
|
|
108
|
+
class: B(r(O)("phila-filter-panel", a.className))
|
|
109
|
+
}, [
|
|
110
|
+
c("header", W, [
|
|
111
|
+
c("h2", Y, y(t.title), 1),
|
|
112
|
+
c("button", {
|
|
113
|
+
type: "button",
|
|
114
|
+
class: "phila-filter-panel__close",
|
|
115
|
+
"aria-label": "Close filters",
|
|
116
|
+
onClick: o[0] || (o[0] = (l) => s("close"))
|
|
117
|
+
}, [
|
|
118
|
+
V(r(F), {
|
|
119
|
+
"icon-definition": r(q),
|
|
120
|
+
size: "small",
|
|
121
|
+
inline: "",
|
|
122
|
+
decorative: ""
|
|
123
|
+
}, null, 8, ["icon-definition"])
|
|
124
|
+
])
|
|
125
|
+
]),
|
|
126
|
+
t.searchable ? (u(), g(r(R), {
|
|
127
|
+
key: 0,
|
|
128
|
+
modelValue: h.value,
|
|
129
|
+
"onUpdate:modelValue": o[1] || (o[1] = (l) => h.value = l),
|
|
130
|
+
placeholder: t.searchPlaceholder
|
|
131
|
+
}, null, 8, ["modelValue", "placeholder"])) : I("", !0),
|
|
132
|
+
c("div", Z, [
|
|
133
|
+
(u(!0), _(E, null, G(m.value, (l) => (u(), g(Q, {
|
|
134
|
+
key: l.key,
|
|
135
|
+
filter: l,
|
|
136
|
+
collapsed: !!d.value[l.key],
|
|
137
|
+
"model-value": n.value[l.key],
|
|
138
|
+
onToggle: (p) => $(l.key),
|
|
139
|
+
"onUpdate:modelValue": (p) => T(l.key, p)
|
|
140
|
+
}, null, 8, ["filter", "collapsed", "model-value", "onToggle", "onUpdate:modelValue"]))), 128))
|
|
141
|
+
]),
|
|
142
|
+
c("footer", ee, [
|
|
143
|
+
V(r(S), {
|
|
144
|
+
variant: "secondary",
|
|
145
|
+
onClick: N
|
|
146
|
+
}, {
|
|
147
|
+
default: C(() => [
|
|
148
|
+
A(y(t.resetText), 1)
|
|
149
|
+
]),
|
|
150
|
+
_: 1
|
|
151
|
+
}),
|
|
152
|
+
V(r(S), {
|
|
153
|
+
variant: "primary",
|
|
154
|
+
onClick: U
|
|
155
|
+
}, {
|
|
156
|
+
default: C(() => [
|
|
157
|
+
A(y(t.applyText) + y(x.value ? ` (${x.value})` : ""), 1)
|
|
158
|
+
]),
|
|
159
|
+
_: 1
|
|
160
|
+
})
|
|
161
|
+
])
|
|
162
|
+
], 2));
|
|
163
|
+
}
|
|
164
|
+
}), ce = /* @__PURE__ */ P(le, [["__scopeId", "data-v-ec98ee74"]]);
|
|
165
|
+
export {
|
|
166
|
+
ce as FilterPanel
|
|
167
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@phila/phila-ui-filter-panel",
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Filter panel for faceted filtering",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"ui",
|
|
21
|
+
"filter-panel",
|
|
22
|
+
"vue",
|
|
23
|
+
"component"
|
|
24
|
+
],
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"vue": "^3.0.0",
|
|
29
|
+
"@fortawesome/fontawesome-svg-core": "^7.1.0",
|
|
30
|
+
"@fortawesome/pro-solid-svg-icons": "^7.1.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@phila/phila-ui-core": "3.0.0-beta.5",
|
|
34
|
+
"@phila/phila-ui-search": "1.2.0-beta.8",
|
|
35
|
+
"@phila/phila-ui-radio": "0.1.1-beta.6",
|
|
36
|
+
"@phila/phila-ui-checkbox": "0.1.1-beta.6",
|
|
37
|
+
"@phila/phila-ui-button": "2.2.3-beta.6"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^24.0.0",
|
|
41
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
42
|
+
"eslint": "^9.0.0",
|
|
43
|
+
"typescript": "^5.8.3",
|
|
44
|
+
"vite": "^7.0.6",
|
|
45
|
+
"vite-plugin-dts": "^4.5.4",
|
|
46
|
+
"vite-plugin-lib-inject-css": "^2.2.2"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "vite build",
|
|
50
|
+
"build-win": "vite build",
|
|
51
|
+
"dev": "vite build --watch",
|
|
52
|
+
"lint": "eslint src --ext .ts,.tsx,.vue",
|
|
53
|
+
"lint:fix": "eslint src --ext .ts,.tsx,.vue --fix",
|
|
54
|
+
"type-check": "tsc --noEmit",
|
|
55
|
+
"clean": "rm -rf dist",
|
|
56
|
+
"format": "prettier --write .",
|
|
57
|
+
"format:check": "prettier --check ."
|
|
58
|
+
}
|
|
59
|
+
}
|