@phila/phila-ui-filter-panel 0.1.0-beta.3 → 1.0.0-beta.5

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,8 +11,10 @@ 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
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
17
+ fullScreen: boolean;
18
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
17
19
  export default _default;
18
20
  //# sourceMappingURL=FilterPanel.vue.d.ts.map
@@ -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":"AA2MA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;;;AAiThD,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-052723b8]{display:flex;flex-direction:column;height:100%;background:#fff;overflow:hidden;box-sizing:border-box}.phila-filter-panel--full-screen[data-v-052723b8]{position:fixed;inset:0;z-index:10001}.phila-filter-panel__header[data-v-052723b8]{display:flex;align-items:center;justify-content:space-between;flex-shrink:0;padding:1.5rem 1.5rem .75rem}.phila-filter-panel__body[data-v-052723b8]{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-052723b8]{margin:0;font-size:1.25rem;font-weight:700}.phila-filter-panel__close[data-v-052723b8]{background:none;border:none;cursor:pointer;font-size:1.25rem;line-height:1}.phila-filter-panel__sections[data-v-052723b8]{display:flex;flex-direction:column}.phila-filter-panel__footer[data-v-052723b8]{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-052723b8]>*{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,9 +11,14 @@ 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. */
17
19
  resetText?: string;
20
+ /** Render as a full-screen takeover (teleported to <body>, above app chrome).
21
+ * Off (default) renders inline; the consumer positions it. */
22
+ fullScreen?: boolean;
18
23
  }
19
24
  //# sourceMappingURL=index.d.ts.map
@@ -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;IACnB;mEAC+D;IAC/D,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
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"),_=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"},T=e.defineComponent({__name:"FilterPanelSection",props:{filter:{},collapsed:{type:Boolean},modelValue:{type:[Boolean,Object]}},emits:["toggle","update:modelValue"],setup(t,{emit:p}){const n=t,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(t.filter.label),1),e.createVNode(e.unref(h.Icon),{icon:e.unref(k.IconChevronDown),size:"xxsmall",inline:"",decorative:"",class:e.normalizeClass({"is-collapsed":t.collapsed})},null,8,["icon","class"])]),e.withDirectives(e.createElementVNode("div",P,[t.filter.multiple?(e.openBlock(),e.createBlock(e.unref(w.CheckboxGroup),{key:0,"group-label":t.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":t.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,!t.collapsed]])]))}}),b=(t,p)=>{const n=t.__vccOpts||t;for(const[c,r]of p)n[c]=r;return n},U=b(T,[["__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"},fullScreen:{type:Boolean,default:!1},className:{}},emits:["update:modelValue","close"],setup(t,{emit:p}){const n=t,c=p,r=e.ref({}),d=e.ref(""),m=e.ref({});function i(o){const a={};for(const l of n.filters){const u=o[l.key];if(Array.isArray(l.choices)&&l.choices.length>0){const x=u&&typeof u=="object"?u:{};a[l.key]=Object.fromEntries(l.choices.map(y=>[y.value,!!x[y.value]]))}else a[l.key]=u===!0}return a}const s=e.computed(()=>n.showActions?r.value:n.modelValue);e.onMounted(()=>{const o=i(n.modelValue);r.value=o,c("update:modelValue",o)});const v=e.computed(()=>n.filters.filter(o=>Array.isArray(o.choices)&&o.choices.length>0)),g=e.computed(()=>{const o=d.value.trim().toLowerCase();return o?v.value.filter(a=>a.label.toLowerCase().includes(o)||(a.choices??[]).some(l=>l.text.toLowerCase().includes(o))):v.value}),f=e.computed(()=>v.value.reduce((o,a)=>{if(a.excludeFromCount)return o;const l=s.value[a.key];return o+(l&&typeof l=="object"?Object.values(l).filter(Boolean).length:l?1:0)},0));function B(o,a){const l=i({...s.value,[o]:a});n.showActions?r.value=l:c("update:modelValue",l)}function C(o){m.value={...m.value,[o]:!m.value[o]}}function N(){r.value=i({})}function S(){c("update:modelValue",i(r.value)),c("close")}return(o,a)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",disabled:!t.fullScreen},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(h.cn)("phila-filter-panel",t.fullScreen&&"phila-filter-panel--full-screen",n.className))},[e.createElementVNode("header",q,[e.createElementVNode("h2",D,e.toDisplayString(t.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,[t.searchable?(e.openBlock(),e.createBlock(e.unref(_.Search),{key:0,modelValue:d.value,"onUpdate:modelValue":a[1]||(a[1]=l=>d.value=l),placeholder:t.searchPlaceholder},null,8,["modelValue","placeholder"])):e.createCommentVNode("",!0),e.createElementVNode("div",$,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,l=>(e.openBlock(),e.createBlock(U,{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))])]),t.showActions?(e.openBlock(),e.createElementBlock("footer",j,[e.createVNode(e.unref(V.PhilaButton),{variant:"secondary",onClick:N},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.resetText),1)]),_:1}),e.createVNode(e.unref(V.PhilaButton),{variant:"primary",onClick:S},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.applyText)+e.toDisplayString(f.value?` (${f.value})`:""),1)]),_:1})])):e.createCommentVNode("",!0)],2)],8,["disabled"]))}}),z=b(I,[["__scopeId","data-v-052723b8"]]);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";
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({
1
+ import { defineComponent as T, computed as v, createElementBlock as x, openBlock as d, createElementVNode as r, withDirectives as O, createVNode as g, toDisplayString as f, unref as c, normalizeClass as $, createBlock as b, vShow as D, ref as C, onMounted as E, Teleport as G, createCommentVNode as w, Fragment as R, renderList as q, withCtx as S, createTextVNode as A } from "vue";
2
+ import { Icon as F, cn as M } from "@phila/phila-ui-core";
3
+ import { Search as H } from "@phila/phila-ui-search";
4
+ import { PhilaButton as B } from "@phila/phila-ui-button";
5
+ import { IconChevronDown as J, IconClose as K } from "@phila/phila-ui-core/icons";
6
+ import { CheckboxGroup as Q } from "@phila/phila-ui-checkbox";
7
+ import { RadioGroup as W } from "@phila/phila-ui-radio";
8
+ import './index.css';const X = { class: "phila-filter-panel__section" }, Y = { class: "phila-filter-panel__section-body" }, Z = /* @__PURE__ */ T({
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(l, { emit: h }) {
17
+ const a = l, n = h, i = v(() => a.filter.choices ?? []), p = v(
18
+ () => a.modelValue && typeof a.modelValue == "object" ? a.modelValue : {}
19
+ );
20
+ return (y, s) => (d(), x("section", X, [
21
+ r("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] = (u) => n("toggle"))
23
25
  }, [
24
- c("span", null, y(t.filter.label), 1),
25
- V(i(F), {
26
- icon: i(j),
26
+ r("span", null, f(l.filter.label), 1),
27
+ g(c(F), {
28
+ icon: c(J),
27
29
  size: "xxsmall",
28
30
  inline: "",
29
31
  decorative: "",
30
- class: B({ "is-collapsed": t.collapsed })
32
+ class: $({ "is-collapsed": l.collapsed })
31
33
  }, null, 8, ["icon", "class"])
32
34
  ]),
33
- U(c("div", K, [
34
- t.filter.multiple ? (u(), g(i(M), {
35
+ O(r("div", Y, [
36
+ l.filter.multiple ? (d(), b(c(Q), {
35
37
  key: 0,
36
- "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), {
38
+ "group-label": l.filter.label,
39
+ choices: i.value,
40
+ "model-value": p.value,
41
+ "onUpdate:modelValue": s[1] || (s[1] = (u) => n("update:modelValue", u))
42
+ }, null, 8, ["group-label", "choices", "model-value"])) : (d(), b(c(W), {
41
43
  key: 1,
42
- "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))
44
+ "group-label": l.filter.label,
45
+ choices: i.value,
46
+ "model-value": p.value,
47
+ "onUpdate:modelValue": s[2] || (s[2] = (u) => n("update:modelValue", u))
46
48
  }, null, 8, ["group-label", "choices", "model-value"]))
47
49
  ], 512), [
48
- [L, !t.collapsed]
50
+ [D, !l.collapsed]
49
51
  ])
50
52
  ]));
51
53
  }
52
- }), P = (t, v) => {
53
- const a = t.__vccOpts || t;
54
- for (const [s, n] of v)
55
- a[s] = n;
54
+ }), P = (l, h) => {
55
+ const a = l.__vccOpts || l;
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
+ }, ee = /* @__PURE__ */ P(Z, [["__scopeId", "data-v-54c0ee8c"]]), le = { class: "phila-filter-panel__header" }, te = { class: "phila-filter-panel__title" }, oe = { class: "phila-filter-panel__body" }, ae = { class: "phila-filter-panel__sections" }, ne = {
60
+ key: 0,
61
+ class: "phila-filter-panel__footer"
62
+ }, se = /* @__PURE__ */ T({
58
63
  __name: "FilterPanel",
59
64
  props: {
60
65
  filters: {},
@@ -62,106 +67,122 @@ 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" },
73
+ fullScreen: { type: Boolean, default: !1 },
67
74
  className: {}
68
75
  },
69
76
  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) {
77
+ setup(l, { emit: h }) {
78
+ const a = l, n = h, i = C({}), p = C(""), y = C({});
79
+ function s(t) {
73
80
  const o = {};
74
- for (const l of Object.keys(e)) {
75
- const p = e[l];
76
- o[l] = Array.isArray(p) ? [...p] : p;
81
+ for (const e of a.filters) {
82
+ const m = t[e.key];
83
+ if (Array.isArray(e.choices) && e.choices.length > 0) {
84
+ const L = m && typeof m == "object" ? m : {};
85
+ o[e.key] = Object.fromEntries(e.choices.map((_) => [_.value, !!L[_.value]]));
86
+ } else
87
+ o[e.key] = m === !0;
77
88
  }
78
89
  return o;
79
90
  }
80
- z(() => {
81
- n.value = k(a.modelValue);
91
+ const u = v(() => a.showActions ? i.value : a.modelValue);
92
+ E(() => {
93
+ const t = s(a.modelValue);
94
+ i.value = t, n("update:modelValue", t);
82
95
  });
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);
96
+ const k = v(() => a.filters.filter((t) => Array.isArray(t.choices) && t.choices.length > 0)), j = v(() => {
97
+ const t = p.value.trim().toLowerCase();
98
+ return t ? k.value.filter(
99
+ (o) => o.label.toLowerCase().includes(t) || (o.choices ?? []).some((e) => e.text.toLowerCase().includes(t))
100
+ ) : k.value;
101
+ }), V = v(
102
+ () => k.value.reduce((t, o) => {
103
+ if (o.excludeFromCount) return t;
104
+ const e = u.value[o.key];
105
+ return t + (e && typeof e == "object" ? Object.values(e).filter(Boolean).length : e ? 1 : 0);
93
106
  }, 0)
94
107
  );
95
- function T(e, o) {
96
- n.value = { ...n.value, [e]: o };
108
+ function N(t, o) {
109
+ const e = s({ ...u.value, [t]: o });
110
+ a.showActions ? i.value = e : n("update:modelValue", e);
97
111
  }
98
- function $(e) {
99
- d.value = { ...d.value, [e]: !d.value[e] };
112
+ function I(t) {
113
+ y.value = { ...y.value, [t]: !y.value[t] };
100
114
  }
101
- function N() {
102
- n.value = {};
115
+ function U() {
116
+ i.value = s({});
103
117
  }
104
- function I() {
105
- s("update:modelValue", k(n.value)), s("close");
118
+ function z() {
119
+ n("update:modelValue", s(i.value)), n("close");
106
120
  }
107
- return (e, o) => (u(), _("div", {
108
- class: B(i(O)("phila-filter-panel", a.className))
121
+ return (t, o) => (d(), b(G, {
122
+ to: "body",
123
+ disabled: !l.fullScreen
109
124
  }, [
110
- c("header", X, [
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(i(F), {
119
- icon: i(q),
120
- size: "small",
121
- inline: "",
122
- decorative: ""
123
- }, null, 8, ["icon"])
124
- ])
125
- ]),
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))
141
- ]),
142
- c("footer", ee, [
143
- V(i(S), {
144
- variant: "secondary",
145
- onClick: N
146
- }, {
147
- default: x(() => [
148
- A(y(t.resetText), 1)
149
- ]),
150
- _: 1
151
- }),
152
- V(i(S), {
153
- variant: "primary",
154
- onClick: I
155
- }, {
156
- default: x(() => [
157
- A(y(t.applyText) + y(C.value ? ` (${C.value})` : ""), 1)
158
- ]),
159
- _: 1
160
- })
161
- ])
162
- ], 2));
125
+ r("div", {
126
+ class: $(c(M)("phila-filter-panel", l.fullScreen && "phila-filter-panel--full-screen", a.className))
127
+ }, [
128
+ r("header", le, [
129
+ r("h2", te, f(l.title) + f(V.value ? ` (${V.value})` : ""), 1),
130
+ r("button", {
131
+ type: "button",
132
+ class: "phila-filter-panel__close",
133
+ "aria-label": "Close filters",
134
+ onClick: o[0] || (o[0] = (e) => n("close"))
135
+ }, [
136
+ g(c(F), {
137
+ icon: c(K),
138
+ size: "small",
139
+ inline: "",
140
+ decorative: ""
141
+ }, null, 8, ["icon"])
142
+ ])
143
+ ]),
144
+ r("div", oe, [
145
+ l.searchable ? (d(), b(c(H), {
146
+ key: 0,
147
+ modelValue: p.value,
148
+ "onUpdate:modelValue": o[1] || (o[1] = (e) => p.value = e),
149
+ placeholder: l.searchPlaceholder
150
+ }, null, 8, ["modelValue", "placeholder"])) : w("", !0),
151
+ r("div", ae, [
152
+ (d(!0), x(R, null, q(j.value, (e) => (d(), b(ee, {
153
+ key: e.key,
154
+ filter: e,
155
+ collapsed: !!y.value[e.key],
156
+ "model-value": u.value[e.key],
157
+ onToggle: (m) => I(e.key),
158
+ "onUpdate:modelValue": (m) => N(e.key, m)
159
+ }, null, 8, ["filter", "collapsed", "model-value", "onToggle", "onUpdate:modelValue"]))), 128))
160
+ ])
161
+ ]),
162
+ l.showActions ? (d(), x("footer", ne, [
163
+ g(c(B), {
164
+ variant: "secondary",
165
+ onClick: U
166
+ }, {
167
+ default: S(() => [
168
+ A(f(l.resetText), 1)
169
+ ]),
170
+ _: 1
171
+ }),
172
+ g(c(B), {
173
+ variant: "primary",
174
+ onClick: z
175
+ }, {
176
+ default: S(() => [
177
+ A(f(l.applyText) + f(V.value ? ` (${V.value})` : ""), 1)
178
+ ]),
179
+ _: 1
180
+ })
181
+ ])) : w("", !0)
182
+ ], 2)
183
+ ], 8, ["disabled"]));
163
184
  }
164
- }), ce = /* @__PURE__ */ P(le, [["__scopeId", "data-v-c37adf1c"]]);
185
+ }), fe = /* @__PURE__ */ P(se, [["__scopeId", "data-v-052723b8"]]);
165
186
  export {
166
- ce as FilterPanel
187
+ fe as FilterPanel
167
188
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phila/phila-ui-filter-panel",
3
- "version": "0.1.0-beta.3",
3
+ "version": "1.0.0-beta.5",
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.8",
32
- "@phila/phila-ui-search": "1.2.0-beta.11",
33
- "@phila/phila-ui-radio": "0.1.1-beta.9",
34
- "@phila/phila-ui-checkbox": "0.1.1-beta.9",
35
- "@phila/phila-ui-button": "2.3.0-beta.9"
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",