@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.
@@ -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":"AAkKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;AAyQhD,wBASG"}
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: string | string[] | boolean | undefined;
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 | string[]) => any;
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 | string[]) => any) | undefined;
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,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,GAAG,SAAS,CAAC;CACrD,CAAC;;;;;;;;AAkJF,wBAQG"}
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-4a425956]{border-bottom:1px solid var(--Schemes-Border, #ccc);padding:.75rem 0}.phila-filter-panel__section-toggle[data-v-4a425956]{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-4a425956]{transform:rotate(-90deg)}.phila-filter-panel__section-body[data-v-4a425956]{padding-top:.75rem}.phila-filter-panel__section-body[data-v-4a425956] .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-c37adf1c]{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-c37adf1c]{display:flex;align-items:center;justify-content:space-between}.phila-filter-panel__title[data-v-c37adf1c]{margin:0;font-size:1.25rem;font-weight:700}.phila-filter-panel__close[data-v-c37adf1c]{background:none;border:none;cursor:pointer;font-size:1.25rem;line-height:1}.phila-filter-panel__sections[data-v-c37adf1c]{display:flex;flex-direction:column}.phila-filter-panel__footer[data-v-c37adf1c]{display:flex;gap:.75rem;margin-top:auto}.phila-filter-panel__footer[data-v-c37adf1c]>*{flex:1}
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
- /** Committed/applied values (v-model). The panel edits a draft and emits this on Apply. */
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. */
@@ -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,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"}
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"),v=require("@phila/phila-ui-core"),x=require("@phila/phila-ui-search"),y=require("@phila/phila-ui-button"),V=require("@phila/phila-ui-core/icons"),_=require("@phila/phila-ui-checkbox"),N=require("@phila/phila-ui-radio"),S={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,i=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,c)=>(e.openBlock(),e.createElementBlock("section",S,[e.createElementVNode("button",{type:"button",class:"phila-filter-panel__section-toggle",onClick:c[0]||(c[0]=u=>i("toggle"))},[e.createElementVNode("span",null,e.toDisplayString(o.filter.label),1),e.createVNode(e.unref(v.Icon),{icon:e.unref(V.IconChevronDown),size:"xxsmall",inline:"",decorative:"",class:e.normalizeClass({"is-collapsed":o.collapsed})},null,8,["icon","class"])]),e.withDirectives(e.createElementVNode("div",A,[o.filter.multiple?(e.openBlock(),e.createBlock(e.unref(_.CheckboxGroup),{key:0,"group-label":o.filter.label,choices:r.value,"model-value":m.value,"onUpdate:modelValue":c[1]||(c[1]=u=>i("update:modelValue",u))},null,8,["group-label","choices","model-value"])):(e.openBlock(),e.createBlock(e.unref(N.RadioGroup),{key:1,"group-label":o.filter.label,choices:r.value,"model-value":s.value,"onUpdate:modelValue":c[2]||(c[2]=u=>i("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[i,r]of p)n[i]=r;return n},P=k(E,[["__scopeId","data-v-4a425956"]]),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,i=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 c=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?c.value.filter(a=>a.label.toLowerCase().includes(l)||(a.choices??[]).some(t=>t.text.toLowerCase().includes(l))):c.value}),h=e.computed(()=>c.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(){i("update:modelValue",f(r.value)),i("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=>i("close"))},[e.createVNode(e.unref(v.Icon),{icon:e.unref(V.IconClose),size:"small",inline:"",decorative:""},null,8,["icon"])])]),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-c37adf1c"]]);exports.FilterPanel=D;
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 w, computed as f, createElementBlock as _, openBlock as u, createElementVNode as c, withDirectives as U, createVNode as V, toDisplayString as y, unref as i, normalizeClass as B, createBlock as g, vShow as L, ref as b, onMounted as z, createCommentVNode as D, Fragment as E, renderList as G, withCtx as x, 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";
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 j, IconClose as q } from "@phila/phila-ui-core/icons";
6
- import { CheckboxGroup as M } from "@phila/phila-ui-checkbox";
7
- import { RadioGroup as H } from "@phila/phila-ui-radio";
8
- import './index.css';const J = { class: "phila-filter-panel__section" }, K = { class: "phila-filter-panel__section-body" }, Q = /* @__PURE__ */ w({
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: [String, Array, Boolean] }
13
+ modelValue: { type: [Boolean, Object] }
14
14
  },
15
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, r) => (u(), _("section", J, [
19
- c("button", {
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: r[0] || (r[0] = (m) => s("toggle"))
24
+ onClick: s[0] || (s[0] = (r) => n("toggle"))
23
25
  }, [
24
- c("span", null, y(t.filter.label), 1),
25
- V(i(F), {
26
- icon: i(j),
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: B({ "is-collapsed": t.collapsed })
32
+ class: F({ "is-collapsed": t.collapsed })
31
33
  }, null, 8, ["icon", "class"])
32
34
  ]),
33
- U(c("div", K, [
34
- t.filter.multiple ? (u(), g(i(M), {
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: n.value,
38
- "model-value": h.value,
39
- "onUpdate:modelValue": r[1] || (r[1] = (m) => s("update:modelValue", m))
40
- }, null, 8, ["group-label", "choices", "model-value"])) : (u(), g(i(H), {
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: n.value,
44
- "model-value": d.value,
45
- "onUpdate:modelValue": r[2] || (r[2] = (m) => s("update:modelValue", m))
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
- [L, !t.collapsed]
50
+ [D, !t.collapsed]
49
51
  ])
50
52
  ]));
51
53
  }
52
- }), P = (t, v) => {
54
+ }), T = (t, h) => {
53
55
  const a = t.__vccOpts || t;
54
- for (const [s, n] of v)
55
- a[s] = n;
56
+ for (const [n, i] of h)
57
+ a[n] = i;
56
58
  return a;
57
- }, W = /* @__PURE__ */ P(Q, [["__scopeId", "data-v-4a425956"]]), X = { 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({
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: v }) {
71
- const a = t, s = v, n = b({}), h = b(""), d = b({});
72
- function k(e) {
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 l of Object.keys(e)) {
75
- const p = e[l];
76
- o[l] = Array.isArray(p) ? [...p] : p;
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
- z(() => {
81
- n.value = k(a.modelValue);
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 r = 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 ? r.value.filter(
86
- (o) => o.label.toLowerCase().includes(e) || (o.choices ?? []).some((l) => l.text.toLowerCase().includes(e))
87
- ) : r.value;
88
- }), C = f(
89
- () => r.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);
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 T(e, o) {
96
- n.value = { ...n.value, [e]: o };
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 $(e) {
99
- d.value = { ...d.value, [e]: !d.value[e] };
111
+ function I(l) {
112
+ y.value = { ...y.value, [l]: !y.value[l] };
100
113
  }
101
- function N() {
102
- n.value = {};
114
+ function U() {
115
+ i.value = s({});
103
116
  }
104
- function I() {
105
- s("update:modelValue", k(n.value)), s("close");
117
+ function z() {
118
+ n("update:modelValue", s(i.value)), n("close");
106
119
  }
107
- return (e, o) => (u(), _("div", {
108
- class: B(i(O)("phila-filter-panel", a.className))
120
+ return (l, o) => (u(), b("div", {
121
+ class: F(c(q)("phila-filter-panel", a.className))
109
122
  }, [
110
- c("header", X, [
111
- c("h2", Y, y(t.title), 1),
112
- c("button", {
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] = (l) => s("close"))
129
+ onClick: o[0] || (o[0] = (e) => n("close"))
117
130
  }, [
118
- V(i(F), {
119
- icon: i(q),
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
- t.searchable ? (u(), g(i(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"])) : D("", !0),
132
- c("div", Z, [
133
- (u(!0), _(E, null, G(m.value, (l) => (u(), g(W, {
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))
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
- c("footer", ee, [
143
- V(i(S), {
157
+ t.showActions ? (u(), b("footer", ae, [
158
+ g(c(S), {
144
159
  variant: "secondary",
145
- onClick: N
160
+ onClick: U
146
161
  }, {
147
- default: x(() => [
148
- A(y(t.resetText), 1)
162
+ default: A(() => [
163
+ B(f(t.resetText), 1)
149
164
  ]),
150
165
  _: 1
151
166
  }),
152
- V(i(S), {
167
+ g(c(S), {
153
168
  variant: "primary",
154
- onClick: I
169
+ onClick: z
155
170
  }, {
156
- default: x(() => [
157
- A(y(t.applyText) + y(C.value ? ` (${C.value})` : ""), 1)
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
- }), ce = /* @__PURE__ */ P(le, [["__scopeId", "data-v-c37adf1c"]]);
179
+ }), pe = /* @__PURE__ */ T(ne, [["__scopeId", "data-v-ed0fc96d"]]);
165
180
  export {
166
- ce as FilterPanel
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": "0.1.0-beta.2",
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.7",
32
- "@phila/phila-ui-search": "1.2.0-beta.10",
33
- "@phila/phila-ui-radio": "0.1.1-beta.8",
34
- "@phila/phila-ui-checkbox": "0.1.1-beta.8",
35
- "@phila/phila-ui-button": "2.3.0-beta.8"
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",