@papernote/ui 2.0.2 → 2.0.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.
@@ -1,7 +1,7 @@
1
1
  export interface FilterConfig {
2
2
  key: string;
3
3
  label: string;
4
- type: 'text' | 'search' | 'select' | 'date' | 'number' | 'boolean' | 'dateRange' | 'toggle' | 'multiSelect';
4
+ type: "text" | "search" | "select" | "date" | "number" | "boolean" | "dateRange" | "toggle" | "switch" | "multiSelect";
5
5
  placeholder?: string;
6
6
  options?: Array<{
7
7
  label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"FilterBar.d.ts","sourceRoot":"","sources":["../../src/components/FilterBar.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC5G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,OAAO,EACP,MAAM,EACN,QAAQ,EACR,SAAc,EACd,OAAO,EACP,eAAuB,GACxB,EAAE,cAAc,kDA0PhB"}
1
+ {"version":3,"file":"FilterBar.d.ts","sourceRoot":"","sources":["../../src/components/FilterBar.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EACA,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,SAAS,GACT,WAAW,GACX,QAAQ,GACR,QAAQ,GACR,aAAa,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,OAAO,EACP,MAAM,EACN,QAAQ,EACR,SAAc,EACd,OAAO,EACP,eAAuB,GACxB,EAAE,cAAc,kDA6ThB"}
package/dist/index.d.ts CHANGED
@@ -1065,7 +1065,7 @@ declare function FormControl({ label, required, error, helperText, children, cla
1065
1065
  interface FilterConfig {
1066
1066
  key: string;
1067
1067
  label: string;
1068
- type: 'text' | 'search' | 'select' | 'date' | 'number' | 'boolean' | 'dateRange' | 'toggle' | 'multiSelect';
1068
+ type: "text" | "search" | "select" | "date" | "number" | "boolean" | "dateRange" | "toggle" | "switch" | "multiSelect";
1069
1069
  placeholder?: string;
1070
1070
  options?: Array<{
1071
1071
  label: string;
package/dist/index.esm.js CHANGED
@@ -2745,7 +2745,7 @@ function FormControl({ label, required = false, error, helperText, children, cla
2745
2745
  return (jsxs("div", { className: `${className}`, children: [label && (jsxs("label", { htmlFor: htmlFor, className: "block text-sm font-medium text-ink-700 mb-1", children: [label, required && jsx("span", { className: "text-error-500 ml-1", children: "*" })] })), jsx("div", { children: children }), (error || helperText) && (jsx("p", { className: `mt-1 text-xs ${error ? 'text-error-600' : 'text-ink-500'}`, children: error || helperText }))] }));
2746
2746
  }
2747
2747
 
2748
- function FilterBar({ filters, values, onChange, className = '', onClear, showClearButton = false, }) {
2748
+ function FilterBar({ filters, values, onChange, className = "", onClear, showClearButton = false, }) {
2749
2749
  const handleFilterChange = (key, value) => {
2750
2750
  onChange({
2751
2751
  ...values,
@@ -2759,16 +2759,19 @@ function FilterBar({ filters, values, onChange, className = '', onClear, showCle
2759
2759
  else {
2760
2760
  // Default clear: set all values to null/empty
2761
2761
  const clearedValues = {};
2762
- filters.forEach(filter => {
2763
- if (filter.type === 'text' || filter.type === 'search') {
2764
- clearedValues[filter.key] = '';
2762
+ filters.forEach((filter) => {
2763
+ if (filter.type === "text" || filter.type === "search") {
2764
+ clearedValues[filter.key] = "";
2765
2765
  }
2766
- else if (filter.type === 'dateRange') {
2766
+ else if (filter.type === "dateRange") {
2767
2767
  clearedValues[filter.key] = { from: undefined, to: undefined };
2768
2768
  }
2769
- else if (filter.type === 'multiSelect') {
2769
+ else if (filter.type === "multiSelect") {
2770
2770
  clearedValues[filter.key] = [];
2771
2771
  }
2772
+ else if (filter.type === "switch") {
2773
+ clearedValues[filter.key] = false;
2774
+ }
2772
2775
  else {
2773
2776
  clearedValues[filter.key] = null;
2774
2777
  }
@@ -2779,51 +2782,70 @@ function FilterBar({ filters, values, onChange, className = '', onClear, showCle
2779
2782
  const renderFilter = (filter) => {
2780
2783
  const value = values[filter.key];
2781
2784
  switch (filter.type) {
2782
- case 'text':
2783
- return (jsx(Input, { type: "text", placeholder: filter.placeholder || `Filter by ${filter.label}`, value: value || '', onChange: (e) => handleFilterChange(filter.key, e.target.value) }));
2784
- case 'select': {
2785
+ case "text":
2786
+ return (jsx(Input, { type: "text", placeholder: filter.placeholder || `Filter by ${filter.label}`, value: value || "", onChange: (e) => handleFilterChange(filter.key, e.target.value) }));
2787
+ case "select": {
2785
2788
  const selectOptions = [
2786
- { value: '', label: `All ${filter.label}` },
2787
- ...(filter.options?.map(opt => ({
2789
+ { value: "", label: `All ${filter.label}` },
2790
+ ...(filter.options?.map((opt) => ({
2788
2791
  value: String(opt.value),
2789
2792
  label: opt.label,
2790
2793
  })) || []),
2791
2794
  ];
2792
- return (jsx(Select, { options: selectOptions, value: String(value || ''), onChange: (newValue) => handleFilterChange(filter.key, newValue || null) }));
2795
+ return (jsx(Select, { options: selectOptions, value: String(value || ""), onChange: (newValue) => handleFilterChange(filter.key, newValue || null) }));
2793
2796
  }
2794
- case 'date':
2795
- return (jsx("input", { type: "date", value: value || '', onChange: (e) => handleFilterChange(filter.key, e.target.value), className: "input" }));
2796
- case 'number':
2797
- return (jsx("input", { type: "number", placeholder: filter.placeholder || `Filter by ${filter.label}`, value: value !== null && value !== undefined ? String(value) : '', onChange: (e) => handleFilterChange(filter.key, e.target.value ? Number(e.target.value) : null), className: "input" }));
2798
- case 'boolean': {
2797
+ case "date":
2798
+ return (jsx("input", { type: "date", value: value || "", onChange: (e) => handleFilterChange(filter.key, e.target.value), className: "input" }));
2799
+ case "number":
2800
+ return (jsx("input", { type: "number", placeholder: filter.placeholder || `Filter by ${filter.label}`, value: value !== null && value !== undefined ? String(value) : "", onChange: (e) => handleFilterChange(filter.key, e.target.value ? Number(e.target.value) : null), className: "input" }));
2801
+ case "boolean": {
2799
2802
  const boolOptions = [
2800
- { value: '', label: 'All' },
2801
- { value: 'true', label: 'Yes' },
2802
- { value: 'false', label: 'No' },
2803
+ { value: "", label: "All" },
2804
+ { value: "true", label: "Yes" },
2805
+ { value: "false", label: "No" },
2803
2806
  ];
2804
- return (jsx(Select, { options: boolOptions, value: value === null || value === undefined ? '' : String(value), onChange: (newValue) => handleFilterChange(filter.key, newValue === '' ? null : newValue === 'true') }));
2807
+ return (jsx(Select, { options: boolOptions, value: value === null || value === undefined ? "" : String(value), onChange: (newValue) => handleFilterChange(filter.key, newValue === "" ? null : newValue === "true") }));
2805
2808
  }
2806
- case 'search':
2807
- return (jsxs("div", { className: "relative", children: [jsx("div", { className: "absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none", children: jsx(Search, { className: "h-4 w-4 text-ink-400" }) }), jsx("input", { type: "text", placeholder: filter.placeholder || `Search ${filter.label}...`, value: value || '', onChange: (e) => handleFilterChange(filter.key, e.target.value), className: "input pl-9" })] }));
2808
- case 'dateRange': {
2809
+ case "search":
2810
+ return (jsxs("div", { className: "relative", children: [jsx("div", { className: "absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none", children: jsx(Search, { className: "h-4 w-4 text-ink-400" }) }), jsx("input", { type: "text", placeholder: filter.placeholder || `Search ${filter.label}...`, value: value || "", onChange: (e) => handleFilterChange(filter.key, e.target.value), className: "input pl-9" })] }));
2811
+ case "dateRange": {
2809
2812
  const rangeValue = value || {};
2810
- return (jsxs("div", { className: "flex items-center gap-2", children: [jsx("input", { type: "date", value: rangeValue.from || '', onChange: (e) => handleFilterChange(filter.key, { ...rangeValue, from: e.target.value || undefined }), className: "input text-sm", "aria-label": `${filter.label} from` }), jsx("span", { className: "text-ink-400 text-xs", children: "to" }), jsx("input", { type: "date", value: rangeValue.to || '', onChange: (e) => handleFilterChange(filter.key, { ...rangeValue, to: e.target.value || undefined }), className: "input text-sm", "aria-label": `${filter.label} to` })] }));
2811
- }
2812
- case 'toggle': {
2813
+ return (jsxs("div", { className: "flex items-center gap-2", children: [jsx("input", { type: "date", value: rangeValue.from || "", onChange: (e) => handleFilterChange(filter.key, {
2814
+ ...rangeValue,
2815
+ from: e.target.value || undefined,
2816
+ }), className: "input text-sm", "aria-label": `${filter.label} from` }), jsx("span", { className: "text-ink-400 text-xs", children: "to" }), jsx("input", { type: "date", value: rangeValue.to || "", onChange: (e) => handleFilterChange(filter.key, {
2817
+ ...rangeValue,
2818
+ to: e.target.value || undefined,
2819
+ }), className: "input text-sm", "aria-label": `${filter.label} to` })] }));
2820
+ }
2821
+ case "toggle": {
2813
2822
  const toggleOptions = [
2814
- { value: '', label: 'All' },
2815
- { value: 'true', label: 'Yes' },
2816
- { value: 'false', label: 'No' },
2823
+ { value: "", label: "All" },
2824
+ { value: "true", label: "Yes" },
2825
+ { value: "false", label: "No" },
2817
2826
  ];
2818
- const currentVal = value === null || value === undefined ? '' : String(value);
2819
- return (jsx("div", { className: "flex rounded-lg border border-paper-300 overflow-hidden", role: "group", children: toggleOptions.map((opt) => (jsx("button", { type: "button", onClick: () => handleFilterChange(filter.key, opt.value === '' ? null : opt.value === 'true'), className: `px-3 py-1.5 text-xs font-medium transition-colors ${currentVal === opt.value
2820
- ? 'bg-accent-500 text-white'
2821
- : 'bg-white text-ink-600 hover:bg-paper-50'} ${opt.value !== '' ? 'border-l border-paper-300' : ''}`, children: opt.label }, opt.value))) }));
2822
- }
2823
- case 'multiSelect': {
2827
+ const currentVal = value === null || value === undefined ? "" : String(value);
2828
+ return (jsx("div", { className: "flex rounded-lg border border-paper-300 overflow-hidden", role: "group", children: toggleOptions.map((opt) => (jsx("button", { type: "button", onClick: () => handleFilterChange(filter.key, opt.value === "" ? null : opt.value === "true"), className: `px-3 py-1.5 text-xs font-medium transition-colors ${currentVal === opt.value
2829
+ ? "bg-accent-500 text-white"
2830
+ : "bg-white text-ink-600 hover:bg-paper-50"} ${opt.value !== "" ? "border-l border-paper-300" : ""}`, children: opt.label }, opt.value))) }));
2831
+ }
2832
+ case "switch": {
2833
+ // Single binary toggle — use when the filter is naturally on/off
2834
+ // (e.g. "Mine only", "Archived"), unlike `boolean` / `toggle` which
2835
+ // present an All/Yes/No tri-state. Stored value is a plain boolean.
2836
+ const checked = value === true;
2837
+ return (jsxs("button", { type: "button", role: "switch", "aria-checked": checked, onClick: () => handleFilterChange(filter.key, !checked), className: `relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-accent-400 focus:ring-offset-2 ${checked ? "bg-accent-500" : "bg-paper-300"}`, children: [jsx("span", { className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform ${checked ? "translate-x-6" : "translate-x-1"}` }), jsx("span", { className: "sr-only", children: filter.label })] }));
2838
+ }
2839
+ case "multiSelect": {
2824
2840
  const selectedValues = Array.isArray(value) ? value : [];
2825
2841
  const msOptions = filter.options || [];
2826
- return (jsxs("div", { className: "relative", children: [jsx(Select, { options: [{ value: '', label: `All ${filter.label}` }, ...msOptions.map(o => ({ value: String(o.value), label: o.label }))], value: "", onChange: (newValue) => {
2842
+ return (jsxs("div", { className: "relative", children: [jsx(Select, { options: [
2843
+ { value: "", label: `All ${filter.label}` },
2844
+ ...msOptions.map((o) => ({
2845
+ value: String(o.value),
2846
+ label: o.label,
2847
+ })),
2848
+ ], value: "", onChange: (newValue) => {
2827
2849
  if (!newValue) {
2828
2850
  handleFilterChange(filter.key, []);
2829
2851
  }
@@ -2831,8 +2853,8 @@ function FilterBar({ filters, values, onChange, className = '', onClear, showCle
2831
2853
  handleFilterChange(filter.key, [...selectedValues, newValue]);
2832
2854
  }
2833
2855
  } }), selectedValues.length > 0 && (jsx("div", { className: "flex flex-wrap gap-1 mt-1", children: selectedValues.map((sv) => {
2834
- const opt = msOptions.find(o => String(o.value) === sv);
2835
- return (jsxs("span", { className: "inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-accent-100 text-accent-700 rounded-full", children: [opt?.label || sv, jsx("button", { type: "button", onClick: () => handleFilterChange(filter.key, selectedValues.filter(v => v !== sv)), className: "hover:text-accent-900", children: jsx(X, { className: "h-3 w-3" }) })] }, sv));
2856
+ const opt = msOptions.find((o) => String(o.value) === sv);
2857
+ return (jsxs("span", { className: "inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-accent-100 text-accent-700 rounded-full", children: [opt?.label || sv, jsx("button", { type: "button", onClick: () => handleFilterChange(filter.key, selectedValues.filter((v) => v !== sv)), className: "hover:text-accent-900", children: jsx(X, { className: "h-3 w-3" }) })] }, sv));
2836
2858
  }) }))] }));
2837
2859
  }
2838
2860
  default:
@@ -15821,44 +15843,52 @@ function getAugmentedNamespace(n) {
15821
15843
  * (A1, A1:C5, ...)
15822
15844
  */
15823
15845
 
15824
- let Collection$3 = class Collection {
15846
+ var collection;
15847
+ var hasRequiredCollection;
15848
+
15849
+ function requireCollection () {
15850
+ if (hasRequiredCollection) return collection;
15851
+ hasRequiredCollection = 1;
15852
+ class Collection {
15825
15853
 
15826
- constructor(data, refs) {
15827
- if (data == null && refs == null) {
15828
- this._data = [];
15829
- this._refs = [];
15830
- } else {
15831
- if (data.length !== refs.length)
15832
- throw Error('Collection: data length should match references length.');
15833
- this._data = data;
15834
- this._refs = refs;
15835
- }
15836
- }
15854
+ constructor(data, refs) {
15855
+ if (data == null && refs == null) {
15856
+ this._data = [];
15857
+ this._refs = [];
15858
+ } else {
15859
+ if (data.length !== refs.length)
15860
+ throw Error('Collection: data length should match references length.');
15861
+ this._data = data;
15862
+ this._refs = refs;
15863
+ }
15864
+ }
15837
15865
 
15838
- get data() {
15839
- return this._data;
15840
- }
15866
+ get data() {
15867
+ return this._data;
15868
+ }
15841
15869
 
15842
- get refs() {
15843
- return this._refs;
15844
- }
15870
+ get refs() {
15871
+ return this._refs;
15872
+ }
15845
15873
 
15846
- get length() {
15847
- return this._data.length;
15848
- }
15874
+ get length() {
15875
+ return this._data.length;
15876
+ }
15849
15877
 
15850
- /**
15851
- * Add data and references to this collection.
15852
- * @param {{}} obj - data
15853
- * @param {{}} ref - reference
15854
- */
15855
- add(obj, ref) {
15856
- this._data.push(obj);
15857
- this._refs.push(ref);
15858
- }
15859
- };
15878
+ /**
15879
+ * Add data and references to this collection.
15880
+ * @param {{}} obj - data
15881
+ * @param {{}} ref - reference
15882
+ */
15883
+ add(obj, ref) {
15884
+ this._data.push(obj);
15885
+ this._refs.push(ref);
15886
+ }
15887
+ }
15860
15888
 
15861
- var collection = Collection$3;
15889
+ collection = Collection;
15890
+ return collection;
15891
+ }
15862
15892
 
15863
15893
  var helpers;
15864
15894
  var hasRequiredHelpers;
@@ -15867,7 +15897,7 @@ function requireHelpers () {
15867
15897
  if (hasRequiredHelpers) return helpers;
15868
15898
  hasRequiredHelpers = 1;
15869
15899
  const FormulaError = requireError();
15870
- const Collection = collection;
15900
+ const Collection = requireCollection();
15871
15901
 
15872
15902
  const Types = {
15873
15903
  NUMBER: 0,
@@ -25521,7 +25551,7 @@ var engineering = EngineeringFunctions;
25521
25551
 
25522
25552
  const FormulaError$b = requireError();
25523
25553
  const {FormulaHelpers: FormulaHelpers$8, Types: Types$6, WildCard, Address: Address$3} = requireHelpers();
25524
- const Collection$2 = collection;
25554
+ const Collection$2 = requireCollection();
25525
25555
  const H$5 = FormulaHelpers$8;
25526
25556
 
25527
25557
  const ReferenceFunctions$1 = {
@@ -37149,7 +37179,7 @@ var parsing = {
37149
37179
  const FormulaError$4 = requireError();
37150
37180
  const {Address: Address$1} = requireHelpers();
37151
37181
  const {Prefix: Prefix$1, Postfix: Postfix$1, Infix: Infix$1, Operators: Operators$1} = operators;
37152
- const Collection$1 = collection;
37182
+ const Collection$1 = requireCollection();
37153
37183
  const MAX_ROW$1 = 1048576, MAX_COLUMN$1 = 16384;
37154
37184
  const {NotAllInputParsedException} = require$$4;
37155
37185
 
@@ -37911,7 +37941,7 @@ var hooks$1 = {
37911
37941
  const FormulaError$2 = requireError();
37912
37942
  const {FormulaHelpers: FormulaHelpers$1, Types, Address} = requireHelpers();
37913
37943
  const {Prefix, Postfix, Infix, Operators} = operators;
37914
- const Collection = collection;
37944
+ const Collection = requireCollection();
37915
37945
  const MAX_ROW = 1048576, MAX_COLUMN = 16384;
37916
37946
 
37917
37947
  let Utils$1 = class Utils {