@papernote/ui 2.0.3 → 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.
- package/dist/components/FilterBar.d.ts +1 -1
- package/dist/components/FilterBar.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +105 -75
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +105 -75
- package/dist/index.js.map +1 -1
- package/dist/styles.css +8 -0
- package/package.json +1 -1
- package/src/components/FilterBar.tsx +130 -53
package/dist/index.js
CHANGED
|
@@ -2765,7 +2765,7 @@ function FormControl({ label, required = false, error, helperText, children, cla
|
|
|
2765
2765
|
return (jsxRuntime.jsxs("div", { className: `${className}`, children: [label && (jsxRuntime.jsxs("label", { htmlFor: htmlFor, className: "block text-sm font-medium text-ink-700 mb-1", children: [label, required && jsxRuntime.jsx("span", { className: "text-error-500 ml-1", children: "*" })] })), jsxRuntime.jsx("div", { children: children }), (error || helperText) && (jsxRuntime.jsx("p", { className: `mt-1 text-xs ${error ? 'text-error-600' : 'text-ink-500'}`, children: error || helperText }))] }));
|
|
2766
2766
|
}
|
|
2767
2767
|
|
|
2768
|
-
function FilterBar({ filters, values, onChange, className =
|
|
2768
|
+
function FilterBar({ filters, values, onChange, className = "", onClear, showClearButton = false, }) {
|
|
2769
2769
|
const handleFilterChange = (key, value) => {
|
|
2770
2770
|
onChange({
|
|
2771
2771
|
...values,
|
|
@@ -2779,16 +2779,19 @@ function FilterBar({ filters, values, onChange, className = '', onClear, showCle
|
|
|
2779
2779
|
else {
|
|
2780
2780
|
// Default clear: set all values to null/empty
|
|
2781
2781
|
const clearedValues = {};
|
|
2782
|
-
filters.forEach(filter => {
|
|
2783
|
-
if (filter.type ===
|
|
2784
|
-
clearedValues[filter.key] =
|
|
2782
|
+
filters.forEach((filter) => {
|
|
2783
|
+
if (filter.type === "text" || filter.type === "search") {
|
|
2784
|
+
clearedValues[filter.key] = "";
|
|
2785
2785
|
}
|
|
2786
|
-
else if (filter.type ===
|
|
2786
|
+
else if (filter.type === "dateRange") {
|
|
2787
2787
|
clearedValues[filter.key] = { from: undefined, to: undefined };
|
|
2788
2788
|
}
|
|
2789
|
-
else if (filter.type ===
|
|
2789
|
+
else if (filter.type === "multiSelect") {
|
|
2790
2790
|
clearedValues[filter.key] = [];
|
|
2791
2791
|
}
|
|
2792
|
+
else if (filter.type === "switch") {
|
|
2793
|
+
clearedValues[filter.key] = false;
|
|
2794
|
+
}
|
|
2792
2795
|
else {
|
|
2793
2796
|
clearedValues[filter.key] = null;
|
|
2794
2797
|
}
|
|
@@ -2799,51 +2802,70 @@ function FilterBar({ filters, values, onChange, className = '', onClear, showCle
|
|
|
2799
2802
|
const renderFilter = (filter) => {
|
|
2800
2803
|
const value = values[filter.key];
|
|
2801
2804
|
switch (filter.type) {
|
|
2802
|
-
case
|
|
2803
|
-
return (jsxRuntime.jsx(Input, { type: "text", placeholder: filter.placeholder || `Filter by ${filter.label}`, value: value ||
|
|
2804
|
-
case
|
|
2805
|
+
case "text":
|
|
2806
|
+
return (jsxRuntime.jsx(Input, { type: "text", placeholder: filter.placeholder || `Filter by ${filter.label}`, value: value || "", onChange: (e) => handleFilterChange(filter.key, e.target.value) }));
|
|
2807
|
+
case "select": {
|
|
2805
2808
|
const selectOptions = [
|
|
2806
|
-
{ value:
|
|
2807
|
-
...(filter.options?.map(opt => ({
|
|
2809
|
+
{ value: "", label: `All ${filter.label}` },
|
|
2810
|
+
...(filter.options?.map((opt) => ({
|
|
2808
2811
|
value: String(opt.value),
|
|
2809
2812
|
label: opt.label,
|
|
2810
2813
|
})) || []),
|
|
2811
2814
|
];
|
|
2812
|
-
return (jsxRuntime.jsx(Select, { options: selectOptions, value: String(value ||
|
|
2815
|
+
return (jsxRuntime.jsx(Select, { options: selectOptions, value: String(value || ""), onChange: (newValue) => handleFilterChange(filter.key, newValue || null) }));
|
|
2813
2816
|
}
|
|
2814
|
-
case
|
|
2815
|
-
return (jsxRuntime.jsx("input", { type: "date", value: value ||
|
|
2816
|
-
case
|
|
2817
|
-
return (jsxRuntime.jsx("input", { type: "number", placeholder: filter.placeholder || `Filter by ${filter.label}`, value: value !== null && value !== undefined ? String(value) :
|
|
2818
|
-
case
|
|
2817
|
+
case "date":
|
|
2818
|
+
return (jsxRuntime.jsx("input", { type: "date", value: value || "", onChange: (e) => handleFilterChange(filter.key, e.target.value), className: "input" }));
|
|
2819
|
+
case "number":
|
|
2820
|
+
return (jsxRuntime.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" }));
|
|
2821
|
+
case "boolean": {
|
|
2819
2822
|
const boolOptions = [
|
|
2820
|
-
{ value:
|
|
2821
|
-
{ value:
|
|
2822
|
-
{ value:
|
|
2823
|
+
{ value: "", label: "All" },
|
|
2824
|
+
{ value: "true", label: "Yes" },
|
|
2825
|
+
{ value: "false", label: "No" },
|
|
2823
2826
|
];
|
|
2824
|
-
return (jsxRuntime.jsx(Select, { options: boolOptions, value: value === null || value === undefined ?
|
|
2827
|
+
return (jsxRuntime.jsx(Select, { options: boolOptions, value: value === null || value === undefined ? "" : String(value), onChange: (newValue) => handleFilterChange(filter.key, newValue === "" ? null : newValue === "true") }));
|
|
2825
2828
|
}
|
|
2826
|
-
case
|
|
2827
|
-
return (jsxRuntime.jsxs("div", { className: "relative", children: [jsxRuntime.jsx("div", { className: "absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none", children: jsxRuntime.jsx(lucideReact.Search, { className: "h-4 w-4 text-ink-400" }) }), jsxRuntime.jsx("input", { type: "text", placeholder: filter.placeholder || `Search ${filter.label}...`, value: value ||
|
|
2828
|
-
case
|
|
2829
|
+
case "search":
|
|
2830
|
+
return (jsxRuntime.jsxs("div", { className: "relative", children: [jsxRuntime.jsx("div", { className: "absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none", children: jsxRuntime.jsx(lucideReact.Search, { className: "h-4 w-4 text-ink-400" }) }), jsxRuntime.jsx("input", { type: "text", placeholder: filter.placeholder || `Search ${filter.label}...`, value: value || "", onChange: (e) => handleFilterChange(filter.key, e.target.value), className: "input pl-9" })] }));
|
|
2831
|
+
case "dateRange": {
|
|
2829
2832
|
const rangeValue = value || {};
|
|
2830
|
-
return (jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx("input", { type: "date", value: rangeValue.from ||
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
+
return (jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx("input", { type: "date", value: rangeValue.from || "", onChange: (e) => handleFilterChange(filter.key, {
|
|
2834
|
+
...rangeValue,
|
|
2835
|
+
from: e.target.value || undefined,
|
|
2836
|
+
}), className: "input text-sm", "aria-label": `${filter.label} from` }), jsxRuntime.jsx("span", { className: "text-ink-400 text-xs", children: "to" }), jsxRuntime.jsx("input", { type: "date", value: rangeValue.to || "", onChange: (e) => handleFilterChange(filter.key, {
|
|
2837
|
+
...rangeValue,
|
|
2838
|
+
to: e.target.value || undefined,
|
|
2839
|
+
}), className: "input text-sm", "aria-label": `${filter.label} to` })] }));
|
|
2840
|
+
}
|
|
2841
|
+
case "toggle": {
|
|
2833
2842
|
const toggleOptions = [
|
|
2834
|
-
{ value:
|
|
2835
|
-
{ value:
|
|
2836
|
-
{ value:
|
|
2843
|
+
{ value: "", label: "All" },
|
|
2844
|
+
{ value: "true", label: "Yes" },
|
|
2845
|
+
{ value: "false", label: "No" },
|
|
2837
2846
|
];
|
|
2838
|
-
const currentVal = value === null || value === undefined ?
|
|
2839
|
-
return (jsxRuntime.jsx("div", { className: "flex rounded-lg border border-paper-300 overflow-hidden", role: "group", children: toggleOptions.map((opt) => (jsxRuntime.jsx("button", { type: "button", onClick: () => handleFilterChange(filter.key, opt.value ===
|
|
2840
|
-
?
|
|
2841
|
-
:
|
|
2842
|
-
}
|
|
2843
|
-
case
|
|
2847
|
+
const currentVal = value === null || value === undefined ? "" : String(value);
|
|
2848
|
+
return (jsxRuntime.jsx("div", { className: "flex rounded-lg border border-paper-300 overflow-hidden", role: "group", children: toggleOptions.map((opt) => (jsxRuntime.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
|
|
2849
|
+
? "bg-accent-500 text-white"
|
|
2850
|
+
: "bg-white text-ink-600 hover:bg-paper-50"} ${opt.value !== "" ? "border-l border-paper-300" : ""}`, children: opt.label }, opt.value))) }));
|
|
2851
|
+
}
|
|
2852
|
+
case "switch": {
|
|
2853
|
+
// Single binary toggle — use when the filter is naturally on/off
|
|
2854
|
+
// (e.g. "Mine only", "Archived"), unlike `boolean` / `toggle` which
|
|
2855
|
+
// present an All/Yes/No tri-state. Stored value is a plain boolean.
|
|
2856
|
+
const checked = value === true;
|
|
2857
|
+
return (jsxRuntime.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: [jsxRuntime.jsx("span", { className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform ${checked ? "translate-x-6" : "translate-x-1"}` }), jsxRuntime.jsx("span", { className: "sr-only", children: filter.label })] }));
|
|
2858
|
+
}
|
|
2859
|
+
case "multiSelect": {
|
|
2844
2860
|
const selectedValues = Array.isArray(value) ? value : [];
|
|
2845
2861
|
const msOptions = filter.options || [];
|
|
2846
|
-
return (jsxRuntime.jsxs("div", { className: "relative", children: [jsxRuntime.jsx(Select, { options: [
|
|
2862
|
+
return (jsxRuntime.jsxs("div", { className: "relative", children: [jsxRuntime.jsx(Select, { options: [
|
|
2863
|
+
{ value: "", label: `All ${filter.label}` },
|
|
2864
|
+
...msOptions.map((o) => ({
|
|
2865
|
+
value: String(o.value),
|
|
2866
|
+
label: o.label,
|
|
2867
|
+
})),
|
|
2868
|
+
], value: "", onChange: (newValue) => {
|
|
2847
2869
|
if (!newValue) {
|
|
2848
2870
|
handleFilterChange(filter.key, []);
|
|
2849
2871
|
}
|
|
@@ -2851,8 +2873,8 @@ function FilterBar({ filters, values, onChange, className = '', onClear, showCle
|
|
|
2851
2873
|
handleFilterChange(filter.key, [...selectedValues, newValue]);
|
|
2852
2874
|
}
|
|
2853
2875
|
} }), selectedValues.length > 0 && (jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1 mt-1", children: selectedValues.map((sv) => {
|
|
2854
|
-
const opt = msOptions.find(o => String(o.value) === sv);
|
|
2855
|
-
return (jsxRuntime.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, jsxRuntime.jsx("button", { type: "button", onClick: () => handleFilterChange(filter.key, selectedValues.filter(v => v !== sv)), className: "hover:text-accent-900", children: jsxRuntime.jsx(lucideReact.X, { className: "h-3 w-3" }) })] }, sv));
|
|
2876
|
+
const opt = msOptions.find((o) => String(o.value) === sv);
|
|
2877
|
+
return (jsxRuntime.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, jsxRuntime.jsx("button", { type: "button", onClick: () => handleFilterChange(filter.key, selectedValues.filter((v) => v !== sv)), className: "hover:text-accent-900", children: jsxRuntime.jsx(lucideReact.X, { className: "h-3 w-3" }) })] }, sv));
|
|
2856
2878
|
}) }))] }));
|
|
2857
2879
|
}
|
|
2858
2880
|
default:
|
|
@@ -15841,44 +15863,52 @@ function getAugmentedNamespace(n) {
|
|
|
15841
15863
|
* (A1, A1:C5, ...)
|
|
15842
15864
|
*/
|
|
15843
15865
|
|
|
15844
|
-
|
|
15866
|
+
var collection;
|
|
15867
|
+
var hasRequiredCollection;
|
|
15868
|
+
|
|
15869
|
+
function requireCollection () {
|
|
15870
|
+
if (hasRequiredCollection) return collection;
|
|
15871
|
+
hasRequiredCollection = 1;
|
|
15872
|
+
class Collection {
|
|
15845
15873
|
|
|
15846
|
-
|
|
15847
|
-
|
|
15848
|
-
|
|
15849
|
-
|
|
15850
|
-
|
|
15851
|
-
|
|
15852
|
-
|
|
15853
|
-
|
|
15854
|
-
|
|
15855
|
-
|
|
15856
|
-
|
|
15874
|
+
constructor(data, refs) {
|
|
15875
|
+
if (data == null && refs == null) {
|
|
15876
|
+
this._data = [];
|
|
15877
|
+
this._refs = [];
|
|
15878
|
+
} else {
|
|
15879
|
+
if (data.length !== refs.length)
|
|
15880
|
+
throw Error('Collection: data length should match references length.');
|
|
15881
|
+
this._data = data;
|
|
15882
|
+
this._refs = refs;
|
|
15883
|
+
}
|
|
15884
|
+
}
|
|
15857
15885
|
|
|
15858
|
-
|
|
15859
|
-
|
|
15860
|
-
|
|
15886
|
+
get data() {
|
|
15887
|
+
return this._data;
|
|
15888
|
+
}
|
|
15861
15889
|
|
|
15862
|
-
|
|
15863
|
-
|
|
15864
|
-
|
|
15890
|
+
get refs() {
|
|
15891
|
+
return this._refs;
|
|
15892
|
+
}
|
|
15865
15893
|
|
|
15866
|
-
|
|
15867
|
-
|
|
15868
|
-
|
|
15894
|
+
get length() {
|
|
15895
|
+
return this._data.length;
|
|
15896
|
+
}
|
|
15869
15897
|
|
|
15870
|
-
|
|
15871
|
-
|
|
15872
|
-
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15878
|
-
|
|
15879
|
-
}
|
|
15898
|
+
/**
|
|
15899
|
+
* Add data and references to this collection.
|
|
15900
|
+
* @param {{}} obj - data
|
|
15901
|
+
* @param {{}} ref - reference
|
|
15902
|
+
*/
|
|
15903
|
+
add(obj, ref) {
|
|
15904
|
+
this._data.push(obj);
|
|
15905
|
+
this._refs.push(ref);
|
|
15906
|
+
}
|
|
15907
|
+
}
|
|
15880
15908
|
|
|
15881
|
-
|
|
15909
|
+
collection = Collection;
|
|
15910
|
+
return collection;
|
|
15911
|
+
}
|
|
15882
15912
|
|
|
15883
15913
|
var helpers;
|
|
15884
15914
|
var hasRequiredHelpers;
|
|
@@ -15887,7 +15917,7 @@ function requireHelpers () {
|
|
|
15887
15917
|
if (hasRequiredHelpers) return helpers;
|
|
15888
15918
|
hasRequiredHelpers = 1;
|
|
15889
15919
|
const FormulaError = requireError();
|
|
15890
|
-
const Collection =
|
|
15920
|
+
const Collection = requireCollection();
|
|
15891
15921
|
|
|
15892
15922
|
const Types = {
|
|
15893
15923
|
NUMBER: 0,
|
|
@@ -25541,7 +25571,7 @@ var engineering = EngineeringFunctions;
|
|
|
25541
25571
|
|
|
25542
25572
|
const FormulaError$b = requireError();
|
|
25543
25573
|
const {FormulaHelpers: FormulaHelpers$8, Types: Types$6, WildCard, Address: Address$3} = requireHelpers();
|
|
25544
|
-
const Collection$2 =
|
|
25574
|
+
const Collection$2 = requireCollection();
|
|
25545
25575
|
const H$5 = FormulaHelpers$8;
|
|
25546
25576
|
|
|
25547
25577
|
const ReferenceFunctions$1 = {
|
|
@@ -37169,7 +37199,7 @@ var parsing = {
|
|
|
37169
37199
|
const FormulaError$4 = requireError();
|
|
37170
37200
|
const {Address: Address$1} = requireHelpers();
|
|
37171
37201
|
const {Prefix: Prefix$1, Postfix: Postfix$1, Infix: Infix$1, Operators: Operators$1} = operators;
|
|
37172
|
-
const Collection$1 =
|
|
37202
|
+
const Collection$1 = requireCollection();
|
|
37173
37203
|
const MAX_ROW$1 = 1048576, MAX_COLUMN$1 = 16384;
|
|
37174
37204
|
const {NotAllInputParsedException} = require$$4;
|
|
37175
37205
|
|
|
@@ -37931,7 +37961,7 @@ var hooks$1 = {
|
|
|
37931
37961
|
const FormulaError$2 = requireError();
|
|
37932
37962
|
const {FormulaHelpers: FormulaHelpers$1, Types, Address} = requireHelpers();
|
|
37933
37963
|
const {Prefix, Postfix, Infix, Operators} = operators;
|
|
37934
|
-
const Collection =
|
|
37964
|
+
const Collection = requireCollection();
|
|
37935
37965
|
const MAX_ROW = 1048576, MAX_COLUMN = 16384;
|
|
37936
37966
|
|
|
37937
37967
|
let Utils$1 = class Utils {
|