basalt-ui 2.13.3 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/MIGRATING.md +36 -12
- package/dist/agent/chat/thread-feed-row.d.ts.map +1 -1
- package/dist/agent/chat/thread-feed-row.js +2 -2
- package/dist/agent/chat/thread-message.d.ts.map +1 -1
- package/dist/agent/chat/thread-message.js +2 -2
- package/dist/agent/chat/thread-outcome-card.js +2 -2
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +1 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +3 -2
- package/dist/charts/cursor.d.ts +10 -6
- package/dist/charts/cursor.d.ts.map +1 -1
- package/dist/charts/cursor.js +20 -13
- package/dist/charts/legend.d.ts +5 -4
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +3 -3
- package/dist/charts/panel.d.ts +2 -0
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +1 -0
- package/dist/commands/notifications/center.d.ts.map +1 -1
- package/dist/commands/notifications/center.js +2 -11
- package/dist/controls/control-name.d.ts +27 -0
- package/dist/controls/control-name.d.ts.map +1 -0
- package/dist/controls/control-name.js +11 -0
- package/dist/controls/enum-filter.d.ts +3 -6
- package/dist/controls/enum-filter.d.ts.map +1 -1
- package/dist/controls/enum-filter.js +8 -4
- package/dist/controls/filter-base.d.ts +30 -0
- package/dist/controls/filter-base.d.ts.map +1 -0
- package/dist/controls/filter-base.js +0 -0
- package/dist/controls/filter-pill.d.ts +3 -1
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +2 -0
- package/dist/controls/filter-sheet.d.ts +0 -32
- package/dist/controls/filter-sheet.d.ts.map +1 -1
- package/dist/controls/filter-sheet.js +1 -28
- package/dist/controls/glyphs.d.ts +12 -0
- package/dist/controls/glyphs.d.ts.map +1 -1
- package/dist/controls/glyphs.js +23 -2
- package/dist/controls/index.d.ts +2 -1
- package/dist/controls/index.d.ts.map +1 -1
- package/dist/controls/multi-select-filter.d.ts +8 -3
- package/dist/controls/multi-select-filter.d.ts.map +1 -1
- package/dist/controls/multi-select-filter.js +27 -10
- package/dist/controls/number-filter.d.ts +3 -12
- package/dist/controls/number-filter.d.ts.map +1 -1
- package/dist/controls/number-filter.js +17 -6
- package/dist/controls/panel-row.d.ts +5 -8
- package/dist/controls/panel-row.d.ts.map +1 -1
- package/dist/controls/panel-row.js +3 -0
- package/dist/controls/range-filter.d.ts +14 -14
- package/dist/controls/range-filter.d.ts.map +1 -1
- package/dist/controls/range-filter.js +18 -41
- package/dist/controls/search-filter.d.ts +5 -2
- package/dist/controls/search-filter.d.ts.map +1 -1
- package/dist/controls/search-filter.js +74 -40
- package/dist/controls/select-filter.d.ts +2 -15
- package/dist/controls/select-filter.d.ts.map +1 -1
- package/dist/controls/sync-button.d.ts +0 -6
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/controls/sync-button.js +6 -36
- package/dist/controls/toggle-filter.d.ts +2 -2
- package/dist/controls/toggle-filter.d.ts.map +1 -1
- package/dist/controls/toggle-filter.js +3 -2
- package/dist/controls/view-tabs.d.ts +3 -4
- package/dist/controls/view-tabs.d.ts.map +1 -1
- package/dist/controls/view-tabs.js +24 -5
- package/dist/format/date.d.ts +43 -10
- package/dist/format/date.d.ts.map +1 -1
- package/dist/format/date.js +109 -18
- package/dist/format/index.d.ts +12 -11
- package/dist/format/index.d.ts.map +1 -1
- package/dist/format/index.js +11 -2
- package/dist/format/measure.d.ts +9 -9
- package/dist/format/measure.d.ts.map +1 -1
- package/dist/format/measure.js +19 -8
- package/dist/format/number.d.ts +35 -27
- package/dist/format/number.d.ts.map +1 -1
- package/dist/format/number.js +41 -20
- package/dist/format/shared.d.ts +38 -7
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +61 -13
- package/dist/provider/index.d.ts +13 -1
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +8 -0
- package/llms.txt +35 -14
- package/package.json +1 -1
- package/src/agent/chat/thread-feed-row.tsx +2 -2
- package/src/agent/chat/thread-message.tsx +2 -2
- package/src/agent/chat/thread-outcome-card.tsx +2 -2
- package/src/charts/DualPanel.tsx +1 -0
- package/src/charts/compile.ts +3 -2
- package/src/charts/cursor.ts +44 -27
- package/src/charts/legend.tsx +9 -6
- package/src/charts/panel.tsx +3 -0
- package/src/commands/notifications/center.tsx +2 -14
- package/src/controls/control-name.ts +33 -0
- package/src/controls/enum-filter.tsx +29 -27
- package/src/controls/filter-base.ts +31 -0
- package/src/controls/filter-pill.tsx +4 -0
- package/src/controls/filter-sheet.tsx +0 -56
- package/src/controls/glyphs.tsx +45 -2
- package/src/controls/index.ts +2 -1
- package/src/controls/multi-select-filter.tsx +67 -43
- package/src/controls/number-filter.tsx +47 -47
- package/src/controls/panel-row.tsx +7 -8
- package/src/controls/range-filter.tsx +54 -78
- package/src/controls/search-filter.tsx +107 -54
- package/src/controls/select-filter.tsx +2 -18
- package/src/controls/sync-button.tsx +7 -40
- package/src/controls/toggle-filter.tsx +9 -7
- package/src/controls/view-tabs.tsx +41 -21
- package/src/format/date.ts +189 -36
- package/src/format/index.ts +12 -11
- package/src/format/measure.ts +29 -18
- package/src/format/number.ts +76 -37
- package/src/format/shared.ts +116 -25
- package/src/provider/index.tsx +23 -0
- package/dist/agent/chat/relative-time.d.ts +0 -27
- package/dist/agent/chat/relative-time.d.ts.map +0 -1
- package/dist/agent/chat/relative-time.js +0 -27
- package/src/agent/chat/relative-time.ts +0 -55
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel-row.d.ts","sourceRoot":"","sources":["../../src/controls/panel-row.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"panel-row.d.ts","sourceRoot":"","sources":["../../src/controls/panel-row.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,IAAI,CAAA;AAEhC,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG;IACxC,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAA;IAC5B;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAA;IACxB,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,gFAAgF;IAChF,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B,CAAA;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,IAAI,EACJ,OAAO,EACP,GAAG,EACH,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,GACN,EAAE,aAAa,GAAG,SAAS,CAiC3B;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,uFAAuF;IACvF,QAAQ,CAAC,SAAS,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAA;IACzC,kCAAkC;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,gGAAgG;IAChG,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC1C,CAAA;AAyDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,GACd;IAAE,OAAO,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CA0F9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,EAC1B,SAAS,EACT,KAAK,EACL,OAAO,EACP,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,gBAAgB,GAAG,SAAS,CAmC9B"}
|
|
@@ -129,6 +129,7 @@ function PanelChoice({
|
|
|
129
129
|
value,
|
|
130
130
|
options,
|
|
131
131
|
numeric,
|
|
132
|
+
disabled,
|
|
132
133
|
onChange
|
|
133
134
|
}) {
|
|
134
135
|
const data = options.map((option) => ({
|
|
@@ -147,6 +148,7 @@ function PanelChoice({
|
|
|
147
148
|
fullWidth: true,
|
|
148
149
|
value,
|
|
149
150
|
data,
|
|
151
|
+
...disabled === true && { disabled: true },
|
|
150
152
|
...numeric === true && { "data-numeric": true },
|
|
151
153
|
onChange
|
|
152
154
|
}
|
|
@@ -159,6 +161,7 @@ function PanelChoice({
|
|
|
159
161
|
value,
|
|
160
162
|
allowDeselect: false,
|
|
161
163
|
data,
|
|
164
|
+
...disabled === true && { disabled: true },
|
|
162
165
|
onChange: (next) => {
|
|
163
166
|
if (next !== null) onChange(next);
|
|
164
167
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
2
|
import type { FieldHandle } from '../state.js';
|
|
3
3
|
import type { RangeField } from '../state/fields.js';
|
|
4
|
+
import type { FilterBase } from './filter-base.js';
|
|
4
5
|
import type { UncontrolledProps } from './uncontrolled.js';
|
|
5
6
|
/**
|
|
6
7
|
* The contract a custom-range picker satisfies — `basalt-ui/controls-dates`' `DateRangePicker`, or a
|
|
@@ -18,7 +19,9 @@ export type RangeCustomPickerProps = {
|
|
|
18
19
|
}) => void;
|
|
19
20
|
};
|
|
20
21
|
/** Everything about the props that does not depend on the field's `custom` flag. */
|
|
21
|
-
type
|
|
22
|
+
type RangeFilterCommon<P extends string, C extends boolean> = UncontrolledProps & Omit<FilterBase, 'clearable' | 'label'> & {
|
|
23
|
+
/** Sheet-form heading. The pill's own label is the VALUE, which is what a bar reads. @default 'Range' */
|
|
24
|
+
readonly label?: string;
|
|
22
25
|
/**
|
|
23
26
|
* A range handle from either store factory. Generic over the field's `custom` flag so a
|
|
24
27
|
* `field.range({ ... })` WITHOUT `custom` (whose handle is `RangeField<P, false>`, and whose
|
|
@@ -26,20 +29,17 @@ type RangeFilterBase<P extends string, C extends boolean> = UncontrolledProps &
|
|
|
26
29
|
* `boolean` here made the setter contravariantly incompatible and forced one at every call site.
|
|
27
30
|
*/
|
|
28
31
|
readonly field: FieldHandle<RangeField<P, C>>;
|
|
29
|
-
/** Leading pill icon. Defaults to a calendar glyph — a range filter reads as a date control, so
|
|
30
|
-
* the glyph is part of the control's identity, not a per-call-site decision. */
|
|
31
|
-
readonly icon?: ReactNode;
|
|
32
|
-
/** Sheet-form heading. The pill's own label is the VALUE, which is what a bar reads. @default 'Range' */
|
|
33
|
-
readonly label?: string;
|
|
34
|
-
};
|
|
35
|
-
export type RangeFilterProps<P extends string, C extends boolean = boolean> = RangeFilterBase<P, C> & {
|
|
36
|
-
/**
|
|
37
|
-
* Rendered when the field declares `custom: true`. Omitted → presets only, which stays LEGAL
|
|
38
|
-
* (a range that only ever shows presets is a real configuration) but warns once in dev when the
|
|
39
|
-
* field allows a custom window: the affordance is then unreachable, and nothing else says so.
|
|
40
|
-
*/
|
|
41
|
-
readonly customPicker?: ComponentType<RangeCustomPickerProps>;
|
|
42
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* `customPicker` is REQUIRED exactly when the field is `custom: true` and FORBIDDEN otherwise, so
|
|
35
|
+
* the unreachable-affordance state (a custom window nobody can pick) is a type error instead of a
|
|
36
|
+
* dev warning. A widened handle (`C = boolean`) cannot say which, so it must supply the picker.
|
|
37
|
+
*/
|
|
38
|
+
export type RangeFilterProps<P extends string, C extends boolean = boolean> = RangeFilterCommon<P, C> & ([C] extends [false] ? {
|
|
39
|
+
readonly customPicker?: never;
|
|
40
|
+
} : {
|
|
41
|
+
readonly customPicker: ComponentType<RangeCustomPickerProps>;
|
|
42
|
+
});
|
|
43
43
|
export declare function RangeFilter<P extends string, C extends boolean = boolean>(props: RangeFilterProps<P, C>): ReactNode;
|
|
44
44
|
export {};
|
|
45
45
|
//# sourceMappingURL=range-filter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range-filter.d.ts","sourceRoot":"","sources":["../../src/controls/range-filter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"range-filter.d.ts","sourceRoot":"","sources":["../../src/controls/range-filter.tsx"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,iBAAiB,CAAA;AAG7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAK/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAUvD;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;IACxF,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CAChE,CAAA;AAED,oFAAoF;AACpF,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,IAAI,iBAAiB,GAC7E,IAAI,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG;IACxC,yGAAyG;IACzG,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;CAC9C,CAAA;AAEH;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,iBAAiB,CAC7F,CAAC,EACD,CAAC,CACF,GACC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAChB;IAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,KAAK,CAAA;CAAE,GACjC;IAAE,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAA;CAAE,CAAC,CAAA;AAEvE,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,GAAG,OAAO,EACvE,KAAK,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,SAAS,CAAA"}
|
|
@@ -6,33 +6,16 @@ import classes from "./controls.module.css";
|
|
|
6
6
|
import { useFilterRegistration, useFilterSurface } from "./filter-context.js";
|
|
7
7
|
import { FilterPill } from "./filter-pill.js";
|
|
8
8
|
import { CalendarGlyph } from "./glyphs.js";
|
|
9
|
-
import { useControlName } from "./
|
|
9
|
+
import { useControlName } from "./control-name.js";
|
|
10
10
|
import { PanelRow } from "./panel-row.js";
|
|
11
11
|
const VERTICAL_FROM = 5;
|
|
12
12
|
const CUSTOM_ROW_LABEL = "Custom range\u2026";
|
|
13
13
|
const NUMERIC_LABEL = /^\d/;
|
|
14
|
-
const noPickerWarned = /* @__PURE__ */ new Set();
|
|
15
|
-
function warnCustomWithoutPicker(label, unreachable) {
|
|
16
|
-
if (!unreachable || process.env.NODE_ENV === "production" || noPickerWarned.has(label)) return;
|
|
17
|
-
noPickerWarned.add(label);
|
|
18
|
-
console.warn(
|
|
19
|
-
`[basalt-ui] RangeFilter('${label}'): the field declares \`custom: true\` but no \`customPicker\` was injected, so the custom window cannot be reached. Pass \`customPicker={DateRangePicker}\` (\`basalt-ui/controls-dates\`), or drop \`custom: true\` from the field. (dev only)`
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
14
|
function RangeFilter(props) {
|
|
23
15
|
assertRequiredProps("RangeFilter", props, ["field"], {
|
|
24
16
|
field: "bind it to a store field (`store.field.<name>`), never a value/onChange pair."
|
|
25
17
|
});
|
|
26
|
-
const {
|
|
27
|
-
field,
|
|
28
|
-
icon,
|
|
29
|
-
customPicker,
|
|
30
|
-
label = "Range",
|
|
31
|
-
className,
|
|
32
|
-
style
|
|
33
|
-
// One cast, at the one boundary a generic `C` cannot be read through: `C` only ever describes
|
|
34
|
-
// the FIELD's custom flag, and the body handles both.
|
|
35
|
-
} = props;
|
|
18
|
+
const { field, icon, disabled, customPicker: Picker, label = "Range", className, style } = props;
|
|
36
19
|
const [value, setValue] = field.use();
|
|
37
20
|
const surface = useFilterSurface();
|
|
38
21
|
const isDefault = field.isDefault(value);
|
|
@@ -45,8 +28,6 @@ function RangeFilter(props) {
|
|
|
45
28
|
const numeric = presets.length > 0 && presets.every((option) => NUMERIC_LABEL.test(option.label));
|
|
46
29
|
const inSheet = surface === "sheet";
|
|
47
30
|
const inPanel = surface === "panel";
|
|
48
|
-
const Picker = customPicker;
|
|
49
|
-
warnCustomWithoutPicker(label, allowsCustom && Picker === void 0);
|
|
50
31
|
const { labelId, nameProps } = useControlName(label, inSheet || inPanel);
|
|
51
32
|
const [customOpen, setCustomOpen] = useState(value.preset === "custom");
|
|
52
33
|
const seenPreset = useRef(value.preset);
|
|
@@ -55,7 +36,16 @@ function RangeFilter(props) {
|
|
|
55
36
|
seenPreset.current = value.preset;
|
|
56
37
|
setCustomOpen(value.preset === "custom");
|
|
57
38
|
}, [value.preset]);
|
|
58
|
-
const
|
|
39
|
+
const picker = allowsCustom && Picker !== void 0 ? /* @__PURE__ */ jsx(
|
|
40
|
+
Picker,
|
|
41
|
+
{
|
|
42
|
+
value: { from: value.from, to: value.to },
|
|
43
|
+
onChange: ({ from, to }) => {
|
|
44
|
+
if (disabled === true) return;
|
|
45
|
+
setValue({ preset: "custom", from, to });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
) : null;
|
|
59
49
|
if (inPanel || inSheet) {
|
|
60
50
|
return /* @__PURE__ */ jsxs(
|
|
61
51
|
PanelRow,
|
|
@@ -70,10 +60,11 @@ function RangeFilter(props) {
|
|
|
70
60
|
{
|
|
71
61
|
...nameProps,
|
|
72
62
|
allowDeselect: false,
|
|
63
|
+
...disabled === true && { disabled: true },
|
|
73
64
|
value: customOpen ? "custom" : value.preset,
|
|
74
65
|
data: [
|
|
75
66
|
...presets.map((option) => ({ value: option.value, label: option.label })),
|
|
76
|
-
...
|
|
67
|
+
...picker !== null ? [{ value: "custom", label: CUSTOM_ROW_LABEL }] : []
|
|
77
68
|
],
|
|
78
69
|
onChange: (next) => {
|
|
79
70
|
if (next === null) return;
|
|
@@ -86,15 +77,7 @@ function RangeFilter(props) {
|
|
|
86
77
|
}
|
|
87
78
|
}
|
|
88
79
|
),
|
|
89
|
-
|
|
90
|
-
Picker,
|
|
91
|
-
{
|
|
92
|
-
value: { from: value.from, to: value.to },
|
|
93
|
-
onChange: ({ from, to }) => {
|
|
94
|
-
setValue({ preset: "custom", from, to });
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
)
|
|
80
|
+
customOpen && picker
|
|
98
81
|
]
|
|
99
82
|
}
|
|
100
83
|
);
|
|
@@ -105,6 +88,7 @@ function RangeFilter(props) {
|
|
|
105
88
|
{
|
|
106
89
|
...nameProps,
|
|
107
90
|
size: "ctl",
|
|
91
|
+
...disabled === true && { disabled: true },
|
|
108
92
|
orientation: presets.length >= VERTICAL_FROM ? "vertical" : "horizontal",
|
|
109
93
|
value: value.preset,
|
|
110
94
|
data: presets.map((option) => ({ value: option.value, label: option.label })),
|
|
@@ -114,15 +98,7 @@ function RangeFilter(props) {
|
|
|
114
98
|
}
|
|
115
99
|
}
|
|
116
100
|
),
|
|
117
|
-
|
|
118
|
-
Picker,
|
|
119
|
-
{
|
|
120
|
-
value: { from: value.from, to: value.to },
|
|
121
|
-
onChange: ({ from, to }) => {
|
|
122
|
-
setValue({ preset: "custom", from, to });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
)
|
|
101
|
+
picker
|
|
126
102
|
] });
|
|
127
103
|
return /* @__PURE__ */ jsx(
|
|
128
104
|
FilterPill,
|
|
@@ -130,6 +106,7 @@ function RangeFilter(props) {
|
|
|
130
106
|
label: rangeLabel(value, options),
|
|
131
107
|
active: !isDefault,
|
|
132
108
|
numeric: numeric && value.preset !== "custom",
|
|
109
|
+
...disabled === true && { disabled: true },
|
|
133
110
|
icon: icon ?? /* @__PURE__ */ jsx(CalendarGlyph, {}),
|
|
134
111
|
...className !== void 0 && { className },
|
|
135
112
|
...style !== void 0 && { style },
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { FieldHandle } from '../state.js';
|
|
3
3
|
import type { StringField } from '../state/fields.js';
|
|
4
|
+
import type { FilterBase } from './filter-base.js';
|
|
4
5
|
import type { UncontrolledProps } from './uncontrolled.js';
|
|
5
|
-
export type SearchFilterProps = UncontrolledProps & {
|
|
6
|
+
export type SearchFilterProps = UncontrolledProps & Omit<FilterBase, 'icon' | 'label' | 'clearable'> & {
|
|
6
7
|
readonly field: FieldHandle<StringField>;
|
|
7
8
|
readonly placeholder?: string;
|
|
8
|
-
/** Sheet-form heading. @default 'Search' */
|
|
9
|
+
/** Sheet-form heading and the accessible name. @default 'Search' */
|
|
9
10
|
readonly label?: string;
|
|
11
|
+
/** The clear button shown while the box holds text. @default true */
|
|
12
|
+
readonly clearable?: boolean;
|
|
10
13
|
};
|
|
11
14
|
export declare function SearchFilter(props: SearchFilterProps): ReactNode;
|
|
12
15
|
//# sourceMappingURL=search-filter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-filter.d.ts","sourceRoot":"","sources":["../../src/controls/search-filter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search-filter.d.ts","sourceRoot":"","sources":["../../src/controls/search-filter.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAI/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAKvD,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAC/C,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC,GAAG;IACjD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,CAAA;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,qEAAqE;IACrE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAoFhE"}
|
|
@@ -1,42 +1,73 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { TextInput } from "@mantine/core";
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CloseButton, TextInput } from "@mantine/core";
|
|
3
3
|
import { useDebouncedCallback } from "@mantine/hooks";
|
|
4
4
|
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { useIsomorphicLayoutEffect } from "../common/isomorphic-layout-effect.js";
|
|
5
6
|
import { assertRequiredProps } from "../common/validate.js";
|
|
7
|
+
import { useControlName } from "./control-name.js";
|
|
6
8
|
import { useFilterRegistration, useFilterSurface } from "./filter-context.js";
|
|
7
|
-
import {
|
|
9
|
+
import { SearchGlyph } from "./glyphs.js";
|
|
8
10
|
import { PanelRow } from "./panel-row.js";
|
|
9
11
|
const DEBOUNCE_MS = 200;
|
|
10
12
|
function SearchFilter(props) {
|
|
11
13
|
assertRequiredProps("SearchFilter", props, ["field"], {
|
|
12
14
|
field: "bind it to a store field (`store.field.<name>`), never a value/onChange pair."
|
|
13
15
|
});
|
|
14
|
-
const {
|
|
16
|
+
const {
|
|
17
|
+
field,
|
|
18
|
+
placeholder,
|
|
19
|
+
label = "Search",
|
|
20
|
+
clearable = true,
|
|
21
|
+
disabled,
|
|
22
|
+
className,
|
|
23
|
+
style
|
|
24
|
+
} = props;
|
|
15
25
|
const [value, setValue] = field.use();
|
|
16
26
|
const surface = useFilterSurface();
|
|
17
|
-
const draft = useDebouncedField(value, setValue)
|
|
18
|
-
useFilterRegistration(!field.isDefault(value), () => {
|
|
27
|
+
const draft = useDebouncedField(value, setValue, () => {
|
|
19
28
|
field.clear();
|
|
20
29
|
});
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
30
|
+
useFilterRegistration(!field.isDefault(value), draft.clear);
|
|
31
|
+
const inRow = surface === "sheet" || surface === "panel";
|
|
32
|
+
const { labelId, nameProps } = useControlName(label, inRow);
|
|
24
33
|
const input = /* @__PURE__ */ jsx(
|
|
25
34
|
TextInput,
|
|
26
35
|
{
|
|
27
36
|
...nameProps,
|
|
28
37
|
size: "ctl",
|
|
38
|
+
type: "search",
|
|
39
|
+
enterKeyHint: "search",
|
|
29
40
|
value: draft.value,
|
|
30
|
-
leftSection: /* @__PURE__ */ jsx(
|
|
41
|
+
leftSection: /* @__PURE__ */ jsx(SearchGlyph, {}),
|
|
42
|
+
rightSectionPointerEvents: "all",
|
|
43
|
+
...clearable && draft.value !== "" && {
|
|
44
|
+
rightSection: /* @__PURE__ */ jsx(
|
|
45
|
+
CloseButton,
|
|
46
|
+
{
|
|
47
|
+
size: "sm",
|
|
48
|
+
"aria-label": "Clear search",
|
|
49
|
+
disabled: disabled === true,
|
|
50
|
+
onMouseDown: (event) => {
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
},
|
|
53
|
+
onClick: draft.clear
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
},
|
|
57
|
+
...disabled === true && { disabled: true },
|
|
31
58
|
...placeholder !== void 0 && { placeholder },
|
|
32
59
|
onChange: (event) => {
|
|
33
60
|
draft.set(event.currentTarget.value);
|
|
34
61
|
},
|
|
35
|
-
|
|
36
|
-
|
|
62
|
+
onBlur: draft.flush,
|
|
63
|
+
onKeyDown: (event) => {
|
|
64
|
+
if (event.key === "Enter" && !event.nativeEvent.isComposing) draft.flush();
|
|
65
|
+
},
|
|
66
|
+
...!inRow && className !== void 0 && { className },
|
|
67
|
+
...!inRow && style !== void 0 && { style }
|
|
37
68
|
}
|
|
38
69
|
);
|
|
39
|
-
if (
|
|
70
|
+
if (inRow) {
|
|
40
71
|
return /* @__PURE__ */ jsx(
|
|
41
72
|
PanelRow,
|
|
42
73
|
{
|
|
@@ -50,18 +81,30 @@ function SearchFilter(props) {
|
|
|
50
81
|
}
|
|
51
82
|
return input;
|
|
52
83
|
}
|
|
53
|
-
function useDebouncedField(value, setValue) {
|
|
84
|
+
function useDebouncedField(value, setValue, clearField) {
|
|
54
85
|
const [draft, setDraft] = useState(value);
|
|
55
86
|
const seen = useRef(value);
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
held.current = value;
|
|
59
|
-
});
|
|
60
|
-
const commit = useDebouncedCallback((next) => {
|
|
61
|
-
if (next === held.current) return;
|
|
87
|
+
const rendered = useRef(value);
|
|
88
|
+
const write = (next) => {
|
|
62
89
|
seen.current = next;
|
|
63
90
|
setValue(next);
|
|
91
|
+
};
|
|
92
|
+
const commit = useDebouncedCallback((next) => {
|
|
93
|
+
if (next === seen.current) return;
|
|
94
|
+
write(next);
|
|
64
95
|
}, DEBOUNCE_MS);
|
|
96
|
+
const commitRef = useRef(commit);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
rendered.current = value;
|
|
99
|
+
commitRef.current = commit;
|
|
100
|
+
});
|
|
101
|
+
useIsomorphicLayoutEffect(
|
|
102
|
+
() => () => {
|
|
103
|
+
if (rendered.current === seen.current) commitRef.current.flush();
|
|
104
|
+
else commitRef.current.cancel();
|
|
105
|
+
},
|
|
106
|
+
[]
|
|
107
|
+
);
|
|
65
108
|
useEffect(() => {
|
|
66
109
|
if (seen.current === value) return;
|
|
67
110
|
seen.current = value;
|
|
@@ -73,29 +116,20 @@ function useDebouncedField(value, setValue) {
|
|
|
73
116
|
set: (next) => {
|
|
74
117
|
setDraft(next);
|
|
75
118
|
commit(next);
|
|
119
|
+
},
|
|
120
|
+
flush: () => {
|
|
121
|
+
commit.flush();
|
|
122
|
+
},
|
|
123
|
+
// Through the field's own `clear()` — it unsets rather than writing the fallback over it — and
|
|
124
|
+
// unconditional: the store may still hold the old phrase, or an unflushed one.
|
|
125
|
+
clear: () => {
|
|
126
|
+
commit.cancel();
|
|
127
|
+
setDraft("");
|
|
128
|
+
seen.current = rendered.current;
|
|
129
|
+
clearField();
|
|
76
130
|
}
|
|
77
131
|
};
|
|
78
132
|
}
|
|
79
|
-
function SearchIcon() {
|
|
80
|
-
return /* @__PURE__ */ jsxs(
|
|
81
|
-
"svg",
|
|
82
|
-
{
|
|
83
|
-
width: 16,
|
|
84
|
-
height: 16,
|
|
85
|
-
viewBox: "0 0 24 24",
|
|
86
|
-
fill: "none",
|
|
87
|
-
stroke: "currentColor",
|
|
88
|
-
strokeWidth: 2,
|
|
89
|
-
strokeLinecap: "round",
|
|
90
|
-
strokeLinejoin: "round",
|
|
91
|
-
"aria-hidden": true,
|
|
92
|
-
children: [
|
|
93
|
-
/* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "7" }),
|
|
94
|
-
/* @__PURE__ */ jsx("path", { d: "M21 21l-4.35 -4.35" })
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
133
|
export {
|
|
100
134
|
SearchFilter
|
|
101
135
|
};
|
|
@@ -32,23 +32,10 @@
|
|
|
32
32
|
import type { ReactNode } from 'react';
|
|
33
33
|
import type { EnumField, FieldHandle } from '../state.js';
|
|
34
34
|
import type { StringField } from '../state/fields.js';
|
|
35
|
+
import type { FilterBase, FilterOption } from './filter-base.js';
|
|
35
36
|
import type { UncontrolledProps } from './uncontrolled.js';
|
|
36
|
-
|
|
37
|
-
* One row of a runtime catalogue. Wider than the store's own `FieldOption` by exactly one member:
|
|
38
|
-
* `disabled` renders the row and refuses the selection, which a declared enum expresses by leaving
|
|
39
|
-
* the value out and a live catalogue cannot (an archived project still labels the rows already
|
|
40
|
-
* pointing at it).
|
|
41
|
-
*/
|
|
42
|
-
export type FilterOption = {
|
|
43
|
-
readonly value: string;
|
|
44
|
-
readonly label: string;
|
|
45
|
-
readonly disabled?: boolean;
|
|
46
|
-
};
|
|
47
|
-
type SelectFilterCommon = UncontrolledProps & {
|
|
37
|
+
type SelectFilterCommon = UncontrolledProps & FilterBase & {
|
|
48
38
|
readonly label: string;
|
|
49
|
-
readonly icon?: ReactNode;
|
|
50
|
-
/** Adds a `Clear` action that writes the field back to its fallback. */
|
|
51
|
-
readonly clearable?: boolean;
|
|
52
39
|
};
|
|
53
40
|
/** A closed enum field: `options` relabels rows the field already declares, so it is optional. */
|
|
54
41
|
export type SelectFilterEnumProps<T extends string> = SelectFilterCommon & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-filter.d.ts","sourceRoot":"","sources":["../../src/controls/select-filter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"select-filter.d.ts","sourceRoot":"","sources":["../../src/controls/select-filter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,KAAK,kBAAkB,GAAG,iBAAiB,GAAG,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAErF,kGAAkG;AAClG,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,MAAM,IAAI,kBAAkB,GAAG;IACzE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACzC,kFAAkF;IAClF,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;CAC3C,CAAA;AAED,kGAAkG;AAClG,MAAM,MAAM,uBAAuB,GAAG,kBAAkB,GAAG;IACzD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,CAAA;IACxC,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,MAAM,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG,uBAAuB,CAAA;AAEpG;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;AAC1F,wBAAgB,YAAY,CAAC,KAAK,EAAE,uBAAuB,GAAG,SAAS,CAAA"}
|
|
@@ -20,12 +20,6 @@ export type SyncButtonProps = BasaltProps & {
|
|
|
20
20
|
};
|
|
21
21
|
/** How often the relative age re-renders. One interval, only while mounted. */
|
|
22
22
|
export declare const AGE_REFRESH_MS = 30000;
|
|
23
|
-
/**
|
|
24
|
-
* Relative age, coarse on purpose: a sync indicator answers "is this stale?", not "how stale to
|
|
25
|
-
* the second". Anything under a minute is `just now`, so the label stops flickering while a sync
|
|
26
|
-
* has just landed.
|
|
27
|
-
*/
|
|
28
|
-
export declare function formatAge(ms: number): string;
|
|
29
23
|
/**
|
|
30
24
|
* @example
|
|
31
25
|
* // page scope — the page's own data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-button.d.ts","sourceRoot":"","sources":["../../src/controls/sync-button.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"sync-button.d.ts","sourceRoot":"","sources":["../../src/controls/sync-button.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAMlD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG;IAC1C,OAAO,EAAE,OAAO,CAAA;IAChB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IACtC,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB;sEACkE;IAClE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAA;IACxB;yBACqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,+EAA+E;AAC/E,eAAO,MAAM,cAAc,QAAS,CAAA;AAmCpC;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,eAAe,EACf,MAAM,EACN,KAAK,EACL,KAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,GACN,EAAE,eAAe,GAAG,SAAS,CAkE7B"}
|
|
@@ -2,17 +2,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { ActionIcon, Button, Tooltip } from "@mantine/core";
|
|
3
3
|
import { useSyncExternalStore } from "react";
|
|
4
4
|
import { cx } from "../common/props.js";
|
|
5
|
+
import { relativeTime } from "../format/index.js";
|
|
5
6
|
import { IconSlot } from "../theme/icon-slot.js";
|
|
7
|
+
import { RefreshGlyph } from "./glyphs.js";
|
|
6
8
|
import classes from "./sync-button.module.css";
|
|
7
9
|
const AGE_REFRESH_MS = 3e4;
|
|
8
|
-
function formatAge(ms) {
|
|
9
|
-
if (ms < 6e4) return "just now";
|
|
10
|
-
const minutes = Math.floor(ms / 6e4);
|
|
11
|
-
if (minutes < 60) return `${minutes}m ago`;
|
|
12
|
-
const hours = Math.floor(minutes / 60);
|
|
13
|
-
if (hours < 24) return `${hours}h ago`;
|
|
14
|
-
return `${Math.floor(hours / 24)}d ago`;
|
|
15
|
-
}
|
|
16
10
|
function toMillis(at) {
|
|
17
11
|
if (at === null || at === void 0) return void 0;
|
|
18
12
|
return at instanceof Date ? at.getTime() : at;
|
|
@@ -21,7 +15,7 @@ function useRelativeAge(at) {
|
|
|
21
15
|
const timestamp = toMillis(at);
|
|
22
16
|
return useSyncExternalStore(
|
|
23
17
|
timestamp === void 0 ? subscribeNever : subscribeAgeTick,
|
|
24
|
-
() => timestamp === void 0 ? void 0 :
|
|
18
|
+
() => timestamp === void 0 ? void 0 : relativeTime(timestamp, { style: "short" }),
|
|
25
19
|
() => void 0
|
|
26
20
|
);
|
|
27
21
|
}
|
|
@@ -31,29 +25,6 @@ function subscribeAgeTick(onTick) {
|
|
|
31
25
|
const id = setInterval(onTick, AGE_REFRESH_MS);
|
|
32
26
|
return () => clearInterval(id);
|
|
33
27
|
}
|
|
34
|
-
function RefreshGlyph({ spinning }) {
|
|
35
|
-
return /* @__PURE__ */ jsx(
|
|
36
|
-
"svg",
|
|
37
|
-
{
|
|
38
|
-
width: 16,
|
|
39
|
-
height: 16,
|
|
40
|
-
viewBox: "0 0 24 24",
|
|
41
|
-
fill: "none",
|
|
42
|
-
"aria-hidden": true,
|
|
43
|
-
className: spinning ? classes.spin : void 0,
|
|
44
|
-
children: /* @__PURE__ */ jsx(
|
|
45
|
-
"path",
|
|
46
|
-
{
|
|
47
|
-
d: "M20 11a8 8 0 1 0-2.34 5.66M20 5v6h-6",
|
|
48
|
-
stroke: "currentColor",
|
|
49
|
-
strokeWidth: 2,
|
|
50
|
-
strokeLinecap: "round",
|
|
51
|
-
strokeLinejoin: "round"
|
|
52
|
-
}
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
28
|
function SyncButton({
|
|
58
29
|
syncing,
|
|
59
30
|
lastCompletedAt,
|
|
@@ -102,7 +73,7 @@ function SyncButton({
|
|
|
102
73
|
...control,
|
|
103
74
|
...className !== void 0 && { className },
|
|
104
75
|
...style !== void 0 && { style },
|
|
105
|
-
children: /* @__PURE__ */ jsx(IconSlot, { children: /* @__PURE__ */ jsx(RefreshGlyph, {
|
|
76
|
+
children: /* @__PURE__ */ jsx(IconSlot, { children: /* @__PURE__ */ jsx(RefreshGlyph, { className: syncing ? classes.spin : void 0 }) })
|
|
106
77
|
}
|
|
107
78
|
) : /* @__PURE__ */ jsxs(
|
|
108
79
|
Button,
|
|
@@ -110,7 +81,7 @@ function SyncButton({
|
|
|
110
81
|
variant: "default",
|
|
111
82
|
className: cx(classes.pageButton, className),
|
|
112
83
|
...style !== void 0 && { style },
|
|
113
|
-
leftSection: /* @__PURE__ */ jsx(IconSlot, { children: /* @__PURE__ */ jsx(RefreshGlyph, {
|
|
84
|
+
leftSection: /* @__PURE__ */ jsx(IconSlot, { children: /* @__PURE__ */ jsx(RefreshGlyph, { className: syncing ? classes.spin : void 0 }) }),
|
|
114
85
|
...control,
|
|
115
86
|
children: [
|
|
116
87
|
/* @__PURE__ */ jsx("span", { className: classes.label, children: label }),
|
|
@@ -124,6 +95,5 @@ function SyncButton({
|
|
|
124
95
|
}
|
|
125
96
|
export {
|
|
126
97
|
AGE_REFRESH_MS,
|
|
127
|
-
SyncButton
|
|
128
|
-
formatAge
|
|
98
|
+
SyncButton
|
|
129
99
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { FieldHandle } from '../state.js';
|
|
3
3
|
import type { BooleanField } from '../state/fields.js';
|
|
4
|
+
import type { FilterBase } from './filter-base.js';
|
|
4
5
|
import type { UncontrolledProps } from './uncontrolled.js';
|
|
5
|
-
export type ToggleFilterProps = UncontrolledProps & {
|
|
6
|
+
export type ToggleFilterProps = UncontrolledProps & Omit<FilterBase, 'clearable'> & {
|
|
6
7
|
readonly field: FieldHandle<BooleanField>;
|
|
7
8
|
readonly label: string;
|
|
8
|
-
readonly icon?: ReactNode;
|
|
9
9
|
};
|
|
10
10
|
export declare function ToggleFilter(props: ToggleFilterProps): ReactNode;
|
|
11
11
|
//# sourceMappingURL=toggle-filter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-filter.d.ts","sourceRoot":"","sources":["../../src/controls/toggle-filter.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"toggle-filter.d.ts","sourceRoot":"","sources":["../../src/controls/toggle-filter.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAC/C,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG;IAC9B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,CAAA;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAoDhE"}
|
|
@@ -9,7 +9,7 @@ function ToggleFilter(props) {
|
|
|
9
9
|
assertRequiredProps("ToggleFilter", props, ["field"], {
|
|
10
10
|
field: "bind it to a store field (`store.field.<name>`), never a value/onChange pair."
|
|
11
11
|
});
|
|
12
|
-
const { field, label, icon, className, style } = props;
|
|
12
|
+
const { field, label, icon, disabled, className, style } = props;
|
|
13
13
|
const [value, setValue] = field.use();
|
|
14
14
|
const surface = useFilterSurface();
|
|
15
15
|
const id = useId();
|
|
@@ -26,7 +26,7 @@ function ToggleFilter(props) {
|
|
|
26
26
|
Switch,
|
|
27
27
|
{
|
|
28
28
|
id,
|
|
29
|
-
|
|
29
|
+
...disabled === true && { disabled: true },
|
|
30
30
|
checked: value,
|
|
31
31
|
onChange: (event) => {
|
|
32
32
|
setValue(event.currentTarget.checked);
|
|
@@ -45,6 +45,7 @@ function ToggleFilter(props) {
|
|
|
45
45
|
active: value,
|
|
46
46
|
pressed: value,
|
|
47
47
|
hideGlyph: true,
|
|
48
|
+
...disabled === true && { disabled: true },
|
|
48
49
|
...icon !== void 0 && { icon },
|
|
49
50
|
onClick: () => {
|
|
50
51
|
setValue(!value);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { EnumField, FieldHandle } from '../state.js';
|
|
3
|
+
import type { FilterBase, FilterOption } from './filter-base.js';
|
|
3
4
|
import type { UncontrolledProps } from './uncontrolled.js';
|
|
4
|
-
export type ViewTabsOption<T extends string> = {
|
|
5
|
-
readonly value: T;
|
|
6
|
-
readonly label: string;
|
|
5
|
+
export type ViewTabsOption<T extends string> = FilterOption<T> & {
|
|
7
6
|
/** Render this option on ONE viewport only. Omitted → both. */
|
|
8
7
|
readonly only?: 'sm-up' | 'sm-down';
|
|
9
8
|
};
|
|
10
|
-
export type ViewTabsProps<T extends string> = UncontrolledProps & {
|
|
9
|
+
export type ViewTabsProps<T extends string> = UncontrolledProps & Pick<FilterBase, 'disabled'> & {
|
|
11
10
|
readonly field: FieldHandle<EnumField<T>>;
|
|
12
11
|
/** Defaults to `field.options` (every declared value, labelled by `store.labels()`). */
|
|
13
12
|
readonly options?: readonly ViewTabsOption<T>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-tabs.d.ts","sourceRoot":"","sources":["../../src/controls/view-tabs.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"view-tabs.d.ts","sourceRoot":"","sources":["../../src/controls/view-tabs.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAItD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAgBvD,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG;IAC/D,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI,iBAAiB,GAC7D,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG;IAC7B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACzC,wFAAwF;IACxF,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,cAAc,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/C;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAEH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,CA0G7E"}
|