derive-dashboards 0.1.0 → 0.2.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/README.md +8 -5
- package/dist/adapter/sql-adapter.mjs +4 -4
- package/dist/body.mjs +11 -1
- package/dist/cache.d.mts +1 -1
- package/dist/cli/add.mjs +130 -0
- package/dist/cli/check.mjs +14 -1
- package/dist/cli/cli.mjs +14 -12
- package/dist/cli/config.mjs +12 -1
- package/dist/cli/doctor.mjs +147 -0
- package/dist/cli/import/dbt-schema.mjs +2 -2
- package/dist/cli/import/index.mjs +2 -2
- package/dist/cli/init.mjs +3 -2
- package/dist/cli/json.mjs +21 -0
- package/dist/cli/layers.mjs +33 -0
- package/dist/core/conformance/cases.d.mts +3 -0
- package/dist/core/conformance/cases.mjs +20 -4
- package/dist/core/conformance/check.mjs +6 -3
- package/dist/core/conformance/drill-cases.mjs +120 -0
- package/dist/core/document/layout.mjs +1 -1
- package/dist/core/document/view-layout.d.mts +14 -0
- package/dist/core/document/view-layout.mjs +157 -0
- package/dist/core/document/view.d.mts +26 -7
- package/dist/core/document/view.mjs +42 -11
- package/dist/core/engine/filter.mjs +2 -2
- package/dist/core/engine/index.d.mts +14 -2
- package/dist/core/engine/index.mjs +12 -1
- package/dist/core/engine/leaf.mjs +9 -4
- package/dist/core/engine/members.mjs +2 -2
- package/dist/core/engine/postgres.mjs +1 -1
- package/dist/core/engine/record-layout.d.mts +11 -0
- package/dist/core/engine/record-layout.mjs +7 -7
- package/dist/core/engine/records.d.mts +3 -2
- package/dist/core/engine/records.mjs +2 -1
- package/dist/core/engine/segmented.mjs +5 -2
- package/dist/core/engine/sql-records.mjs +2 -1
- package/dist/core/engine/statement.mjs +37 -3
- package/dist/core/engine/types.d.mts +3 -0
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +33 -1
- package/dist/core/error/codes.mjs +30 -2
- package/dist/core/index.d.mts +13 -7
- package/dist/core/index.mjs +9 -5
- package/dist/core/model/catalog/check.mjs +1 -1
- package/dist/core/model/hints.d.mts +36 -0
- package/dist/core/model/member.d.mts +4 -2
- package/dist/core/model/member.mjs +19 -3
- package/dist/core/model/types.d.mts +21 -19
- package/dist/core/model/validate/drill.mjs +70 -0
- package/dist/core/model/validate/index.mjs +3 -0
- package/dist/core/model/validate/members.mjs +7 -4
- package/dist/core/model/validate/shape.mjs +150 -0
- package/dist/core/model/validate/source.mjs +5 -3
- package/dist/core/policy/bind-query.d.mts +12 -0
- package/dist/core/policy/bind-query.mjs +53 -0
- package/dist/core/query/alias.mjs +7 -1
- package/dist/core/query/drill/compose.d.mts +22 -0
- package/dist/core/query/drill/compose.mjs +85 -0
- package/dist/core/query/drill/fields.d.mts +21 -0
- package/dist/core/query/drill/fields.mjs +91 -0
- package/dist/core/query/drill/internal.d.mts +11 -0
- package/dist/core/query/drill/items.d.mts +29 -0
- package/dist/core/query/drill/items.mjs +98 -0
- package/dist/core/query/drill/line.d.mts +31 -0
- package/dist/core/query/drill/line.mjs +183 -0
- package/dist/core/query/drill/links.d.mts +33 -0
- package/dist/core/query/drill/links.mjs +31 -0
- package/dist/core/query/drill/operand.mjs +7 -0
- package/dist/core/query/drill/scopes.d.mts +22 -0
- package/dist/core/query/drill/scopes.mjs +58 -0
- package/dist/core/query/drill/selection.d.mts +37 -0
- package/dist/core/query/drill/selection.mjs +144 -0
- package/dist/core/query/drill/steps.d.mts +14 -0
- package/dist/core/query/drill/steps.mjs +35 -0
- package/dist/core/query/drill/synthetic-expr.mjs +85 -0
- package/dist/core/query/drill/synthetic.d.mts +22 -0
- package/dist/core/query/drill/synthetic.mjs +165 -0
- package/dist/core/query/drill/time.d.mts +11 -0
- package/dist/core/query/drill/time.mjs +71 -0
- package/dist/core/query/drill/types.d.mts +155 -0
- package/dist/core/query/drill/types.mjs +4 -0
- package/dist/core/query/drill/views.d.mts +62 -0
- package/dist/core/query/drill/views.mjs +257 -0
- package/dist/core/query/filter.d.mts +6 -0
- package/dist/core/query/picks.d.mts +8 -2
- package/dist/core/query/picks.mjs +11 -4
- package/dist/core/query/segments.d.mts +12 -2
- package/dist/core/query/segments.mjs +5 -2
- package/dist/core/result/columns.mjs +20 -4
- package/dist/core/result/types.d.mts +5 -1
- package/dist/core/schema/aliases.d.mts +7 -0
- package/dist/core/schema/aliases.mjs +77 -0
- package/dist/core/schema/answer-parts.mjs +117 -0
- package/dist/core/schema/answers.d.mts +2109 -128
- package/dist/core/schema/answers.mjs +11 -113
- package/dist/core/schema/commands.d.mts +2 -2
- package/dist/core/schema/document.d.mts +1 -1
- package/dist/core/schema/drill-answers.mjs +179 -0
- package/dist/core/schema/drill.d.mts +260 -0
- package/dist/core/schema/drill.mjs +107 -0
- package/dist/core/schema/index.d.mts +6 -3
- package/dist/core/schema/index.mjs +6 -3
- package/dist/core/schema/picks.d.mts +35 -0
- package/dist/core/schema/picks.mjs +23 -0
- package/dist/core/schema/query.d.mts +82 -1
- package/dist/core/schema/query.mjs +9 -5
- package/dist/core/schema/tools.mjs +1 -1
- package/dist/core/schema/view.d.mts +0 -35
- package/dist/core/schema/view.mjs +19 -24
- package/dist/core/store/schema.d.mts +5 -0
- package/dist/core/store/schema.mjs +10 -0
- package/dist/core/types/api.d.mts +21 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/drill-api.d.mts +210 -0
- package/dist/core/types/options.d.mts +21 -0
- package/dist/core/types/viewer.d.mts +5 -0
- package/dist/cursor-seal.d.mts +8 -0
- package/dist/cursor-seal.mjs +98 -0
- package/dist/dashboard-id.mjs +1 -1
- package/dist/dashboards.mjs +4 -0
- package/dist/drill-access.mjs +93 -0
- package/dist/drill-change.mjs +76 -0
- package/dist/drill-crumbs.mjs +113 -0
- package/dist/drill-distinct.mjs +130 -0
- package/dist/drill-explain.mjs +64 -0
- package/dist/drill-identity.mjs +35 -0
- package/dist/drill-item-id.mjs +35 -0
- package/dist/drill-items.mjs +132 -0
- package/dist/drill-open.mjs +169 -0
- package/dist/drill-seal.mjs +170 -0
- package/dist/drill-secret.mjs +14 -0
- package/dist/drill-share.mjs +53 -0
- package/dist/drill-summary.mjs +158 -0
- package/dist/drill-targets.mjs +53 -0
- package/dist/drill-totals.mjs +8 -0
- package/dist/drill-views.mjs +175 -0
- package/dist/drill.mjs +157 -0
- package/dist/editing.mjs +3 -3
- package/dist/endpoints/dashboards.mjs +28 -5
- package/dist/endpoints/drill.mjs +55 -0
- package/dist/endpoints/index.d.mts +245 -4
- package/dist/endpoints/index.mjs +5 -1
- package/dist/endpoints/meta.mjs +10 -1
- package/dist/endpoints/query.mjs +26 -4
- package/dist/execute.d.mts +19 -1
- package/dist/execute.mjs +34 -27
- package/dist/handler.mjs +5 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +29 -2
- package/dist/llms.txt +22 -0
- package/dist/mcp/drill.mjs +61 -0
- package/dist/mcp/format.mjs +69 -11
- package/dist/mcp/index.d.mts +15 -4
- package/dist/mcp/index.mjs +13 -7
- package/dist/mcp/query.d.mts +7 -2
- package/dist/mcp/query.mjs +40 -6
- package/dist/node-postgres.d.mts +8 -4
- package/dist/node-postgres.mjs +29 -6
- package/dist/owner.mjs +3 -3
- package/dist/postgres-connection.d.mts +8 -2
- package/dist/postgres-connection.mjs +2 -1
- package/dist/postgres-store.mjs +1 -0
- package/dist/react/Canvas.mjs +28 -5
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +10 -5
- package/dist/react/Dashboard.mjs +62 -22
- package/dist/react/DashboardList.mjs +52 -24
- package/dist/react/DashboardListRow.mjs +49 -0
- package/dist/react/Discard.mjs +12 -4
- package/dist/react/Editing.mjs +19 -5
- package/dist/react/FilterBar.d.mts +7 -9
- package/dist/react/Grid.mjs +19 -24
- package/dist/react/Header.mjs +10 -1
- package/dist/react/History.mjs +5 -0
- package/dist/react/Parts.mjs +6 -2
- package/dist/react/ReadFailed.mjs +23 -0
- package/dist/react/ReviewPanel.mjs +13 -2
- package/dist/react/RowBody.d.mts +19 -0
- package/dist/react/RowBody.mjs +55 -0
- package/dist/react/Spaces.mjs +15 -1
- package/dist/react/Tile.d.mts +3 -1
- package/dist/react/Tile.mjs +84 -32
- package/dist/react/_virtual/_rolldown/runtime.mjs +12 -0
- package/dist/react/arrange-steps.mjs +16 -13
- package/dist/react/arrange.mjs +10 -3
- package/dist/react/builder/Calcs.mjs +35 -11
- package/dist/react/builder/FilterEditor.mjs +196 -0
- package/dist/react/builder/Filters.mjs +172 -116
- package/dist/react/builder/Formula.mjs +82 -0
- package/dist/react/builder/Groups.mjs +1 -0
- package/dist/react/builder/Preview.mjs +1 -1
- package/dist/react/builder/RangeEditor.mjs +184 -0
- package/dist/react/builder/Sections.mjs +41 -6
- package/dist/react/builder/Time.mjs +138 -60
- package/dist/react/builder/Values.mjs +85 -0
- package/dist/react/builder/WidgetBuilder.mjs +50 -49
- package/dist/react/builder/base.d.mts +5 -0
- package/dist/react/builder/base.mjs +33 -8
- package/dist/react/builder/calc.mjs +15 -1
- package/dist/react/builder/escape.d.mts +1 -0
- package/dist/react/builder/escape.mjs +62 -0
- package/dist/react/builder/filter-tree.d.mts +9 -0
- package/dist/react/builder/filter-tree.mjs +186 -0
- package/dist/react/builder/formula-parse.d.mts +18 -0
- package/dist/react/builder/formula-parse.mjs +136 -0
- package/dist/react/builder/labels.d.mts +1 -1
- package/dist/react/builder/state.d.mts +2 -1
- package/dist/react/builder/state.mjs +23 -37
- package/dist/react/builder/useBuilder.d.mts +12 -1
- package/dist/react/builder/useBuilder.mjs +6 -3
- package/dist/react/builder/words.d.mts +59 -0
- package/dist/react/builder/words.mjs +73 -0
- package/dist/react/client.d.mts +2 -0
- package/dist/react/client.mjs +1 -0
- package/dist/react/context.d.mts +28 -1
- package/dist/react/context.mjs +25 -4
- package/dist/react/drill/Bars.mjs +179 -0
- package/dist/react/drill/Controls.mjs +173 -0
- package/dist/react/drill/DashboardTile.d.mts +18 -0
- package/dist/react/drill/DashboardTile.mjs +107 -0
- package/dist/react/drill/DrillPanel.d.mts +31 -0
- package/dist/react/drill/DrillPanel.mjs +104 -0
- package/dist/react/drill/DrillTabs.mjs +52 -0
- package/dist/react/drill/Header.mjs +131 -0
- package/dist/react/drill/Items.d.mts +22 -0
- package/dist/react/drill/Items.mjs +164 -0
- package/dist/react/drill/ItemsFoot.mjs +60 -0
- package/dist/react/drill/Notes.mjs +58 -0
- package/dist/react/drill/PanelBody.mjs +74 -0
- package/dist/react/drill/PanelStates.mjs +37 -0
- package/dist/react/drill/board.d.mts +18 -0
- package/dist/react/drill/board.mjs +91 -0
- package/dist/react/drill/counts.mjs +14 -0
- package/dist/react/drill/host.mjs +26 -0
- package/dist/react/drill/item-parts.d.mts +5 -0
- package/dist/react/drill/item-parts.mjs +76 -0
- package/dist/react/drill/item-type.d.mts +26 -0
- package/dist/react/drill/item-type.mjs +7 -0
- package/dist/react/drill/lazy.d.mts +6 -0
- package/dist/react/drill/lazy.mjs +17 -0
- package/dist/react/drill/pages.mjs +48 -0
- package/dist/react/drill/panel-focus.mjs +51 -0
- package/dist/react/drill/props.d.mts +25 -0
- package/dist/react/drill/props.mjs +72 -0
- package/dist/react/drill/state.d.mts +18 -0
- package/dist/react/drill/state.mjs +68 -0
- package/dist/react/drill/useDrill.d.mts +46 -0
- package/dist/react/drill/useDrill.mjs +194 -0
- package/dist/react/drill/words.d.mts +101 -0
- package/dist/react/drill/words.mjs +79 -0
- package/dist/react/english.mjs +29 -6
- package/dist/react/filters/bar.d.mts +12 -0
- package/dist/react/filters/bar.mjs +135 -0
- package/dist/react/filters/calendar.mjs +193 -0
- package/dist/react/filters/chip.mjs +174 -0
- package/dist/react/filters/context.d.mts +22 -0
- package/dist/react/filters/context.mjs +78 -0
- package/dist/react/filters/dates.mjs +89 -0
- package/dist/react/filters/days.d.mts +36 -0
- package/dist/react/filters/days.mjs +87 -0
- package/dist/react/filters/field-step.mjs +81 -0
- package/dist/react/filters/hooks.d.mts +34 -0
- package/dist/react/filters/hooks.mjs +94 -0
- package/dist/react/filters/listbox.mjs +131 -0
- package/dist/react/filters/logic.d.mts +59 -0
- package/dist/react/filters/logic.mjs +109 -0
- package/dist/react/filters/menu-search.mjs +211 -0
- package/dist/react/filters/menu.mjs +85 -0
- package/dist/react/filters/number.mjs +127 -0
- package/dist/react/filters/numbers.d.mts +47 -0
- package/dist/react/filters/numbers.mjs +151 -0
- package/dist/react/filters/operator.mjs +104 -0
- package/dist/react/filters/phone.mjs +104 -0
- package/dist/react/filters/popover.d.mts +19 -0
- package/dist/react/filters/popover.mjs +153 -0
- package/dist/react/filters/rules.d.mts +8 -0
- package/dist/react/filters/rules.mjs +55 -0
- package/dist/react/filters/sheet.mjs +196 -0
- package/dist/react/filters/state.mjs +132 -0
- package/dist/react/filters/suggest.d.mts +47 -0
- package/dist/react/filters/suggest.mjs +97 -0
- package/dist/react/filters/values.mjs +166 -0
- package/dist/react/filters/words.d.mts +81 -0
- package/dist/react/filters/words.mjs +73 -0
- package/dist/react/format.d.mts +3 -3
- package/dist/react/format.mjs +45 -16
- package/dist/react/index.d.mts +34 -5
- package/dist/react/index.mjs +15 -4
- package/dist/react/messages.d.mts +47 -2
- package/dist/react/place.mjs +7 -3
- package/dist/react/renderers/index.d.mts +10 -2
- package/dist/react/renderers/index.mjs +116 -14
- package/dist/react/renderers/list.d.mts +22 -0
- package/dist/react/renderers/list.mjs +118 -0
- package/dist/react/review-words.mjs +1 -1
- package/dist/react/review.mjs +2 -2
- package/dist/react/scope.mjs +2 -7
- package/dist/react/series.d.mts +54 -0
- package/dist/react/series.mjs +191 -0
- package/dist/react/theme.css +2734 -1296
- package/dist/react/theme.css.d.ts +1 -0
- package/dist/react/tile-store.mjs +15 -3
- package/dist/react/useBoard.d.mts +7 -0
- package/dist/react/useBoard.mjs +4 -1
- package/dist/react/useDashboard.d.mts +4 -0
- package/dist/react/useDashboard.mjs +8 -1
- package/dist/react/useTiles.mjs +50 -15
- package/dist/react/view-grid.mjs +16 -0
- package/dist/react/view.d.mts +9 -0
- package/dist/react/view.mjs +22 -10
- package/dist/reading.d.mts +2 -0
- package/dist/reading.mjs +9 -1
- package/dist/recharts/axes.mjs +28 -0
- package/dist/recharts/axis.mjs +84 -0
- package/dist/recharts/bar.d.mts +7 -0
- package/dist/recharts/bar.mjs +140 -0
- package/dist/recharts/charts.d.mts +4 -6
- package/dist/recharts/charts.mjs +2 -114
- package/dist/recharts/index.d.mts +5 -3
- package/dist/recharts/index.mjs +6 -3
- package/dist/recharts/line.d.mts +2 -0
- package/dist/recharts/line.mjs +111 -0
- package/dist/recharts/marks.mjs +112 -0
- package/dist/recharts/parts.mjs +88 -0
- package/dist/recharts/series.d.mts +2 -22
- package/dist/recharts/series.mjs +1 -64
- package/dist/recharts/table.mjs +71 -0
- package/dist/records-read.mjs +44 -0
- package/dist/registry/filter-bar.json +26 -0
- package/dist/skills/derive-dashboards/SKILL.md +69 -0
- package/dist/store/apply.mjs +5 -5
- package/dist/store/commands.mjs +4 -4
- package/dist/store/discard.mjs +7 -7
- package/dist/store/drafts.mjs +5 -5
- package/dist/store/editor.mjs +1 -1
- package/dist/store/publish.mjs +12 -12
- package/dist/store/reader.mjs +41 -22
- package/dist/store/review.mjs +16 -16
- package/dist/store/rows.mjs +20 -20
- package/dist/store/undo.mjs +3 -3
- package/dist/store/unpublished.mjs +4 -4
- package/dist/store/versions.mjs +14 -14
- package/dist/testing/adapter-suite.mjs +4 -4
- package/dist/tiles.mjs +37 -3
- package/package.json +12 -10
- package/dist/react/FilterBar.mjs +0 -119
- package/dist/react/Records.d.mts +0 -12
- package/dist/react/Records.mjs +0 -97
- package/src/adapter/sql-adapter.ts +0 -95
- package/src/adapter/statement.ts +0 -185
- package/src/authorize.ts +0 -73
- package/src/body.ts +0 -169
- package/src/bounded.ts +0 -43
- package/src/cache.ts +0 -192
- package/src/checks.ts +0 -170
- package/src/custom-source.ts +0 -59
- package/src/dashboard-id.ts +0 -36
- package/src/dashboards.ts +0 -132
- package/src/editing.ts +0 -148
- package/src/endpoints/access.ts +0 -41
- package/src/endpoints/dashboards.ts +0 -92
- package/src/endpoints/drafts.ts +0 -138
- package/src/endpoints/index.ts +0 -21
- package/src/endpoints/meta.ts +0 -137
- package/src/endpoints/query.ts +0 -86
- package/src/endpoints/read.ts +0 -92
- package/src/endpoints/review.ts +0 -89
- package/src/endpoints/values.ts +0 -62
- package/src/endpoints/versions.ts +0 -104
- package/src/execute.ts +0 -207
- package/src/handler.ts +0 -232
- package/src/http.ts +0 -66
- package/src/index.ts +0 -163
- package/src/introspect.ts +0 -205
- package/src/mcp/api.ts +0 -59
- package/src/mcp/format.ts +0 -67
- package/src/mcp/index.ts +0 -151
- package/src/mcp/query.ts +0 -153
- package/src/mcp/resolve.ts +0 -114
- package/src/node-postgres.ts +0 -81
- package/src/owner.ts +0 -36
- package/src/postgres-connection.ts +0 -143
- package/src/postgres-store.ts +0 -82
- package/src/principal.ts +0 -39
- package/src/reading.ts +0 -56
- package/src/request-rows.ts +0 -23
- package/src/request.ts +0 -22
- package/src/storage.ts +0 -63
- package/src/store/apply.ts +0 -129
- package/src/store/commands.ts +0 -75
- package/src/store/conflicts.ts +0 -98
- package/src/store/create-tables.ts +0 -104
- package/src/store/discard.ts +0 -42
- package/src/store/drafts.ts +0 -133
- package/src/store/editor.ts +0 -28
- package/src/store/log.ts +0 -28
- package/src/store/publish.ts +0 -199
- package/src/store/publisher.ts +0 -21
- package/src/store/reader.ts +0 -139
- package/src/store/review.ts +0 -239
- package/src/store/rows.ts +0 -250
- package/src/store/tenant.ts +0 -28
- package/src/store/undo.ts +0 -56
- package/src/store/unpublished.ts +0 -33
- package/src/store/versions.ts +0 -106
- package/src/store/writer.ts +0 -19
- package/src/testing/adapter-suite.ts +0 -239
- package/src/testing/index.ts +0 -2
- package/src/tile-doc.ts +0 -46
- package/src/tiles.ts +0 -120
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// src/filters/numbers.ts
|
|
2
|
+
const unitText = (unit) => unit === "" ? "" : ` ${unit}`;
|
|
3
|
+
const NUMBER_SIGN = {
|
|
4
|
+
equals: "=",
|
|
5
|
+
gte: "≥",
|
|
6
|
+
gt: ">",
|
|
7
|
+
lt: "<",
|
|
8
|
+
lte: "≤"
|
|
9
|
+
};
|
|
10
|
+
/** A number pick as a chip says it: "2–8 h", "≥ 2 h", "> 2 h", "< 8 h", "≤ 8 h", "= 4 h". */
|
|
11
|
+
function numberText(pick, unit) {
|
|
12
|
+
const [a, b] = pick.values;
|
|
13
|
+
const u = unitText(unit);
|
|
14
|
+
if (pick.op === "between") return `${String(a)}–${String(b)}${u}`;
|
|
15
|
+
return `${NUMBER_SIGN[pick.op] ?? pick.op} ${String(a)}${u}`;
|
|
16
|
+
}
|
|
17
|
+
/** The quick picks a number field's buckets give, for the operators the control allows. */
|
|
18
|
+
function numberPresets(edges, unit, ops = [
|
|
19
|
+
"lt",
|
|
20
|
+
"between",
|
|
21
|
+
"gte"
|
|
22
|
+
]) {
|
|
23
|
+
const [lo, hi] = edges;
|
|
24
|
+
if (lo === void 0 || hi === void 0) return [];
|
|
25
|
+
const u = unitText(unit);
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
kind: "under",
|
|
29
|
+
lo,
|
|
30
|
+
hi,
|
|
31
|
+
pick: {
|
|
32
|
+
op: "lt",
|
|
33
|
+
values: [lo]
|
|
34
|
+
},
|
|
35
|
+
label: `Under ${String(lo)}${u}`
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
kind: "between",
|
|
39
|
+
lo,
|
|
40
|
+
hi,
|
|
41
|
+
pick: {
|
|
42
|
+
op: "between",
|
|
43
|
+
values: [lo, hi]
|
|
44
|
+
},
|
|
45
|
+
label: `${String(lo)} to ${String(hi)}${u}`
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
kind: "over",
|
|
49
|
+
lo,
|
|
50
|
+
hi,
|
|
51
|
+
pick: {
|
|
52
|
+
op: "gte",
|
|
53
|
+
values: [hi]
|
|
54
|
+
},
|
|
55
|
+
label: `${String(hi)}${u} or more`
|
|
56
|
+
}
|
|
57
|
+
].filter((p) => ops.includes(p.pick.op));
|
|
58
|
+
}
|
|
59
|
+
const typedNumber = (s) => {
|
|
60
|
+
if (s.trim() === "") return "blank";
|
|
61
|
+
const n = Number(s);
|
|
62
|
+
return Number.isFinite(n) ? n : "bad";
|
|
63
|
+
};
|
|
64
|
+
/** The first of these operators the control allows. */
|
|
65
|
+
const firstOf = (ops, wanted) => wanted.find((op) => op !== void 0 && ops.includes(op));
|
|
66
|
+
/** One typed bound as a pick: from the minimum, or under the maximum, keeping `prefer` (the
|
|
67
|
+
* operator it had) where the control allows it, so "> 2" edited to 3 stays strict. */
|
|
68
|
+
function oneSide(value, side, ops, prefer) {
|
|
69
|
+
const op = side === "min" ? firstOf(ops, [
|
|
70
|
+
prefer === "gt" || prefer === "gte" ? prefer : void 0,
|
|
71
|
+
"gte",
|
|
72
|
+
"gt"
|
|
73
|
+
]) : firstOf(ops, [
|
|
74
|
+
prefer === "lt" || prefer === "lte" ? prefer : void 0,
|
|
75
|
+
"lt",
|
|
76
|
+
"lte"
|
|
77
|
+
]);
|
|
78
|
+
return op === void 0 ? { problem: "bothBounds" } : { pick: {
|
|
79
|
+
op,
|
|
80
|
+
values: [value]
|
|
81
|
+
} };
|
|
82
|
+
}
|
|
83
|
+
/** Both bounds as a range, where the control has between. */
|
|
84
|
+
function range(a, b, ops) {
|
|
85
|
+
if (!ops.includes("between")) return { problem: "oneBound" };
|
|
86
|
+
return a > b ? { problem: "minOverMax" } : { pick: {
|
|
87
|
+
op: "between",
|
|
88
|
+
values: [a, b]
|
|
89
|
+
} };
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Which boxes a control's operators give: a minimum, a maximum, or one exact value. An exact
|
|
93
|
+
* value is the only box for an equals-only control, and the box for a pick that is already
|
|
94
|
+
* "= 4" (`current`), so editing it keeps it exact.
|
|
95
|
+
*/
|
|
96
|
+
function numberSides(ops, current) {
|
|
97
|
+
const min = ops.some((op) => op === "between" || op === "gte" || op === "gt");
|
|
98
|
+
const max = ops.some((op) => op === "between" || op === "lt" || op === "lte");
|
|
99
|
+
const exact = ops.includes("equals") && (current === "equals" || !min && !max);
|
|
100
|
+
return exact ? {
|
|
101
|
+
min: false,
|
|
102
|
+
max: false,
|
|
103
|
+
exact
|
|
104
|
+
} : {
|
|
105
|
+
min,
|
|
106
|
+
max,
|
|
107
|
+
exact
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Typed bounds as a pick (none when blank), or why they are not one. Only finite numbers count;
|
|
112
|
+
* the operator is always one the control lists: between for both, a one-sided comparison for
|
|
113
|
+
* one (the one it had, if any), equals for an exact value. `prefer` is the pick's operator before
|
|
114
|
+
* the edit; a pick read into the boxes and applied unchanged comes back as itself.
|
|
115
|
+
*/
|
|
116
|
+
function numberDraft(min, max, ops = [
|
|
117
|
+
"between",
|
|
118
|
+
"gte",
|
|
119
|
+
"lt"
|
|
120
|
+
], prefer) {
|
|
121
|
+
const a = typedNumber(min);
|
|
122
|
+
const b = typedNumber(max);
|
|
123
|
+
if (a === "bad" || b === "bad") return { problem: "notNumbers" };
|
|
124
|
+
if (a !== "blank" && numberSides(ops, prefer).exact) return { pick: {
|
|
125
|
+
op: "equals",
|
|
126
|
+
values: [a]
|
|
127
|
+
} };
|
|
128
|
+
if (a !== "blank" && b !== "blank") return range(a, b, ops);
|
|
129
|
+
if (a !== "blank") return oneSide(a, "min", ops, prefer);
|
|
130
|
+
return b === "blank" ? {} : oneSide(b, "max", ops, prefer);
|
|
131
|
+
}
|
|
132
|
+
/** A number pick as the boxes show it: an exact value and a minimum both fill the first box. */
|
|
133
|
+
function numberBounds(pick) {
|
|
134
|
+
if (pick === void 0) return {
|
|
135
|
+
min: "",
|
|
136
|
+
max: ""
|
|
137
|
+
};
|
|
138
|
+
const [a = "", b = ""] = pick.values.map(String);
|
|
139
|
+
if (pick.op === "between") return {
|
|
140
|
+
min: a,
|
|
141
|
+
max: b
|
|
142
|
+
};
|
|
143
|
+
return pick.op === "gte" || pick.op === "gt" || pick.op === "equals" ? {
|
|
144
|
+
min: a,
|
|
145
|
+
max: ""
|
|
146
|
+
} : {
|
|
147
|
+
min: "",
|
|
148
|
+
max: a
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
export { numberBounds, numberDraft, numberPresets, numberSides, numberText, unitText };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useOpText, useWords } from "./context.mjs";
|
|
2
|
+
import { canFlip, isNegative } from "./logic.mjs";
|
|
3
|
+
import { Popover } from "./popover.mjs";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/filters/operator.tsx
|
|
7
|
+
const CHOICES = [false, true];
|
|
8
|
+
/** Arrow keys, Home and End move between a menu's items, as the ARIA menu pattern asks. */
|
|
9
|
+
function moveInMenu(e) {
|
|
10
|
+
const items = [...e.currentTarget.querySelectorAll("[role=menuitemradio]")];
|
|
11
|
+
const at = items.findIndex((i) => i === document.activeElement);
|
|
12
|
+
const last = items.length - 1;
|
|
13
|
+
const next = {
|
|
14
|
+
ArrowDown: at >= last ? 0 : at + 1,
|
|
15
|
+
ArrowUp: at <= 0 ? last : at - 1,
|
|
16
|
+
Home: 0,
|
|
17
|
+
End: last
|
|
18
|
+
}[e.key];
|
|
19
|
+
if (next === void 0) return;
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
items[next]?.focus();
|
|
22
|
+
}
|
|
23
|
+
function Choices({ label, pick, onChange }) {
|
|
24
|
+
const opText = useOpText();
|
|
25
|
+
const negative = isNegative(pick.op);
|
|
26
|
+
return /* @__PURE__ */ jsx("div", {
|
|
27
|
+
role: "menu",
|
|
28
|
+
"aria-label": label,
|
|
29
|
+
className: "dd-fb-menu",
|
|
30
|
+
onKeyDown: moveInMenu,
|
|
31
|
+
children: CHOICES.map((neg) => /* @__PURE__ */ jsx("button", {
|
|
32
|
+
type: "button",
|
|
33
|
+
role: "menuitemradio",
|
|
34
|
+
"aria-checked": neg === negative,
|
|
35
|
+
tabIndex: neg === negative ? 0 : -1,
|
|
36
|
+
className: "dd-fb-preset",
|
|
37
|
+
onClick: () => {
|
|
38
|
+
onChange(neg);
|
|
39
|
+
},
|
|
40
|
+
children: opText(pick, neg)
|
|
41
|
+
}, String(neg)))
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The operator as its own small menu: what it is now, and the other choice beside it. Where the
|
|
46
|
+
* control cannot say "is not", it is plain text.
|
|
47
|
+
*/
|
|
48
|
+
function OperatorMenu({ control, pick, onChange }) {
|
|
49
|
+
const words = useWords();
|
|
50
|
+
const opText = useOpText();
|
|
51
|
+
const [open, setOpen] = useState(false);
|
|
52
|
+
const button = useRef(null);
|
|
53
|
+
if (!canFlip(control, pick)) return /* @__PURE__ */ jsx("span", {
|
|
54
|
+
className: "dd-fb-seg dd-fb-op",
|
|
55
|
+
children: opText(pick)
|
|
56
|
+
});
|
|
57
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
58
|
+
ref: button,
|
|
59
|
+
type: "button",
|
|
60
|
+
className: "dd-fb-seg dd-fb-op",
|
|
61
|
+
"aria-haspopup": "menu",
|
|
62
|
+
"aria-expanded": open,
|
|
63
|
+
"aria-label": words.operator(control.label, opText(pick)),
|
|
64
|
+
onClick: () => {
|
|
65
|
+
setOpen(!open);
|
|
66
|
+
},
|
|
67
|
+
children: opText(pick)
|
|
68
|
+
}), /* @__PURE__ */ jsx(Popover, {
|
|
69
|
+
anchor: button,
|
|
70
|
+
open,
|
|
71
|
+
onClose: () => {
|
|
72
|
+
setOpen(false);
|
|
73
|
+
},
|
|
74
|
+
label: control.label,
|
|
75
|
+
role: "none",
|
|
76
|
+
children: /* @__PURE__ */ jsx(Choices, {
|
|
77
|
+
label: control.label,
|
|
78
|
+
pick,
|
|
79
|
+
onChange: (neg) => {
|
|
80
|
+
onChange(neg);
|
|
81
|
+
setOpen(false);
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
})] });
|
|
85
|
+
}
|
|
86
|
+
/** The same choice as two buttons, for the phone sheet, where nothing opens on top. */
|
|
87
|
+
function OperatorToggle({ control, pick, onChange }) {
|
|
88
|
+
const opText = useOpText();
|
|
89
|
+
if (!canFlip(control, pick)) return null;
|
|
90
|
+
return /* @__PURE__ */ jsx("fieldset", {
|
|
91
|
+
className: "dd-fb-seg-row",
|
|
92
|
+
"aria-label": control.label,
|
|
93
|
+
children: CHOICES.map((neg) => /* @__PURE__ */ jsx("button", {
|
|
94
|
+
type: "button",
|
|
95
|
+
"aria-pressed": isNegative(pick.op) === neg,
|
|
96
|
+
className: "dd-fb-preset",
|
|
97
|
+
onClick: () => {
|
|
98
|
+
onChange(neg);
|
|
99
|
+
},
|
|
100
|
+
children: opText(pick, neg)
|
|
101
|
+
}, String(neg)))
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
export { OperatorMenu, OperatorToggle };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { rangeOf, useBar, useRangeText, useSummary, useWords, valuePickOf } from "./context.mjs";
|
|
2
|
+
import { chosenOf, isNegative, isNumber } from "./logic.mjs";
|
|
3
|
+
import { numberText } from "./numbers.mjs";
|
|
4
|
+
import { Sheet } from "./sheet.mjs";
|
|
5
|
+
import { useShortcuts } from "./state.mjs";
|
|
6
|
+
import { ValuesSummary } from "./values.mjs";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
// src/filters/phone.tsx
|
|
10
|
+
/** A date range or a number filter's pick, said short. */
|
|
11
|
+
function PickText({ control }) {
|
|
12
|
+
const { fields, picks } = useBar();
|
|
13
|
+
const rangeText = useRangeText();
|
|
14
|
+
if (control.kind === "date_range") {
|
|
15
|
+
const range = rangeOf(picks, control.id);
|
|
16
|
+
return /* @__PURE__ */ jsx("span", { children: range === void 0 ? null : rangeText(range) });
|
|
17
|
+
}
|
|
18
|
+
const pick = valuePickOf(picks, control.id);
|
|
19
|
+
return /* @__PURE__ */ jsx("span", { children: pick === void 0 ? null : numberText(pick, fields[control.id]?.unit ?? "") });
|
|
20
|
+
}
|
|
21
|
+
/** A filter in use on the phone row: its label and its pick, which opens it in the sheet. */
|
|
22
|
+
function Pill({ control, onOpen }) {
|
|
23
|
+
const { fields, picks } = useBar();
|
|
24
|
+
const words = useWords();
|
|
25
|
+
const said = useSummary()(control);
|
|
26
|
+
const pick = valuePickOf(picks, control.id);
|
|
27
|
+
const values = control.kind === "filter" && pick !== void 0 && !isNumber(control, fields);
|
|
28
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
29
|
+
type: "button",
|
|
30
|
+
className: "dd-fb-pill",
|
|
31
|
+
"aria-label": `${control.label} ${said ?? ""}`,
|
|
32
|
+
onClick: onOpen,
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ jsx("span", {
|
|
35
|
+
className: "dd-fb-quiet",
|
|
36
|
+
children: control.label
|
|
37
|
+
}),
|
|
38
|
+
values && isNegative(pick.op) ? /* @__PURE__ */ jsx("span", {
|
|
39
|
+
className: "dd-fb-quiet",
|
|
40
|
+
children: words.isNotWord
|
|
41
|
+
}) : null,
|
|
42
|
+
values ? /* @__PURE__ */ jsx(ValuesSummary, {
|
|
43
|
+
control,
|
|
44
|
+
values: chosenOf(pick)
|
|
45
|
+
}) : /* @__PURE__ */ jsx(PickText, { control })
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** The phone row: Filters with how many are set, then a pill per filter in use. */
|
|
50
|
+
function PhoneRow({ inUse, sheetOpen, onOpen }) {
|
|
51
|
+
const words = useWords();
|
|
52
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
53
|
+
className: "dd-fb dd-fb-bar",
|
|
54
|
+
"data-narrow": true,
|
|
55
|
+
role: "toolbar",
|
|
56
|
+
"aria-label": words.filters(inUse.length),
|
|
57
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
58
|
+
type: "button",
|
|
59
|
+
className: "dd-fb-add",
|
|
60
|
+
"aria-haspopup": "dialog",
|
|
61
|
+
"aria-expanded": sheetOpen,
|
|
62
|
+
onClick: () => {
|
|
63
|
+
onOpen(null);
|
|
64
|
+
},
|
|
65
|
+
children: words.filters(inUse.length)
|
|
66
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: "dd-fb-scroll",
|
|
68
|
+
children: inUse.map((c) => /* @__PURE__ */ jsx(Pill, {
|
|
69
|
+
control: c,
|
|
70
|
+
onOpen: () => {
|
|
71
|
+
onOpen(c.id);
|
|
72
|
+
}
|
|
73
|
+
}, c.id))
|
|
74
|
+
})]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/** On a phone: the filters in use in one row, and Filters, which opens the sheet of every filter. */
|
|
78
|
+
function PhoneBar({ controls, removeLast, onReset }) {
|
|
79
|
+
const { picks } = useBar();
|
|
80
|
+
const [sheet, setSheet] = useState(false);
|
|
81
|
+
const [expanded, setExpanded] = useState(null);
|
|
82
|
+
const open = (id) => {
|
|
83
|
+
setExpanded(id);
|
|
84
|
+
setSheet(true);
|
|
85
|
+
};
|
|
86
|
+
useShortcuts(() => {
|
|
87
|
+
open(null);
|
|
88
|
+
}, removeLast);
|
|
89
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(PhoneRow, {
|
|
90
|
+
inUse: controls.filter((c) => picks[c.id] !== void 0),
|
|
91
|
+
sheetOpen: sheet,
|
|
92
|
+
onOpen: open
|
|
93
|
+
}), /* @__PURE__ */ jsx(Sheet, {
|
|
94
|
+
controls,
|
|
95
|
+
open: sheet,
|
|
96
|
+
onClose: () => {
|
|
97
|
+
setSheet(false);
|
|
98
|
+
},
|
|
99
|
+
expanded,
|
|
100
|
+
setExpanded,
|
|
101
|
+
onReset
|
|
102
|
+
})] });
|
|
103
|
+
}
|
|
104
|
+
export { PhoneBar };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode, RefObject } from "react";
|
|
2
|
+
type Anchor = RefObject<HTMLElement | null>;
|
|
3
|
+
/**
|
|
4
|
+
* A panel under its anchor, drawn at the end of <body> so no overflow or stacking context of the
|
|
5
|
+
* host clips it. It flips above when there is no room below, stays inside the viewport, follows
|
|
6
|
+
* scrolling, closes on Escape or a press outside, and gives focus back on close.
|
|
7
|
+
* The panel carries `dd-fb-pop`; style it like anything else.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Popover({ anchor, open, onClose, label, className, role, children }: {
|
|
10
|
+
anchor: Anchor;
|
|
11
|
+
open: boolean;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
label: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
/** "dialog" (the default) labels the panel; "none" when its content carries the role, as a menu does. */
|
|
16
|
+
role?: "dialog" | "none";
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}): import("react").ReactPortal | null;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/filters/popover.tsx
|
|
5
|
+
const GAP = 6;
|
|
6
|
+
const MARGIN = 8;
|
|
7
|
+
/** Where the panel goes: under its anchor, above when there is no room, inside the viewport. */
|
|
8
|
+
function placeOf(a, p) {
|
|
9
|
+
const below = window.innerHeight - a.bottom - GAP;
|
|
10
|
+
const up = below < p.height + MARGIN && a.top > below;
|
|
11
|
+
const top = up ? Math.max(MARGIN, a.top - GAP - p.height) : a.bottom + GAP;
|
|
12
|
+
const left = Math.min(Math.max(MARGIN, a.left), window.innerWidth - p.width - MARGIN);
|
|
13
|
+
return {
|
|
14
|
+
top,
|
|
15
|
+
left: Math.max(MARGIN, left),
|
|
16
|
+
up
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** The panel's place while open, kept up to date as it resizes and the page scrolls. */
|
|
20
|
+
function usePlace(open, anchor, panel) {
|
|
21
|
+
const [place, setPlace] = useState(null);
|
|
22
|
+
const measure = useCallback(() => {
|
|
23
|
+
const a = anchor.current?.getBoundingClientRect();
|
|
24
|
+
const p = panel.current?.getBoundingClientRect();
|
|
25
|
+
if (a !== void 0 && p !== void 0) setPlace(placeOf(a, p));
|
|
26
|
+
}, [anchor, panel]);
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
if (!open) {
|
|
29
|
+
setPlace(null);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
measure();
|
|
33
|
+
const observer = new ResizeObserver(measure);
|
|
34
|
+
if (panel.current !== null) observer.observe(panel.current);
|
|
35
|
+
window.addEventListener("resize", measure);
|
|
36
|
+
window.addEventListener("scroll", measure, true);
|
|
37
|
+
return () => {
|
|
38
|
+
observer.disconnect();
|
|
39
|
+
window.removeEventListener("resize", measure);
|
|
40
|
+
window.removeEventListener("scroll", measure, true);
|
|
41
|
+
};
|
|
42
|
+
}, [
|
|
43
|
+
open,
|
|
44
|
+
measure,
|
|
45
|
+
panel
|
|
46
|
+
]);
|
|
47
|
+
return place;
|
|
48
|
+
}
|
|
49
|
+
const lostFocus = () => document.activeElement === null || document.activeElement === document.body;
|
|
50
|
+
/** Closes on Escape (from inside, its anchor, or nowhere) and on a press outside both. */
|
|
51
|
+
function useDismiss(open, anchor, panel, onClose) {
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!open) return;
|
|
54
|
+
const inside = (t) => panel.current?.contains(t) === true || anchor.current?.contains(t) === true;
|
|
55
|
+
const onDown = (e) => {
|
|
56
|
+
const t = e.target instanceof Element ? e.target : null;
|
|
57
|
+
if (!inside(t) && (t?.closest(".dd-fb-pop") ?? null) === null) onClose();
|
|
58
|
+
};
|
|
59
|
+
const onKey = (e) => {
|
|
60
|
+
if (e.key !== "Escape" || !(lostFocus() || inside(document.activeElement))) return;
|
|
61
|
+
e.stopPropagation();
|
|
62
|
+
onClose();
|
|
63
|
+
};
|
|
64
|
+
document.addEventListener("pointerdown", onDown, true);
|
|
65
|
+
document.addEventListener("keydown", onKey, true);
|
|
66
|
+
return () => {
|
|
67
|
+
document.removeEventListener("pointerdown", onDown, true);
|
|
68
|
+
document.removeEventListener("keydown", onKey, true);
|
|
69
|
+
};
|
|
70
|
+
}, [
|
|
71
|
+
open,
|
|
72
|
+
onClose,
|
|
73
|
+
anchor,
|
|
74
|
+
panel
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* When it closes with focus inside (or lost with the panel), focus goes back to what opened it,
|
|
79
|
+
* or, when a pick redrew the chip, to the chip's value.
|
|
80
|
+
*/
|
|
81
|
+
function useFocusBack(open, anchor, panel) {
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (!open) return;
|
|
84
|
+
const at = document.activeElement;
|
|
85
|
+
const opener = at instanceof HTMLElement && anchor.current?.contains(at) === true ? at : null;
|
|
86
|
+
const box = panel.current;
|
|
87
|
+
return () => {
|
|
88
|
+
if (!lostFocus() && box?.contains(document.activeElement) !== true) return;
|
|
89
|
+
requestAnimationFrame(() => {
|
|
90
|
+
if (!lostFocus()) return;
|
|
91
|
+
(opener?.isConnected === true ? opener : anchor.current?.querySelector(".dd-fb-value, [aria-haspopup]"))?.focus({ preventScroll: true });
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}, [
|
|
95
|
+
open,
|
|
96
|
+
anchor,
|
|
97
|
+
panel
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
/** Focuses the first field, or the first button, once the panel is placed (hidden takes none). */
|
|
101
|
+
function useFocusFirst(open, placed, panel) {
|
|
102
|
+
const focused = useRef(false);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (!open) {
|
|
105
|
+
focused.current = false;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (!placed || focused.current) return;
|
|
109
|
+
focused.current = true;
|
|
110
|
+
if (panel.current?.contains(document.activeElement) === true) return;
|
|
111
|
+
const box = panel.current;
|
|
112
|
+
(box?.querySelector("[aria-checked=true]") ?? box?.querySelector("input, [role=option], button:not([disabled])"))?.focus({ preventScroll: true });
|
|
113
|
+
}, [
|
|
114
|
+
open,
|
|
115
|
+
placed,
|
|
116
|
+
panel
|
|
117
|
+
]);
|
|
118
|
+
}
|
|
119
|
+
/** The panel's side and position; hidden off screen until it is measured. */
|
|
120
|
+
const placed = (place) => ({
|
|
121
|
+
"data-side": place?.up === true ? "top" : "bottom",
|
|
122
|
+
style: {
|
|
123
|
+
position: "fixed",
|
|
124
|
+
top: place?.top ?? -9999,
|
|
125
|
+
left: place?.left ?? -9999,
|
|
126
|
+
visibility: place === null ? "hidden" : "visible"
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
/**
|
|
130
|
+
* A panel under its anchor, drawn at the end of <body> so no overflow or stacking context of the
|
|
131
|
+
* host clips it. It flips above when there is no room below, stays inside the viewport, follows
|
|
132
|
+
* scrolling, closes on Escape or a press outside, and gives focus back on close.
|
|
133
|
+
* The panel carries `dd-fb-pop`; style it like anything else.
|
|
134
|
+
*/
|
|
135
|
+
function Popover({ anchor, open, onClose, label, className, role = "dialog", children }) {
|
|
136
|
+
const panel = useRef(null);
|
|
137
|
+
const place = usePlace(open, anchor, panel);
|
|
138
|
+
useDismiss(open, anchor, panel, onClose);
|
|
139
|
+
useFocusBack(open, anchor, panel);
|
|
140
|
+
useFocusFirst(open, place !== null, panel);
|
|
141
|
+
if (!open) return null;
|
|
142
|
+
return createPortal(/* @__PURE__ */ jsx("div", {
|
|
143
|
+
ref: panel,
|
|
144
|
+
...role === "dialog" ? {
|
|
145
|
+
role,
|
|
146
|
+
"aria-label": label
|
|
147
|
+
} : { role },
|
|
148
|
+
className: className === void 0 ? "dd-fb dd-fb-pop" : `dd-fb dd-fb-pop ${className}`,
|
|
149
|
+
...placed(place),
|
|
150
|
+
children
|
|
151
|
+
}), document.body);
|
|
152
|
+
}
|
|
153
|
+
export { Popover };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DAY_ONLY, addDays, dateFormat, daysLabel, daysPick, explicitDays, fromIsoDay, isoDay, monthEnd, monthStart, pickedDays, rangeLabel, relativeLabel, sameDay, todayIn, weekday } from "./days.mjs";
|
|
2
|
+
import { DateControl, Fields, FilterControl, OpWord, RelativeRange, ValuePick, canFlip, changeText, chosenOf, defaultFormat, flipped, isNegative, isNone, isNumber, listText, nonePick, offersNone, opWord, pickOpWord, removedOf, takesMany, toggled, valueOp, valuePick } from "./logic.mjs";
|
|
3
|
+
import { NumberPreset, NumberProblem, numberBounds, numberDraft, numberPresets, numberSides, numberText, unitText } from "./numbers.mjs";
|
|
4
|
+
import { DATE_WORDS, ENGLISH_GRAMMAR, Grammar, SuggestInput, Suggestion, fieldMatches, matchingFields, suggest, suggestionPick } from "./suggest.mjs";
|
|
5
|
+
declare namespace rules_d_exports {
|
|
6
|
+
export { DATE_WORDS, DAY_ONLY, DateControl, ENGLISH_GRAMMAR, Fields, FilterControl, Grammar, NumberPreset, NumberProblem, OpWord, RelativeRange, SuggestInput, Suggestion, ValuePick, addDays, canFlip, changeText, chosenOf, dateFormat, daysLabel, daysPick, defaultFormat, explicitDays, fieldMatches, flipped, fromIsoDay, isNegative, isNone, isNumber, isoDay, listText, matchingFields, monthEnd, monthStart, nonePick, numberBounds, numberDraft, numberPresets, numberSides, numberText, offersNone, opWord, pickOpWord, pickedDays, rangeLabel, relativeLabel, removedOf, sameDay, suggest, suggestionPick, takesMany, todayIn, toggled, unitText, valueOp, valuePick, weekday };
|
|
7
|
+
}
|
|
8
|
+
export { DATE_WORDS, DAY_ONLY, DateControl, ENGLISH_GRAMMAR, Fields, FilterControl, Grammar, NumberPreset, NumberProblem, OpWord, RelativeRange, SuggestInput, Suggestion, ValuePick, addDays, canFlip, changeText, chosenOf, dateFormat, daysLabel, daysPick, defaultFormat, explicitDays, fieldMatches, flipped, fromIsoDay, isNegative, isNone, isNumber, isoDay, listText, matchingFields, monthEnd, monthStart, nonePick, numberBounds, numberDraft, numberPresets, numberSides, numberText, offersNone, opWord, pickOpWord, pickedDays, rangeLabel, relativeLabel, removedOf, rules_d_exports, sameDay, suggest, suggestionPick, takesMany, todayIn, toggled, unitText, valueOp, valuePick, weekday };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { DAY_ONLY, addDays, dateFormat, daysLabel, daysPick, explicitDays, fromIsoDay, isoDay, monthEnd, monthStart, pickedDays, rangeLabel, relativeLabel, sameDay, todayIn, weekday } from "./days.mjs";
|
|
3
|
+
import { canFlip, changeText, chosenOf, defaultFormat, flipped, isNegative, isNone, isNumber, listText, nonePick, offersNone, opWord, pickOpWord, removedOf, takesMany, toggled, valueOp, valuePick } from "./logic.mjs";
|
|
4
|
+
import { numberBounds, numberDraft, numberPresets, numberSides, numberText, unitText } from "./numbers.mjs";
|
|
5
|
+
import { DATE_WORDS, ENGLISH_GRAMMAR, fieldMatches, matchingFields, suggest, suggestionPick } from "./suggest.mjs";
|
|
6
|
+
// src/filters/rules.ts
|
|
7
|
+
var rules_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
DATE_WORDS: () => DATE_WORDS,
|
|
9
|
+
DAY_ONLY: () => DAY_ONLY,
|
|
10
|
+
ENGLISH_GRAMMAR: () => ENGLISH_GRAMMAR,
|
|
11
|
+
addDays: () => addDays,
|
|
12
|
+
canFlip: () => canFlip,
|
|
13
|
+
changeText: () => changeText,
|
|
14
|
+
chosenOf: () => chosenOf,
|
|
15
|
+
dateFormat: () => dateFormat,
|
|
16
|
+
daysLabel: () => daysLabel,
|
|
17
|
+
daysPick: () => daysPick,
|
|
18
|
+
defaultFormat: () => defaultFormat,
|
|
19
|
+
explicitDays: () => explicitDays,
|
|
20
|
+
fieldMatches: () => fieldMatches,
|
|
21
|
+
flipped: () => flipped,
|
|
22
|
+
fromIsoDay: () => fromIsoDay,
|
|
23
|
+
isNegative: () => isNegative,
|
|
24
|
+
isNone: () => isNone,
|
|
25
|
+
isNumber: () => isNumber,
|
|
26
|
+
isoDay: () => isoDay,
|
|
27
|
+
listText: () => listText,
|
|
28
|
+
matchingFields: () => matchingFields,
|
|
29
|
+
monthEnd: () => monthEnd,
|
|
30
|
+
monthStart: () => monthStart,
|
|
31
|
+
nonePick: () => nonePick,
|
|
32
|
+
numberBounds: () => numberBounds,
|
|
33
|
+
numberDraft: () => numberDraft,
|
|
34
|
+
numberPresets: () => numberPresets,
|
|
35
|
+
numberSides: () => numberSides,
|
|
36
|
+
numberText: () => numberText,
|
|
37
|
+
offersNone: () => offersNone,
|
|
38
|
+
opWord: () => opWord,
|
|
39
|
+
pickOpWord: () => pickOpWord,
|
|
40
|
+
pickedDays: () => pickedDays,
|
|
41
|
+
rangeLabel: () => rangeLabel,
|
|
42
|
+
relativeLabel: () => relativeLabel,
|
|
43
|
+
removedOf: () => removedOf,
|
|
44
|
+
sameDay: () => sameDay,
|
|
45
|
+
suggest: () => suggest,
|
|
46
|
+
suggestionPick: () => suggestionPick,
|
|
47
|
+
takesMany: () => takesMany,
|
|
48
|
+
todayIn: () => todayIn,
|
|
49
|
+
toggled: () => toggled,
|
|
50
|
+
unitText: () => unitText,
|
|
51
|
+
valueOp: () => valueOp,
|
|
52
|
+
valuePick: () => valuePick,
|
|
53
|
+
weekday: () => weekday
|
|
54
|
+
});
|
|
55
|
+
export { DATE_WORDS, DAY_ONLY, ENGLISH_GRAMMAR, addDays, canFlip, changeText, chosenOf, dateFormat, daysLabel, daysPick, defaultFormat, explicitDays, fieldMatches, flipped, fromIsoDay, isNegative, isNone, isNumber, isoDay, listText, matchingFields, monthEnd, monthStart, nonePick, numberBounds, numberDraft, numberPresets, numberSides, numberText, offersNone, opWord, pickOpWord, pickedDays, rangeLabel, relativeLabel, removedOf, rules_exports, sameDay, suggest, suggestionPick, takesMany, todayIn, toggled, unitText, valueOp, valuePick, weekday };
|