@copilotkit/shared 2.0.0-rc.4 → 2.0.0-rc.41
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 +4 -15
- package/dist/a2ui-envelope.cjs +2 -2
- package/dist/a2ui-envelope.cjs.map +1 -1
- package/dist/a2ui-envelope.d.cts +1 -1
- package/dist/a2ui-envelope.d.cts.map +1 -1
- package/dist/a2ui-envelope.d.mts +1 -1
- package/dist/a2ui-envelope.d.mts.map +1 -1
- package/dist/a2ui-envelope.mjs +2 -2
- package/dist/a2ui-envelope.mjs.map +1 -1
- package/dist/a2ui-prompts.cjs +21 -62
- package/dist/a2ui-prompts.cjs.map +1 -1
- package/dist/a2ui-prompts.d.cts +8 -1
- package/dist/a2ui-prompts.d.cts.map +1 -1
- package/dist/a2ui-prompts.d.mts +8 -1
- package/dist/a2ui-prompts.d.mts.map +1 -1
- package/dist/a2ui-prompts.mjs +22 -62
- package/dist/a2ui-prompts.mjs.map +1 -1
- package/dist/attachments/types.d.cts +1 -3
- package/dist/attachments/types.d.cts.map +1 -1
- package/dist/attachments/types.d.mts +1 -3
- package/dist/attachments/types.d.mts.map +1 -1
- package/dist/attachments/utils.cjs +16 -5
- package/dist/attachments/utils.cjs.map +1 -1
- package/dist/attachments/utils.d.cts +3 -1
- package/dist/attachments/utils.d.cts.map +1 -1
- package/dist/attachments/utils.d.mts +3 -1
- package/dist/attachments/utils.d.mts.map +1 -1
- package/dist/attachments/utils.mjs +16 -5
- package/dist/attachments/utils.mjs.map +1 -1
- package/dist/finalize-events.cjs +16 -0
- package/dist/finalize-events.cjs.map +1 -1
- package/dist/finalize-events.d.cts.map +1 -1
- package/dist/finalize-events.d.mts.map +1 -1
- package/dist/finalize-events.mjs +16 -0
- package/dist/finalize-events.mjs.map +1 -1
- package/dist/generative-ui/basic-functions.cjs +1 -1
- package/dist/generative-ui/basic-functions.cjs.map +1 -1
- package/dist/generative-ui/basic-functions.mjs +1 -1
- package/dist/generative-ui/basic-functions.mjs.map +1 -1
- package/dist/generative-ui/catalog/catalog-export.cjs +329 -0
- package/dist/generative-ui/catalog/catalog-export.cjs.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.d.cts +92 -0
- package/dist/generative-ui/catalog/catalog-export.d.cts.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.d.mts +92 -0
- package/dist/generative-ui/catalog/catalog-export.d.mts.map +1 -0
- package/dist/generative-ui/catalog/catalog-export.mjs +328 -0
- package/dist/generative-ui/catalog/catalog-export.mjs.map +1 -0
- package/dist/generative-ui/catalog/catalog.cjs +315 -0
- package/dist/generative-ui/catalog/catalog.cjs.map +1 -0
- package/dist/generative-ui/catalog/catalog.d.cts +407 -0
- package/dist/generative-ui/catalog/catalog.d.cts.map +1 -0
- package/dist/generative-ui/catalog/catalog.d.mts +407 -0
- package/dist/generative-ui/catalog/catalog.d.mts.map +1 -0
- package/dist/generative-ui/catalog/catalog.mjs +312 -0
- package/dist/generative-ui/catalog/catalog.mjs.map +1 -0
- package/dist/generative-ui/catalog/errors.cjs +13 -0
- package/dist/generative-ui/catalog/errors.cjs.map +1 -0
- package/dist/generative-ui/catalog/errors.d.cts +46 -0
- package/dist/generative-ui/catalog/errors.d.cts.map +1 -0
- package/dist/generative-ui/catalog/errors.d.mts +46 -0
- package/dist/generative-ui/catalog/errors.d.mts.map +1 -0
- package/dist/generative-ui/catalog/errors.mjs +12 -0
- package/dist/generative-ui/catalog/errors.mjs.map +1 -0
- package/dist/generative-ui/catalog/index.d.mts +6 -0
- package/dist/generative-ui/catalog/json-schema.cjs +16 -0
- package/dist/generative-ui/catalog/json-schema.cjs.map +1 -0
- package/dist/generative-ui/catalog/json-schema.d.cts +12 -0
- package/dist/generative-ui/catalog/json-schema.d.cts.map +1 -0
- package/dist/generative-ui/catalog/json-schema.d.mts +12 -0
- package/dist/generative-ui/catalog/json-schema.d.mts.map +1 -0
- package/dist/generative-ui/catalog/json-schema.mjs +16 -0
- package/dist/generative-ui/catalog/json-schema.mjs.map +1 -0
- package/dist/generative-ui/catalog/refs.cjs +21 -0
- package/dist/generative-ui/catalog/refs.cjs.map +1 -0
- package/dist/generative-ui/catalog/refs.d.cts +55 -0
- package/dist/generative-ui/catalog/refs.d.cts.map +1 -0
- package/dist/generative-ui/catalog/refs.d.mts +55 -0
- package/dist/generative-ui/catalog/refs.d.mts.map +1 -0
- package/dist/generative-ui/catalog/refs.mjs +18 -0
- package/dist/generative-ui/catalog/refs.mjs.map +1 -0
- package/dist/generative-ui/catalog/schema.cjs +74 -0
- package/dist/generative-ui/catalog/schema.cjs.map +1 -0
- package/dist/generative-ui/catalog/schema.d.cts +43 -0
- package/dist/generative-ui/catalog/schema.d.cts.map +1 -0
- package/dist/generative-ui/catalog/schema.d.mts +43 -0
- package/dist/generative-ui/catalog/schema.d.mts.map +1 -0
- package/dist/generative-ui/catalog/schema.mjs +68 -0
- package/dist/generative-ui/catalog/schema.mjs.map +1 -0
- package/dist/generative-ui/child-refs.cjs +3 -3
- package/dist/generative-ui/child-refs.cjs.map +1 -1
- package/dist/generative-ui/child-refs.d.cts.map +1 -1
- package/dist/generative-ui/child-refs.d.mts.map +1 -1
- package/dist/generative-ui/child-refs.mjs +3 -3
- package/dist/generative-ui/child-refs.mjs.map +1 -1
- package/dist/generative-ui/clone-value.cjs +364 -0
- package/dist/generative-ui/clone-value.cjs.map +1 -0
- package/dist/generative-ui/clone-value.d.cts +51 -0
- package/dist/generative-ui/clone-value.d.cts.map +1 -0
- package/dist/generative-ui/clone-value.d.mts +51 -0
- package/dist/generative-ui/clone-value.d.mts.map +1 -0
- package/dist/generative-ui/clone-value.mjs +363 -0
- package/dist/generative-ui/clone-value.mjs.map +1 -0
- package/dist/generative-ui/compact-schema.cjs +187 -0
- package/dist/generative-ui/compact-schema.cjs.map +1 -0
- package/dist/generative-ui/compact-schema.d.cts +55 -0
- package/dist/generative-ui/compact-schema.d.cts.map +1 -0
- package/dist/generative-ui/compact-schema.d.mts +55 -0
- package/dist/generative-ui/compact-schema.d.mts.map +1 -0
- package/dist/generative-ui/compact-schema.mjs +185 -0
- package/dist/generative-ui/compact-schema.mjs.map +1 -0
- package/dist/generative-ui/index.cjs +286 -0
- package/dist/generative-ui/index.d.cts +39 -0
- package/dist/generative-ui/index.d.mts +41 -0
- package/dist/generative-ui/index.mjs +40 -0
- package/dist/generative-ui/is-record.cjs +6 -1
- package/dist/generative-ui/is-record.cjs.map +1 -1
- package/dist/generative-ui/is-record.d.cts +8 -0
- package/dist/generative-ui/is-record.d.cts.map +1 -0
- package/dist/generative-ui/is-record.d.mts +8 -0
- package/dist/generative-ui/is-record.d.mts.map +1 -0
- package/dist/generative-ui/is-record.mjs +6 -2
- package/dist/generative-ui/is-record.mjs.map +1 -1
- package/dist/generative-ui/prompt-spec.cjs +225 -0
- package/dist/generative-ui/prompt-spec.cjs.map +1 -0
- package/dist/generative-ui/prompt-spec.d.cts +94 -0
- package/dist/generative-ui/prompt-spec.d.cts.map +1 -0
- package/dist/generative-ui/prompt-spec.d.mts +94 -0
- package/dist/generative-ui/prompt-spec.d.mts.map +1 -0
- package/dist/generative-ui/prompt-spec.mjs +220 -0
- package/dist/generative-ui/prompt-spec.mjs.map +1 -0
- package/dist/generative-ui/prompt.cjs +10 -36
- package/dist/generative-ui/prompt.cjs.map +1 -1
- package/dist/generative-ui/prompt.d.cts +2 -1
- package/dist/generative-ui/prompt.d.cts.map +1 -1
- package/dist/generative-ui/prompt.d.mts +2 -1
- package/dist/generative-ui/prompt.d.mts.map +1 -1
- package/dist/generative-ui/prompt.mjs +12 -38
- package/dist/generative-ui/prompt.mjs.map +1 -1
- package/dist/generative-ui/render-ui-args.cjs +1 -0
- package/dist/generative-ui/render-ui-args.cjs.map +1 -1
- package/dist/generative-ui/render-ui-args.d.cts.map +1 -1
- package/dist/generative-ui/render-ui-args.d.mts.map +1 -1
- package/dist/generative-ui/render-ui-args.mjs +1 -0
- package/dist/generative-ui/render-ui-args.mjs.map +1 -1
- package/dist/generative-ui/schema-render.cjs +243 -0
- package/dist/generative-ui/schema-render.cjs.map +1 -0
- package/dist/generative-ui/schema-render.d.cts +44 -0
- package/dist/generative-ui/schema-render.d.cts.map +1 -0
- package/dist/generative-ui/schema-render.d.mts +44 -0
- package/dist/generative-ui/schema-render.d.mts.map +1 -0
- package/dist/generative-ui/schema-render.mjs +240 -0
- package/dist/generative-ui/schema-render.mjs.map +1 -0
- package/dist/generative-ui/standard/chart-config.cjs +347 -0
- package/dist/generative-ui/standard/chart-config.cjs.map +1 -0
- package/dist/generative-ui/standard/chart-config.d.cts +97 -0
- package/dist/generative-ui/standard/chart-config.d.cts.map +1 -0
- package/dist/generative-ui/standard/chart-config.d.mts +97 -0
- package/dist/generative-ui/standard/chart-config.d.mts.map +1 -0
- package/dist/generative-ui/standard/chart-config.mjs +342 -0
- package/dist/generative-ui/standard/chart-config.mjs.map +1 -0
- package/dist/generative-ui/standard/chart.cjs +56 -0
- package/dist/generative-ui/standard/chart.cjs.map +1 -0
- package/dist/generative-ui/standard/chart.d.cts +62 -0
- package/dist/generative-ui/standard/chart.d.cts.map +1 -0
- package/dist/generative-ui/standard/chart.d.mts +62 -0
- package/dist/generative-ui/standard/chart.d.mts.map +1 -0
- package/dist/generative-ui/standard/chart.mjs +54 -0
- package/dist/generative-ui/standard/chart.mjs.map +1 -0
- package/dist/generative-ui/standard/checks.cjs +74 -0
- package/dist/generative-ui/standard/checks.cjs.map +1 -0
- package/dist/generative-ui/standard/checks.d.cts +56 -0
- package/dist/generative-ui/standard/checks.d.cts.map +1 -0
- package/dist/generative-ui/standard/checks.d.mts +56 -0
- package/dist/generative-ui/standard/checks.d.mts.map +1 -0
- package/dist/generative-ui/standard/checks.mjs +71 -0
- package/dist/generative-ui/standard/checks.mjs.map +1 -0
- package/dist/generative-ui/standard/components.cjs +23 -0
- package/dist/generative-ui/standard/components.cjs.map +1 -0
- package/dist/generative-ui/standard/components.d.cts +24 -0
- package/dist/generative-ui/standard/components.d.cts.map +1 -0
- package/dist/generative-ui/standard/components.d.mts +24 -0
- package/dist/generative-ui/standard/components.d.mts.map +1 -0
- package/dist/generative-ui/standard/components.mjs +22 -0
- package/dist/generative-ui/standard/components.mjs.map +1 -0
- package/dist/generative-ui/standard/composites.cjs +143 -0
- package/dist/generative-ui/standard/composites.cjs.map +1 -0
- package/dist/generative-ui/standard/composites.d.cts +233 -0
- package/dist/generative-ui/standard/composites.d.cts.map +1 -0
- package/dist/generative-ui/standard/composites.d.mts +233 -0
- package/dist/generative-ui/standard/composites.d.mts.map +1 -0
- package/dist/generative-ui/standard/composites.mjs +132 -0
- package/dist/generative-ui/standard/composites.mjs.map +1 -0
- package/dist/generative-ui/standard/data.cjs +176 -0
- package/dist/generative-ui/standard/data.cjs.map +1 -0
- package/dist/generative-ui/standard/data.d.cts +365 -0
- package/dist/generative-ui/standard/data.d.cts.map +1 -0
- package/dist/generative-ui/standard/data.d.mts +365 -0
- package/dist/generative-ui/standard/data.d.mts.map +1 -0
- package/dist/generative-ui/standard/data.mjs +167 -0
- package/dist/generative-ui/standard/data.mjs.map +1 -0
- package/dist/generative-ui/standard/declarations.cjs +40 -0
- package/dist/generative-ui/standard/declarations.cjs.map +1 -0
- package/dist/generative-ui/standard/declarations.d.cts +2570 -0
- package/dist/generative-ui/standard/declarations.d.cts.map +1 -0
- package/dist/generative-ui/standard/declarations.d.mts +2571 -0
- package/dist/generative-ui/standard/declarations.d.mts.map +1 -0
- package/dist/generative-ui/standard/declarations.mjs +39 -0
- package/dist/generative-ui/standard/declarations.mjs.map +1 -0
- package/dist/generative-ui/standard/feedback.cjs +97 -0
- package/dist/generative-ui/standard/feedback.cjs.map +1 -0
- package/dist/generative-ui/standard/feedback.d.cts +133 -0
- package/dist/generative-ui/standard/feedback.d.cts.map +1 -0
- package/dist/generative-ui/standard/feedback.d.mts +133 -0
- package/dist/generative-ui/standard/feedback.d.mts.map +1 -0
- package/dist/generative-ui/standard/feedback.mjs +90 -0
- package/dist/generative-ui/standard/feedback.mjs.map +1 -0
- package/dist/generative-ui/standard/index.d.mts +20 -0
- package/dist/generative-ui/standard/inputs.cjs +333 -0
- package/dist/generative-ui/standard/inputs.cjs.map +1 -0
- package/dist/generative-ui/standard/inputs.d.cts +1128 -0
- package/dist/generative-ui/standard/inputs.d.cts.map +1 -0
- package/dist/generative-ui/standard/inputs.d.mts +1128 -0
- package/dist/generative-ui/standard/inputs.d.mts.map +1 -0
- package/dist/generative-ui/standard/inputs.mjs +318 -0
- package/dist/generative-ui/standard/inputs.mjs.map +1 -0
- package/dist/generative-ui/standard/layout.cjs +289 -0
- package/dist/generative-ui/standard/layout.cjs.map +1 -0
- package/dist/generative-ui/standard/layout.d.cts +1974 -0
- package/dist/generative-ui/standard/layout.d.cts.map +1 -0
- package/dist/generative-ui/standard/layout.d.mts +1975 -0
- package/dist/generative-ui/standard/layout.d.mts.map +1 -0
- package/dist/generative-ui/standard/layout.mjs +269 -0
- package/dist/generative-ui/standard/layout.mjs.map +1 -0
- package/dist/generative-ui/standard/map-helpers.cjs +104 -0
- package/dist/generative-ui/standard/map-helpers.cjs.map +1 -0
- package/dist/generative-ui/standard/map-helpers.d.cts +88 -0
- package/dist/generative-ui/standard/map-helpers.d.cts.map +1 -0
- package/dist/generative-ui/standard/map-helpers.d.mts +88 -0
- package/dist/generative-ui/standard/map-helpers.d.mts.map +1 -0
- package/dist/generative-ui/standard/map-helpers.mjs +95 -0
- package/dist/generative-ui/standard/map-helpers.mjs.map +1 -0
- package/dist/generative-ui/standard/map.cjs +27 -0
- package/dist/generative-ui/standard/map.cjs.map +1 -0
- package/dist/generative-ui/standard/map.d.cts +31 -0
- package/dist/generative-ui/standard/map.d.cts.map +1 -0
- package/dist/generative-ui/standard/map.d.mts +31 -0
- package/dist/generative-ui/standard/map.d.mts.map +1 -0
- package/dist/generative-ui/standard/map.mjs +25 -0
- package/dist/generative-ui/standard/map.mjs.map +1 -0
- package/dist/generative-ui/standard/media.cjs +215 -0
- package/dist/generative-ui/standard/media.cjs.map +1 -0
- package/dist/generative-ui/standard/media.d.cts +396 -0
- package/dist/generative-ui/standard/media.d.cts.map +1 -0
- package/dist/generative-ui/standard/media.d.mts +396 -0
- package/dist/generative-ui/standard/media.d.mts.map +1 -0
- package/dist/generative-ui/standard/media.mjs +205 -0
- package/dist/generative-ui/standard/media.mjs.map +1 -0
- package/dist/generative-ui/standard/parameter-order.cjs +231 -0
- package/dist/generative-ui/standard/parameter-order.cjs.map +1 -0
- package/dist/generative-ui/standard/parameter-order.d.cts +84 -0
- package/dist/generative-ui/standard/parameter-order.d.cts.map +1 -0
- package/dist/generative-ui/standard/parameter-order.d.mts +84 -0
- package/dist/generative-ui/standard/parameter-order.d.mts.map +1 -0
- package/dist/generative-ui/standard/parameter-order.mjs +230 -0
- package/dist/generative-ui/standard/parameter-order.mjs.map +1 -0
- package/dist/generative-ui/standard/style-helpers.cjs +151 -0
- package/dist/generative-ui/standard/style-helpers.cjs.map +1 -0
- package/dist/generative-ui/standard/style-helpers.d.cts +56 -0
- package/dist/generative-ui/standard/style-helpers.d.cts.map +1 -0
- package/dist/generative-ui/standard/style-helpers.d.mts +56 -0
- package/dist/generative-ui/standard/style-helpers.d.mts.map +1 -0
- package/dist/generative-ui/standard/style-helpers.mjs +142 -0
- package/dist/generative-ui/standard/style-helpers.mjs.map +1 -0
- package/dist/generative-ui/standard/styles.cjs +62 -0
- package/dist/generative-ui/standard/styles.cjs.map +1 -0
- package/dist/generative-ui/standard/styles.d.cts +17 -0
- package/dist/generative-ui/standard/styles.d.cts.map +1 -0
- package/dist/generative-ui/standard/styles.d.mts +17 -0
- package/dist/generative-ui/standard/styles.d.mts.map +1 -0
- package/dist/generative-ui/standard/styles.mjs +60 -0
- package/dist/generative-ui/standard/styles.mjs.map +1 -0
- package/dist/generative-ui/standard/text.cjs +226 -0
- package/dist/generative-ui/standard/text.cjs.map +1 -0
- package/dist/generative-ui/standard/text.d.cts +522 -0
- package/dist/generative-ui/standard/text.d.cts.map +1 -0
- package/dist/generative-ui/standard/text.d.mts +522 -0
- package/dist/generative-ui/standard/text.d.mts.map +1 -0
- package/dist/generative-ui/standard/text.mjs +209 -0
- package/dist/generative-ui/standard/text.mjs.map +1 -0
- package/dist/generative-ui/standard/theme.cjs +115 -0
- package/dist/generative-ui/standard/theme.cjs.map +1 -0
- package/dist/generative-ui/standard/theme.d.cts +60 -0
- package/dist/generative-ui/standard/theme.d.cts.map +1 -0
- package/dist/generative-ui/standard/theme.d.mts +60 -0
- package/dist/generative-ui/standard/theme.d.mts.map +1 -0
- package/dist/generative-ui/standard/theme.mjs +112 -0
- package/dist/generative-ui/standard/theme.mjs.map +1 -0
- package/dist/generative-ui/standard/tokens.cjs +336 -0
- package/dist/generative-ui/standard/tokens.cjs.map +1 -0
- package/dist/generative-ui/standard/tokens.d.cts +76 -0
- package/dist/generative-ui/standard/tokens.d.cts.map +1 -0
- package/dist/generative-ui/standard/tokens.d.mts +76 -0
- package/dist/generative-ui/standard/tokens.d.mts.map +1 -0
- package/dist/generative-ui/standard/tokens.mjs +305 -0
- package/dist/generative-ui/standard/tokens.mjs.map +1 -0
- package/dist/generative-ui/standard/url.cjs +54 -0
- package/dist/generative-ui/standard/url.cjs.map +1 -0
- package/dist/generative-ui/standard/url.d.cts +32 -0
- package/dist/generative-ui/standard/url.d.cts.map +1 -0
- package/dist/generative-ui/standard/url.d.mts +32 -0
- package/dist/generative-ui/standard/url.d.mts.map +1 -0
- package/dist/generative-ui/standard/url.mjs +50 -0
- package/dist/generative-ui/standard/url.mjs.map +1 -0
- package/dist/generative-ui/thrown.cjs +69 -0
- package/dist/generative-ui/thrown.cjs.map +1 -0
- package/dist/generative-ui/thrown.d.cts +21 -0
- package/dist/generative-ui/thrown.d.cts.map +1 -0
- package/dist/generative-ui/thrown.d.mts +21 -0
- package/dist/generative-ui/thrown.d.mts.map +1 -0
- package/dist/generative-ui/thrown.mjs +67 -0
- package/dist/generative-ui/thrown.mjs.map +1 -0
- package/dist/generative-ui/types.cjs +2 -2
- package/dist/generative-ui/types.cjs.map +1 -1
- package/dist/generative-ui/types.d.cts +7 -7
- package/dist/generative-ui/types.d.cts.map +1 -1
- package/dist/generative-ui/types.d.mts +7 -7
- package/dist/generative-ui/types.d.mts.map +1 -1
- package/dist/generative-ui/types.mjs +2 -2
- package/dist/generative-ui/types.mjs.map +1 -1
- package/dist/generative-ui/validate-operation.cjs +2 -2
- package/dist/generative-ui/validate-operation.cjs.map +1 -1
- package/dist/generative-ui/validate-operation.mjs +2 -2
- package/dist/generative-ui/validate-operation.mjs.map +1 -1
- package/dist/index.cjs +18 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -16
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +17 -16
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +10 -8
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1233 -456
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/standard-schema.cjs +20 -7
- package/dist/standard-schema.cjs.map +1 -1
- package/dist/standard-schema.d.cts +15 -16
- package/dist/standard-schema.d.cts.map +1 -1
- package/dist/standard-schema.d.mts +15 -16
- package/dist/standard-schema.d.mts.map +1 -1
- package/dist/standard-schema.mjs +20 -8
- package/dist/standard-schema.mjs.map +1 -1
- package/dist/telemetry/lambda-client.cjs +1 -1
- package/dist/telemetry/lambda-client.cjs.map +1 -1
- package/dist/telemetry/lambda-client.d.cts.map +1 -1
- package/dist/telemetry/lambda-client.d.mts.map +1 -1
- package/dist/telemetry/lambda-client.mjs +1 -1
- package/dist/telemetry/lambda-client.mjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.cjs +0 -5
- package/dist/telemetry/telemetry-disabled.cjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.cts +0 -5
- package/dist/telemetry/telemetry-disabled.d.cts.map +1 -1
- package/dist/telemetry/telemetry-disabled.d.mts +0 -5
- package/dist/telemetry/telemetry-disabled.d.mts.map +1 -1
- package/dist/telemetry/telemetry-disabled.mjs +0 -5
- package/dist/telemetry/telemetry-disabled.mjs.map +1 -1
- package/dist/types/message.d.cts +1 -18
- package/dist/types/message.d.cts.map +1 -1
- package/dist/types/message.d.mts +1 -18
- package/dist/types/message.d.mts.map +1 -1
- package/dist/utils/errors.cjs +5 -42
- package/dist/utils/errors.cjs.map +1 -1
- package/dist/utils/errors.d.cts +16 -34
- package/dist/utils/errors.d.cts.map +1 -1
- package/dist/utils/errors.d.mts +16 -34
- package/dist/utils/errors.d.mts.map +1 -1
- package/dist/utils/errors.mjs +6 -41
- package/dist/utils/errors.mjs.map +1 -1
- package/dist/utils/index.cjs +0 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +4 -6
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +4 -6
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +4 -6
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/inspector-visibility.cjs +25 -3
- package/dist/utils/inspector-visibility.cjs.map +1 -1
- package/dist/utils/inspector-visibility.d.cts +26 -3
- package/dist/utils/inspector-visibility.d.cts.map +1 -1
- package/dist/utils/inspector-visibility.d.mts +26 -3
- package/dist/utils/inspector-visibility.d.mts.map +1 -1
- package/dist/utils/inspector-visibility.mjs +25 -4
- package/dist/utils/inspector-visibility.mjs.map +1 -1
- package/dist/utils/json-schema.cjs +4 -79
- package/dist/utils/json-schema.cjs.map +1 -1
- package/dist/utils/json-schema.d.cts +1 -4
- package/dist/utils/json-schema.d.cts.map +1 -1
- package/dist/utils/json-schema.d.mts +1 -4
- package/dist/utils/json-schema.d.mts.map +1 -1
- package/dist/utils/json-schema.mjs +5 -78
- package/dist/utils/json-schema.mjs.map +1 -1
- package/dist/utils/random-id.cjs +13 -26
- package/dist/utils/random-id.cjs.map +1 -1
- package/dist/utils/random-id.d.cts +6 -3
- package/dist/utils/random-id.d.cts.map +1 -1
- package/dist/utils/random-id.d.mts +6 -3
- package/dist/utils/random-id.d.mts.map +1 -1
- package/dist/utils/random-id.mjs +14 -25
- package/dist/utils/random-id.mjs.map +1 -1
- package/package.json +19 -32
- package/scripts/verify-cjs-exports.cjs +1 -1
- package/src/__tests__/a2ui-envelope.test.ts +18 -13
- package/src/__tests__/a2ui-prompts.test.ts +47 -14
- package/src/__tests__/fixtures/prompt-goldens.json +354 -0
- package/src/__tests__/prompt-spec.test.ts +191 -0
- package/src/__tests__/root-entry-browser-safety.test.ts +5 -7
- package/src/__tests__/schema-render.test.ts +323 -0
- package/src/__tests__/standard-schema.test.ts +61 -101
- package/src/a2ui-envelope.ts +7 -6
- package/src/a2ui-prompts.ts +47 -96
- package/src/attachments/__tests__/utils.test.ts +22 -0
- package/src/attachments/types.ts +1 -3
- package/src/attachments/utils.ts +23 -5
- package/src/finalize-events.ts +16 -0
- package/src/generative-ui/__tests__/clone-value-differential.test.ts +480 -0
- package/src/generative-ui/__tests__/clone-value.test.ts +226 -0
- package/src/generative-ui/__tests__/render-ui-args.test.ts +7 -7
- package/src/generative-ui/__tests__/validate-operation.test.ts +19 -13
- package/src/generative-ui/base.ts +9 -0
- package/src/generative-ui/basic-functions.ts +1 -1
- package/src/generative-ui/catalog/catalog-export.ts +478 -0
- package/src/generative-ui/catalog/catalog.ts +1167 -0
- package/src/generative-ui/catalog/errors.ts +102 -0
- package/src/generative-ui/catalog/index.ts +6 -0
- package/src/generative-ui/catalog/json-schema.ts +14 -0
- package/src/generative-ui/catalog/refs.ts +87 -0
- package/src/generative-ui/catalog/schema.ts +107 -0
- package/src/generative-ui/child-refs.ts +5 -4
- package/src/generative-ui/clone-value.ts +511 -0
- package/src/generative-ui/compact-schema.ts +277 -0
- package/src/generative-ui/index.ts +14 -0
- package/src/generative-ui/is-record.ts +6 -1
- package/src/generative-ui/prompt-spec.ts +335 -0
- package/src/generative-ui/prompt.ts +25 -75
- package/src/generative-ui/render-ui-args.ts +3 -0
- package/src/generative-ui/schema-render.ts +378 -0
- package/src/generative-ui/standard/__tests__/standard-helpers.test.ts +407 -0
- package/src/generative-ui/standard/__tests__/theme.test.ts +61 -0
- package/src/generative-ui/standard/__tests__/tokens.test.ts +139 -0
- package/src/generative-ui/standard/chart-config.ts +434 -0
- package/src/generative-ui/standard/chart.ts +79 -0
- package/src/generative-ui/standard/checks.ts +98 -0
- package/src/generative-ui/standard/components.ts +35 -0
- package/src/generative-ui/standard/composites.ts +158 -0
- package/src/generative-ui/standard/data.ts +213 -0
- package/src/generative-ui/standard/declarations.ts +57 -0
- package/src/generative-ui/standard/feedback.ts +105 -0
- package/src/generative-ui/standard/index.ts +55 -0
- package/src/generative-ui/standard/inputs.ts +423 -0
- package/src/generative-ui/standard/layout.ts +312 -0
- package/src/generative-ui/standard/map-helpers.ts +155 -0
- package/src/generative-ui/standard/map.ts +32 -0
- package/src/generative-ui/standard/media.ts +265 -0
- package/src/generative-ui/standard/parameter-order.ts +155 -0
- package/src/generative-ui/standard/style-helpers.ts +170 -0
- package/src/generative-ui/standard/styles.ts +79 -0
- package/src/generative-ui/standard/text.ts +210 -0
- package/src/generative-ui/standard/theme.ts +198 -0
- package/src/generative-ui/standard/tokens.ts +317 -0
- package/src/generative-ui/standard/url.ts +51 -0
- package/src/generative-ui/thrown.ts +90 -0
- package/src/generative-ui/types.ts +10 -7
- package/src/generative-ui/validate-operation.ts +2 -2
- package/src/index.ts +9 -17
- package/src/standard-schema.ts +24 -27
- package/src/telemetry/lambda-client.ts +8 -3
- package/src/telemetry/model-host.test.ts +2 -5
- package/src/telemetry/telemetry-disabled.ts +0 -5
- package/src/types/message.ts +1 -19
- package/src/utils/__tests__/errors.test.ts +44 -0
- package/src/utils/__tests__/json-schema.test.ts +3 -479
- package/src/utils/__tests__/random-id.test.ts +37 -0
- package/src/utils/errors.ts +28 -85
- package/src/utils/index.ts +0 -2
- package/src/utils/inspector-visibility.test.ts +26 -0
- package/src/utils/inspector-visibility.ts +35 -3
- package/src/utils/json-schema.ts +5 -152
- package/src/utils/random-id.ts +17 -37
- package/tsconfig.json +3 -1
- package/tsdown.config.ts +2 -19
- package/dist/event-transforms/index.cjs +0 -15
- package/dist/event-transforms/index.d.cts +0 -4
- package/dist/event-transforms/index.d.mts +0 -4
- package/dist/event-transforms/index.mjs +0 -5
- package/dist/event-transforms/open-generative-ui-middleware.cjs +0 -286
- package/dist/event-transforms/open-generative-ui-middleware.cjs.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.cts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.d.mts +0 -60
- package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +0 -1
- package/dist/event-transforms/open-generative-ui-middleware.mjs +0 -283
- package/dist/event-transforms/open-generative-ui-middleware.mjs.map +0 -1
- package/dist/event-transforms/recorded-events.cjs +0 -59
- package/dist/event-transforms/recorded-events.cjs.map +0 -1
- package/dist/event-transforms/recorded-events.d.cts +0 -23
- package/dist/event-transforms/recorded-events.d.cts.map +0 -1
- package/dist/event-transforms/recorded-events.d.mts +0 -23
- package/dist/event-transforms/recorded-events.d.mts.map +0 -1
- package/dist/event-transforms/recorded-events.mjs +0 -58
- package/dist/event-transforms/recorded-events.mjs.map +0 -1
- package/dist/telemetry/events.d.cts +0 -72
- package/dist/telemetry/events.d.cts.map +0 -1
- package/dist/telemetry/events.d.mts +0 -72
- package/dist/telemetry/events.d.mts.map +0 -1
- package/dist/telemetry/index.cjs +0 -18
- package/dist/telemetry/index.d.cts +0 -5
- package/dist/telemetry/index.d.mts +0 -5
- package/dist/telemetry/index.mjs +0 -6
- package/dist/telemetry/telemetry-client.cjs +0 -165
- package/dist/telemetry/telemetry-client.cjs.map +0 -1
- package/dist/telemetry/telemetry-client.d.cts +0 -87
- package/dist/telemetry/telemetry-client.d.cts.map +0 -1
- package/dist/telemetry/telemetry-client.d.mts +0 -87
- package/dist/telemetry/telemetry-client.d.mts.map +0 -1
- package/dist/telemetry/telemetry-client.mjs +0 -164
- package/dist/telemetry/telemetry-client.mjs.map +0 -1
- package/dist/telemetry/utils.cjs +0 -14
- package/dist/telemetry/utils.cjs.map +0 -1
- package/dist/telemetry/utils.mjs +0 -13
- package/dist/telemetry/utils.mjs.map +0 -1
- package/dist/utils/conditions.cjs +0 -32
- package/dist/utils/conditions.cjs.map +0 -1
- package/dist/utils/conditions.d.cts +0 -31
- package/dist/utils/conditions.d.cts.map +0 -1
- package/dist/utils/conditions.d.mts +0 -31
- package/dist/utils/conditions.d.mts.map +0 -1
- package/dist/utils/conditions.mjs +0 -31
- package/dist/utils/conditions.mjs.map +0 -1
- package/dist/utils/console-styling.cjs +0 -91
- package/dist/utils/console-styling.cjs.map +0 -1
- package/dist/utils/console-styling.d.cts +0 -65
- package/dist/utils/console-styling.d.cts.map +0 -1
- package/dist/utils/console-styling.d.mts +0 -65
- package/dist/utils/console-styling.d.mts.map +0 -1
- package/dist/utils/console-styling.mjs +0 -85
- package/dist/utils/console-styling.mjs.map +0 -1
- package/src/__tests__/zod-regression.test.ts +0 -319
- package/src/event-transforms/index.ts +0 -5
- package/src/event-transforms/open-generative-ui-middleware.ts +0 -392
- package/src/event-transforms/recorded-events.test.ts +0 -166
- package/src/event-transforms/recorded-events.ts +0 -74
- package/src/telemetry/events.ts +0 -68
- package/src/telemetry/index.ts +0 -9
- package/src/telemetry/telemetry-blank-license-identity.test.ts +0 -128
- package/src/telemetry/telemetry-client.test.ts +0 -798
- package/src/telemetry/telemetry-client.ts +0 -328
- package/src/telemetry/utils.ts +0 -15
- package/src/utils/__tests__/conditions.test.ts +0 -161
- package/src/utils/conditions.ts +0 -116
- package/src/utils/console-styling.ts +0 -126
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.mts","names":[],"sources":["../../../src/generative-ui/standard/layout.ts"],"mappings":";;;;;;cAKa,SAAA,EAAS,CAAA,CAAA,QAAA,WAAA,CAAA,CAAA,SAAA,EAAA,CAAA,CAAA,SAAA;;cAGT,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAMV,cAAA,EAAc,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAOd,cAAA,EAAc,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmBd,oBAAA;AAAA,cACA,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkBvB,YAAA,EAAY,CAAA,CAAA,SAAA;;;cACZ,UAAA,EAAU,CAAA,CAAA,SAAA;;;;;;;;cAiBV,aAAA,EAAa,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkBb,kBAAA"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { child } from "../catalog/refs.mjs";
|
|
2
|
+
import { ALIGN, BORDER_COLORS, JUSTIFY, RADII, WRAP } from "./tokens.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//#region src/generative-ui/standard/layout.ts
|
|
6
|
+
/** A number is a count of 4px steps. A string is raw CSS. */
|
|
7
|
+
const sizeValue = z.union([z.number(), z.string()]);
|
|
8
|
+
/** The A2UI `weight`: how much of the free space of a Row or Column to take. */
|
|
9
|
+
const weightProp = z.number().optional().describe("flex-grow in a Row or Column");
|
|
10
|
+
const radiusValue = z.union([
|
|
11
|
+
z.enum(RADII),
|
|
12
|
+
z.number(),
|
|
13
|
+
z.string(),
|
|
14
|
+
z.object({
|
|
15
|
+
topLeft: z.string().optional(),
|
|
16
|
+
topRight: z.string().optional(),
|
|
17
|
+
bottomLeft: z.string().optional(),
|
|
18
|
+
bottomRight: z.string().optional()
|
|
19
|
+
})
|
|
20
|
+
]);
|
|
21
|
+
/**
|
|
22
|
+
* The layout props of every container. Spread them into a props schema:
|
|
23
|
+
* `z.object({ ...layoutProps, variant: ... })`. The children of a container
|
|
24
|
+
* are a slot, not a prop.
|
|
25
|
+
*/
|
|
26
|
+
const layoutProps = {
|
|
27
|
+
align: z.enum(ALIGN).optional(),
|
|
28
|
+
justify: z.enum(JUSTIFY).optional(),
|
|
29
|
+
wrap: z.enum(WRAP).optional(),
|
|
30
|
+
gap: sizeValue.optional().describe("4px steps when a number"),
|
|
31
|
+
rowGap: sizeValue.optional(),
|
|
32
|
+
columnGap: sizeValue.optional(),
|
|
33
|
+
padding: sizeValue.optional().describe("4px steps when a number"),
|
|
34
|
+
background: z.string().optional().describe("Leave it unset. A surface token such as surface, surface-secondary, info, success, warning, danger, discovery, or one with -solid, or a CSS color. Only one summary panel in a Card uses \"surface-secondary\""),
|
|
35
|
+
border: z.boolean().optional(),
|
|
36
|
+
borderColor: z.enum(BORDER_COLORS).optional(),
|
|
37
|
+
radius: radiusValue.optional(),
|
|
38
|
+
width: sizeValue.optional(),
|
|
39
|
+
height: sizeValue.optional(),
|
|
40
|
+
minWidth: sizeValue.optional(),
|
|
41
|
+
maxWidth: sizeValue.optional(),
|
|
42
|
+
minHeight: sizeValue.optional(),
|
|
43
|
+
maxHeight: sizeValue.optional(),
|
|
44
|
+
flex: z.number().optional(),
|
|
45
|
+
weight: weightProp,
|
|
46
|
+
aspectRatio: z.string().optional(),
|
|
47
|
+
scrollable: z.boolean().optional(),
|
|
48
|
+
clip: z.boolean().optional(),
|
|
49
|
+
shadow: z.boolean().optional(),
|
|
50
|
+
inline: z.boolean().optional(),
|
|
51
|
+
role: z.string().optional().describe("ARIA role"),
|
|
52
|
+
flush: z.boolean().optional().describe("No padding"),
|
|
53
|
+
minSize: sizeValue.optional().describe("Minimum width and height"),
|
|
54
|
+
maxSize: sizeValue.optional().describe("Maximum width and height"),
|
|
55
|
+
disableAutoSpacing: z.boolean().optional().describe("No default gap between children")
|
|
56
|
+
};
|
|
57
|
+
const layoutSchema = z.object(layoutProps);
|
|
58
|
+
/** The arguments of a click or visibility event: none. */
|
|
59
|
+
const NO_ARGS = z.object({});
|
|
60
|
+
/**
|
|
61
|
+
* The `onVisible` event of every container: sent once, the first time the
|
|
62
|
+
* container scrolls into view.
|
|
63
|
+
*/
|
|
64
|
+
const VISIBLE_EVENT = { onVisible: {
|
|
65
|
+
description: "Sent once, the first time the container scrolls into view. Use it to load more content lazily.",
|
|
66
|
+
parameters: NO_ARGS
|
|
67
|
+
} };
|
|
68
|
+
/** The slot of every container: a list of children or a template. */
|
|
69
|
+
const CHILDREN_SLOT = { children: "multiple" };
|
|
70
|
+
const boxSchema = z.object({
|
|
71
|
+
...layoutProps,
|
|
72
|
+
direction: z.enum(["col", "row"]).optional().describe("Default \"col\"")
|
|
73
|
+
});
|
|
74
|
+
const gridSchema = z.object({
|
|
75
|
+
...layoutProps,
|
|
76
|
+
columns: z.union([z.number(), z.string()]).optional().describe("Column count or CSS template. Default 2"),
|
|
77
|
+
minChildWidth: sizeValue.optional(),
|
|
78
|
+
rows: z.union([z.number(), z.string()]).optional()
|
|
79
|
+
});
|
|
80
|
+
const gridItemSchema = z.object({
|
|
81
|
+
...layoutProps,
|
|
82
|
+
span: z.number().optional(),
|
|
83
|
+
rowSpan: z.number().optional()
|
|
84
|
+
});
|
|
85
|
+
const cardSchema = z.object({
|
|
86
|
+
...layoutProps,
|
|
87
|
+
variant: z.enum([
|
|
88
|
+
"default",
|
|
89
|
+
"outline",
|
|
90
|
+
"section",
|
|
91
|
+
"soft",
|
|
92
|
+
"elevated",
|
|
93
|
+
"transparent"
|
|
94
|
+
]).optional(),
|
|
95
|
+
shadowStyle: z.enum([
|
|
96
|
+
"none",
|
|
97
|
+
"sm",
|
|
98
|
+
"md"
|
|
99
|
+
]).optional().describe("Overrides the shadow of the variant"),
|
|
100
|
+
size: z.enum([
|
|
101
|
+
"sm",
|
|
102
|
+
"md",
|
|
103
|
+
"lg"
|
|
104
|
+
]).optional().describe("The padding preset: 8, 16 or 24px. Default \"md\"")
|
|
105
|
+
});
|
|
106
|
+
const flowSchema = z.object({
|
|
107
|
+
...layoutProps,
|
|
108
|
+
columns: z.number().optional(),
|
|
109
|
+
rows: z.number().optional(),
|
|
110
|
+
layout: z.enum(["pack", "fixed"]).optional().describe("Default \"pack\"")
|
|
111
|
+
});
|
|
112
|
+
const flowItemSchema = z.object({
|
|
113
|
+
...layoutProps,
|
|
114
|
+
span: z.number().optional(),
|
|
115
|
+
rowSpan: z.number().optional(),
|
|
116
|
+
aspectRatio: z.string().optional().describe("Default \"1 / 1\""),
|
|
117
|
+
aspectMode: z.enum(["soft", "fixed"]).optional()
|
|
118
|
+
});
|
|
119
|
+
const carouselSchema = z.object({
|
|
120
|
+
...layoutProps,
|
|
121
|
+
label: z.string().optional().describe("A short name of the carousel for screen readers"),
|
|
122
|
+
visibleItems: z.number().optional(),
|
|
123
|
+
showArrows: z.boolean().optional().describe("Default true"),
|
|
124
|
+
activeIndex: z.number().optional().describe("The index of the slide in view. Bind it with { \"@path\": \"/x\" } to read or set it"),
|
|
125
|
+
previousLabel: z.string().optional().describe("Default \"Previous\""),
|
|
126
|
+
nextLabel: z.string().optional().describe("Default \"Next\""),
|
|
127
|
+
snap: z.enum([
|
|
128
|
+
"none",
|
|
129
|
+
"proximity",
|
|
130
|
+
"mandatory"
|
|
131
|
+
]).optional(),
|
|
132
|
+
snapAlign: z.enum([
|
|
133
|
+
"start",
|
|
134
|
+
"center",
|
|
135
|
+
"end"
|
|
136
|
+
]).optional()
|
|
137
|
+
});
|
|
138
|
+
const CAROUSEL_MEDIA_SIZES = [
|
|
139
|
+
"sm",
|
|
140
|
+
"md",
|
|
141
|
+
"lg"
|
|
142
|
+
];
|
|
143
|
+
const carouselMediaItemSchema = z.object({
|
|
144
|
+
...layoutProps,
|
|
145
|
+
url: z.string().describe("Image URL"),
|
|
146
|
+
description: z.string().optional().describe("What the image shows, for screen readers"),
|
|
147
|
+
size: z.enum(CAROUSEL_MEDIA_SIZES).optional().describe("The width: \"sm\" 160px, \"md\" 240px, \"lg\" 320px. Default \"md\""),
|
|
148
|
+
aspectRatio: z.string().optional().describe("Default \"4 / 3\""),
|
|
149
|
+
href: z.string().optional().describe("Opens this URL in a new tab"),
|
|
150
|
+
lightbox: z.boolean().optional().describe("Default true: a click opens all slides full-screen")
|
|
151
|
+
});
|
|
152
|
+
const spacerSchema = z.object({ minSize: sizeValue.optional() });
|
|
153
|
+
const tabsSchema = z.object({
|
|
154
|
+
tabs: z.array(z.object({
|
|
155
|
+
title: z.string().describe("The tab title"),
|
|
156
|
+
child: child("The id of the panel component")
|
|
157
|
+
})).describe("One entry per tab"),
|
|
158
|
+
selectedIndex: z.number().optional().describe("The open tab. Default 0. Bind it with { \"@path\": \"/x\" } to read it"),
|
|
159
|
+
weight: weightProp
|
|
160
|
+
});
|
|
161
|
+
const dividerSchema = z.object({
|
|
162
|
+
axis: z.enum(["horizontal", "vertical"]).optional().describe("Default \"horizontal\""),
|
|
163
|
+
weight: weightProp,
|
|
164
|
+
color: z.enum(BORDER_COLORS).optional(),
|
|
165
|
+
size: z.number().optional(),
|
|
166
|
+
spacing: sizeValue.optional(),
|
|
167
|
+
flush: z.boolean().optional()
|
|
168
|
+
});
|
|
169
|
+
/**
|
|
170
|
+
* The standard layout components, without their framework components:
|
|
171
|
+
* containers, Spacer and Divider. Every container has a "multiple"
|
|
172
|
+
* `children` slot, so it takes a list of child ids or a template
|
|
173
|
+
* `{ componentId, path }`.
|
|
174
|
+
*/
|
|
175
|
+
const layoutDeclarations = {
|
|
176
|
+
Box: {
|
|
177
|
+
description: "A flex container. It stacks its children in a column (direction \"row\" puts them in a row). Use it to group children with gap, padding, border, radius or background.",
|
|
178
|
+
props: boxSchema,
|
|
179
|
+
events: VISIBLE_EVENT,
|
|
180
|
+
slots: CHILDREN_SLOT
|
|
181
|
+
},
|
|
182
|
+
Column: {
|
|
183
|
+
description: "A vertical flex container. Its default gap already separates sections, so do not add padding, background or a Spacer for space.",
|
|
184
|
+
props: layoutSchema,
|
|
185
|
+
events: VISIBLE_EVENT,
|
|
186
|
+
slots: CHILDREN_SLOT
|
|
187
|
+
},
|
|
188
|
+
Row: {
|
|
189
|
+
description: "A horizontal flex container. Label and value pair: justify \"spaceBetween\", a Caption left and a Text with fontWeight \"medium\" right. Buttons go in a Row at the bottom of a Card: one variant \"primary\", the others default or \"borderless\".",
|
|
190
|
+
props: layoutSchema,
|
|
191
|
+
events: VISIBLE_EVENT,
|
|
192
|
+
slots: CHILDREN_SLOT
|
|
193
|
+
},
|
|
194
|
+
Grid: {
|
|
195
|
+
description: "A CSS grid container. On a narrow screen, its columns collapse towards one column.",
|
|
196
|
+
props: gridSchema,
|
|
197
|
+
events: VISIBLE_EVENT,
|
|
198
|
+
slots: CHILDREN_SLOT
|
|
199
|
+
},
|
|
200
|
+
GridItem: {
|
|
201
|
+
description: "A cell of a Grid, with an optional span. A span that covers all rendered columns fills the row.",
|
|
202
|
+
props: gridItemSchema,
|
|
203
|
+
events: VISIBLE_EVENT,
|
|
204
|
+
slots: CHILDREN_SLOT
|
|
205
|
+
},
|
|
206
|
+
Card: {
|
|
207
|
+
description: "A bordered panel, only for an interactive panel (controls, a form, a configurator); tables, charts and text need none. Give it a Title and a Caption. Separate groups with a Divider or the gap, never a nested Card or bordered Box. Variant \"section\": no box; \"outline\": always a box. In markdown mode, without controls it renders as \"section\" unless variant or border is set.",
|
|
208
|
+
props: cardSchema,
|
|
209
|
+
events: VISIBLE_EVENT,
|
|
210
|
+
slots: {
|
|
211
|
+
child: "single",
|
|
212
|
+
children: "multiple"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
Flow: {
|
|
216
|
+
description: "A masonry-like grid that packs cells of different sizes. Put FlowItem children in it.",
|
|
217
|
+
props: flowSchema,
|
|
218
|
+
events: VISIBLE_EVENT,
|
|
219
|
+
slots: CHILDREN_SLOT
|
|
220
|
+
},
|
|
221
|
+
FlowItem: {
|
|
222
|
+
description: "A cell of a Flow, with an optional span.",
|
|
223
|
+
props: flowItemSchema,
|
|
224
|
+
events: VISIBLE_EVENT,
|
|
225
|
+
slots: CHILDREN_SLOT
|
|
226
|
+
},
|
|
227
|
+
Carousel: {
|
|
228
|
+
description: "A horizontally scrolling row that snaps to its CarouselItem or CarouselMediaItem children, with arrows. Bind activeIndex to read or set the slide in view.",
|
|
229
|
+
props: carouselSchema,
|
|
230
|
+
events: VISIBLE_EVENT,
|
|
231
|
+
slots: CHILDREN_SLOT,
|
|
232
|
+
writable: ["activeIndex"]
|
|
233
|
+
},
|
|
234
|
+
CarouselItem: {
|
|
235
|
+
description: "A slide of a Carousel.",
|
|
236
|
+
props: layoutSchema,
|
|
237
|
+
events: VISIBLE_EVENT,
|
|
238
|
+
slots: CHILDREN_SLOT
|
|
239
|
+
},
|
|
240
|
+
CarouselMediaItem: {
|
|
241
|
+
description: "A Carousel slide: an image with its children (a Caption, a Text) under it. size \"sm\" 160px, \"md\" 240px (default), \"lg\" 320px wide. A click opens all slides full-screen, unless href or onClick is set.",
|
|
242
|
+
props: carouselMediaItemSchema,
|
|
243
|
+
events: {
|
|
244
|
+
...VISIBLE_EVENT,
|
|
245
|
+
onClick: {
|
|
246
|
+
description: "Sent when the user clicks the image. It replaces the full-screen view.",
|
|
247
|
+
parameters: NO_ARGS
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
slots: CHILDREN_SLOT
|
|
251
|
+
},
|
|
252
|
+
Spacer: {
|
|
253
|
+
description: "Flexible empty space. You almost never need it: use the default gap.",
|
|
254
|
+
props: spacerSchema
|
|
255
|
+
},
|
|
256
|
+
Divider: {
|
|
257
|
+
description: "A line between two groups: horizontal, or vertical with axis \"vertical\" in a Row.",
|
|
258
|
+
props: dividerSchema
|
|
259
|
+
},
|
|
260
|
+
Tabs: {
|
|
261
|
+
description: "Tabs that show one panel at a time. Each tab has a title and the id of its panel component: \"tabs\":[{\"title\":\"Specs\",\"child\":\"specs\"}].",
|
|
262
|
+
props: tabsSchema,
|
|
263
|
+
writable: ["selectedIndex"]
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
//#endregion
|
|
268
|
+
export { CAROUSEL_MEDIA_SIZES, CHILDREN_SLOT, NO_ARGS, VISIBLE_EVENT, boxSchema, cardSchema, carouselMediaItemSchema, carouselSchema, dividerSchema, flowItemSchema, flowSchema, gridItemSchema, gridSchema, layoutDeclarations, layoutProps, radiusValue, sizeValue, spacerSchema, tabsSchema, weightProp };
|
|
269
|
+
//# sourceMappingURL=layout.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.mjs","names":[],"sources":["../../../src/generative-ui/standard/layout.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { child } from \"../catalog/refs\";\nimport { ALIGN, BORDER_COLORS, JUSTIFY, RADII, WRAP } from \"./tokens\";\n\n/** A number is a count of 4px steps. A string is raw CSS. */\nexport const sizeValue = z.union([z.number(), z.string()]);\n\n/** The A2UI `weight`: how much of the free space of a Row or Column to take. */\nexport const weightProp = z\n .number()\n .optional()\n .describe(\"flex-grow in a Row or Column\");\n\nexport const radiusValue = z.union([\n z.enum(RADII),\n z.number(),\n z.string(),\n z.object({\n topLeft: z.string().optional(),\n topRight: z.string().optional(),\n bottomLeft: z.string().optional(),\n bottomRight: z.string().optional(),\n }),\n]);\n\n/**\n * The layout props of every container. Spread them into a props schema:\n * `z.object({ ...layoutProps, variant: ... })`. The children of a container\n * are a slot, not a prop.\n */\nexport const layoutProps = {\n align: z.enum(ALIGN).optional(),\n justify: z.enum(JUSTIFY).optional(),\n wrap: z.enum(WRAP).optional(),\n gap: sizeValue.optional().describe(\"4px steps when a number\"),\n rowGap: sizeValue.optional(),\n columnGap: sizeValue.optional(),\n padding: sizeValue.optional().describe(\"4px steps when a number\"),\n background: z\n .string()\n .optional()\n .describe(\n 'Leave it unset. A surface token such as surface, surface-secondary, info, success, warning, danger, discovery, or one with -solid, or a CSS color. Only one summary panel in a Card uses \"surface-secondary\"',\n ),\n border: z.boolean().optional(),\n borderColor: z.enum(BORDER_COLORS).optional(),\n radius: radiusValue.optional(),\n width: sizeValue.optional(),\n height: sizeValue.optional(),\n minWidth: sizeValue.optional(),\n maxWidth: sizeValue.optional(),\n minHeight: sizeValue.optional(),\n maxHeight: sizeValue.optional(),\n flex: z.number().optional(),\n weight: weightProp,\n aspectRatio: z.string().optional(),\n scrollable: z.boolean().optional(),\n clip: z.boolean().optional(),\n shadow: z.boolean().optional(),\n inline: z.boolean().optional(),\n role: z.string().optional().describe(\"ARIA role\"),\n flush: z.boolean().optional().describe(\"No padding\"),\n minSize: sizeValue.optional().describe(\"Minimum width and height\"),\n maxSize: sizeValue.optional().describe(\"Maximum width and height\"),\n disableAutoSpacing: z\n .boolean()\n .optional()\n .describe(\"No default gap between children\"),\n};\n\nconst layoutSchema = z.object(layoutProps);\n\n/** The arguments of a click or visibility event: none. */\nexport const NO_ARGS = z.object({});\n\n/**\n * The `onVisible` event of every container: sent once, the first time the\n * container scrolls into view.\n */\nexport const VISIBLE_EVENT = {\n onVisible: {\n description:\n \"Sent once, the first time the container scrolls into view. Use it to load more content lazily.\",\n parameters: NO_ARGS,\n },\n} as const;\n\nexport type LayoutProps = z.output<typeof layoutSchema>;\n\n/** The slot of every container: a list of children or a template. */\nexport const CHILDREN_SLOT = { children: \"multiple\" } as const;\n\nexport const boxSchema = z.object({\n ...layoutProps,\n direction: z.enum([\"col\", \"row\"]).optional().describe('Default \"col\"'),\n});\nexport const gridSchema = z.object({\n ...layoutProps,\n columns: z\n .union([z.number(), z.string()])\n .optional()\n .describe(\"Column count or CSS template. Default 2\"),\n minChildWidth: sizeValue.optional(),\n rows: z.union([z.number(), z.string()]).optional(),\n});\nexport const gridItemSchema = z.object({\n ...layoutProps,\n span: z.number().optional(),\n rowSpan: z.number().optional(),\n});\nexport const cardSchema = z.object({\n ...layoutProps,\n variant: z\n .enum([\"default\", \"outline\", \"section\", \"soft\", \"elevated\", \"transparent\"])\n .optional(),\n shadowStyle: z\n .enum([\"none\", \"sm\", \"md\"])\n .optional()\n .describe(\"Overrides the shadow of the variant\"),\n size: z\n .enum([\"sm\", \"md\", \"lg\"])\n .optional()\n .describe('The padding preset: 8, 16 or 24px. Default \"md\"'),\n});\nexport const flowSchema = z.object({\n ...layoutProps,\n columns: z.number().optional(),\n rows: z.number().optional(),\n layout: z.enum([\"pack\", \"fixed\"]).optional().describe('Default \"pack\"'),\n});\nexport const flowItemSchema = z.object({\n ...layoutProps,\n span: z.number().optional(),\n rowSpan: z.number().optional(),\n aspectRatio: z.string().optional().describe('Default \"1 / 1\"'),\n aspectMode: z.enum([\"soft\", \"fixed\"]).optional(),\n});\nexport const carouselSchema = z.object({\n ...layoutProps,\n label: z\n .string()\n .optional()\n .describe(\"A short name of the carousel for screen readers\"),\n visibleItems: z.number().optional(),\n showArrows: z.boolean().optional().describe(\"Default true\"),\n activeIndex: z\n .number()\n .optional()\n .describe(\n 'The index of the slide in view. Bind it with { \"@path\": \"/x\" } to read or set it',\n ),\n previousLabel: z.string().optional().describe('Default \"Previous\"'),\n nextLabel: z.string().optional().describe('Default \"Next\"'),\n snap: z.enum([\"none\", \"proximity\", \"mandatory\"]).optional(),\n snapAlign: z.enum([\"start\", \"center\", \"end\"]).optional(),\n});\nexport const CAROUSEL_MEDIA_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nexport const carouselMediaItemSchema = z.object({\n ...layoutProps,\n url: z.string().describe(\"Image URL\"),\n description: z\n .string()\n .optional()\n .describe(\"What the image shows, for screen readers\"),\n size: z\n .enum(CAROUSEL_MEDIA_SIZES)\n .optional()\n .describe('The width: \"sm\" 160px, \"md\" 240px, \"lg\" 320px. Default \"md\"'),\n aspectRatio: z.string().optional().describe('Default \"4 / 3\"'),\n href: z.string().optional().describe(\"Opens this URL in a new tab\"),\n lightbox: z\n .boolean()\n .optional()\n .describe(\"Default true: a click opens all slides full-screen\"),\n});\nexport const spacerSchema = z.object({ minSize: sizeValue.optional() });\nexport const tabsSchema = z.object({\n tabs: z\n .array(\n z.object({\n title: z.string().describe(\"The tab title\"),\n child: child(\"The id of the panel component\"),\n }),\n )\n .describe(\"One entry per tab\"),\n selectedIndex: z\n .number()\n .optional()\n .describe(\n 'The open tab. Default 0. Bind it with { \"@path\": \"/x\" } to read it',\n ),\n weight: weightProp,\n});\nexport const dividerSchema = z.object({\n axis: z\n .enum([\"horizontal\", \"vertical\"])\n .optional()\n .describe('Default \"horizontal\"'),\n weight: weightProp,\n color: z.enum(BORDER_COLORS).optional(),\n size: z.number().optional(),\n spacing: sizeValue.optional(),\n flush: z.boolean().optional(),\n});\n\n/**\n * The standard layout components, without their framework components:\n * containers, Spacer and Divider. Every container has a \"multiple\"\n * `children` slot, so it takes a list of child ids or a template\n * `{ componentId, path }`.\n */\nexport const layoutDeclarations = {\n Box: {\n description:\n 'A flex container. It stacks its children in a column (direction \"row\" puts them in a row). Use it to group children with gap, padding, border, radius or background.',\n props: boxSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Column: {\n description:\n \"A vertical flex container. Its default gap already separates sections, so do not add padding, background or a Spacer for space.\",\n props: layoutSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Row: {\n description:\n 'A horizontal flex container. Label and value pair: justify \"spaceBetween\", a Caption left and a Text with fontWeight \"medium\" right. Buttons go in a Row at the bottom of a Card: one variant \"primary\", the others default or \"borderless\".',\n props: layoutSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Grid: {\n description:\n \"A CSS grid container. On a narrow screen, its columns collapse towards one column.\",\n props: gridSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n GridItem: {\n description:\n \"A cell of a Grid, with an optional span. A span that covers all rendered columns fills the row.\",\n props: gridItemSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Card: {\n description:\n 'A bordered panel, only for an interactive panel (controls, a form, a configurator); tables, charts and text need none. Give it a Title and a Caption. Separate groups with a Divider or the gap, never a nested Card or bordered Box. Variant \"section\": no box; \"outline\": always a box. In markdown mode, without controls it renders as \"section\" unless variant or border is set.',\n props: cardSchema,\n events: VISIBLE_EVENT,\n slots: { child: \"single\", children: \"multiple\" } as const,\n },\n Flow: {\n description:\n \"A masonry-like grid that packs cells of different sizes. Put FlowItem children in it.\",\n props: flowSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n FlowItem: {\n description: \"A cell of a Flow, with an optional span.\",\n props: flowItemSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n Carousel: {\n description:\n \"A horizontally scrolling row that snaps to its CarouselItem or CarouselMediaItem children, with arrows. Bind activeIndex to read or set the slide in view.\",\n props: carouselSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n writable: [\"activeIndex\"] as const,\n },\n CarouselItem: {\n description: \"A slide of a Carousel.\",\n props: layoutSchema,\n events: VISIBLE_EVENT,\n slots: CHILDREN_SLOT,\n },\n CarouselMediaItem: {\n description:\n 'A Carousel slide: an image with its children (a Caption, a Text) under it. size \"sm\" 160px, \"md\" 240px (default), \"lg\" 320px wide. A click opens all slides full-screen, unless href or onClick is set.',\n props: carouselMediaItemSchema,\n events: {\n ...VISIBLE_EVENT,\n onClick: {\n description:\n \"Sent when the user clicks the image. It replaces the full-screen view.\",\n parameters: NO_ARGS,\n },\n },\n slots: CHILDREN_SLOT,\n },\n Spacer: {\n description:\n \"Flexible empty space. You almost never need it: use the default gap.\",\n props: spacerSchema,\n },\n Divider: {\n description:\n 'A line between two groups: horizontal, or vertical with axis \"vertical\" in a Row.',\n props: dividerSchema,\n },\n Tabs: {\n description:\n 'Tabs that show one panel at a time. Each tab has a title and the id of its panel component: \"tabs\":[{\"title\":\"Specs\",\"child\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ACP,QAAQ;EACR,OAAO;EACR;CACD,MAAM;EACJ,aACE;EACF,OAAO;EACP,QAAQ;EACR,OAAO;GAAE,OAAO;GAAU,UAAU;GAAY;EACjD;CACD,MAAM;EACJ,aACE;EACF,OAAO;EACP,QAAQ;EACR,OAAO;EACR;CACD,UAAU;EACR,aAAa;EACb,OAAO;EACP,QAAQ;EACR,OAAO;EACR;CACD,UAAU;EACR,aACE;EACF,OAAO;EACP,QAAQ;EACR,OAAO;EACP,UAAU,CAAC,cAAc;EAC1B;CACD,cAAc;EACZ,aAAa;EACb,OAAO;EACP,QAAQ;EACR,OAAO;EACR;CACD,mBAAmB;EACjB,aACE;EACF,OAAO;EACP,QAAQ;GACN,GAAG;GACH,SAAS;IACP,aACE;IACF,YAAY;IACb;GACF;EACD,OAAO;EACR;CACD,QAAQ;EACN,aACE;EACF,OAAO;EACR;CACD,SAAS;EACP,aACE;EACF,OAAO;EACR;CACD,MAAM;EACJ,aACE;EACF,OAAO;EACP,UAAU,CAAC,gBAAgB;EAC5B;CACF"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/generative-ui/standard/map-helpers.ts
|
|
3
|
+
/**
|
|
4
|
+
* The default basemap: the Positron style of OpenFreeMap. It is a keyless
|
|
5
|
+
* OpenStreetMap vector style with streets and labels at city zoom. A host
|
|
6
|
+
* sets another style with `theme: { mapStyle: "<style url>" }`, and a
|
|
7
|
+
* dark one with `theme: { dark: { mapStyle: "<style url>" } }`.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_MAP_STYLE = "https://tiles.openfreemap.org/styles/positron";
|
|
10
|
+
/** The default basemap in dark mode: the Dark style of OpenFreeMap. */
|
|
11
|
+
const DEFAULT_DARK_MAP_STYLE = "https://tiles.openfreemap.org/styles/dark";
|
|
12
|
+
const ORDERING_OPS = new Set([
|
|
13
|
+
"<",
|
|
14
|
+
"<=",
|
|
15
|
+
">",
|
|
16
|
+
">="
|
|
17
|
+
]);
|
|
18
|
+
/**
|
|
19
|
+
* A filter expression with every numeric comparison of a feature property
|
|
20
|
+
* guarded by `["has", property]`.
|
|
21
|
+
*
|
|
22
|
+
* MapLibre adds a number assertion to `["get", key]` in a comparison with a
|
|
23
|
+
* number. The assertion logs a warning for each feature without the
|
|
24
|
+
* property. OpenFreeMap styles compare `ref_length` on roads that mostly do
|
|
25
|
+
* not have it. The comparison is false for a missing property in both
|
|
26
|
+
* cases, so the guard changes no result.
|
|
27
|
+
*
|
|
28
|
+
* @param filter - A MapLibre filter expression, at any depth.
|
|
29
|
+
*/
|
|
30
|
+
function guardNumericFilter(filter) {
|
|
31
|
+
if (!Array.isArray(filter)) return filter;
|
|
32
|
+
const [op, left, right] = filter;
|
|
33
|
+
if (typeof op === "string" && ORDERING_OPS.has(op) && Array.isArray(left) && left[0] === "get" && typeof left[1] === "string" && typeof right === "number") return [
|
|
34
|
+
"all",
|
|
35
|
+
["has", left[1]],
|
|
36
|
+
filter
|
|
37
|
+
];
|
|
38
|
+
return filter.map((part) => guardNumericFilter(part));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The style with `guardNumericFilter` applied to the filter of each layer.
|
|
42
|
+
* Pass it as the `transformStyle` of MapLibre's `setStyle`.
|
|
43
|
+
*
|
|
44
|
+
* @param style - A MapLibre style object.
|
|
45
|
+
*/
|
|
46
|
+
function guardStyleFilters(style) {
|
|
47
|
+
const layers = style.layers;
|
|
48
|
+
if (layers === void 0) return style;
|
|
49
|
+
const guarded = layers.map((layer) => "filter" in layer ? {
|
|
50
|
+
...layer,
|
|
51
|
+
filter: guardNumericFilter(layer.filter)
|
|
52
|
+
} : layer);
|
|
53
|
+
return {
|
|
54
|
+
...style,
|
|
55
|
+
layers: guarded
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** The id of the map stylesheet (`MAP_CSS`) in the document. */
|
|
59
|
+
const MAP_STYLE_ID = "a2ui-standard-map";
|
|
60
|
+
/** The source and layer id of the route line between the markers. */
|
|
61
|
+
const ROUTE_SOURCE = "a2ui-route";
|
|
62
|
+
/**
|
|
63
|
+
* The few maplibre-gl rules that markers and popups need, so a host does not
|
|
64
|
+
* have to import maplibre-gl.css. The list of places is hidden while the map
|
|
65
|
+
* shows. It shows when a keyboard user moves focus into it.
|
|
66
|
+
*/
|
|
67
|
+
const MAP_CSS = [
|
|
68
|
+
".maplibregl-map{position:relative;overflow:hidden}",
|
|
69
|
+
".maplibregl-canvas{position:absolute;left:0;top:0}",
|
|
70
|
+
".maplibregl-canvas-container{width:100%;height:100%}",
|
|
71
|
+
".maplibregl-marker{position:absolute;top:0;left:0;will-change:transform;cursor:pointer}",
|
|
72
|
+
".maplibregl-popup{position:absolute;top:0;left:0;display:flex;will-change:transform;pointer-events:none}",
|
|
73
|
+
".maplibregl-popup-content{position:relative;background:var(--a2ui-color-surface-elevated, #fff);color:var(--a2ui-color-text-default, #0d0d0d);border-radius:6px;padding:6px 10px;font:12px/1.4 system-ui,sans-serif;box-shadow:var(--a2ui-shadow-sm, 0 1px 4px rgba(0,0,0,.2));pointer-events:auto}",
|
|
74
|
+
".maplibregl-popup-tip{display:none}",
|
|
75
|
+
".maplibregl-popup-close-button{display:none}",
|
|
76
|
+
".maplibregl-ctrl-attrib{font:10px system-ui,sans-serif;position:absolute;right:0;bottom:0;background:color-mix(in srgb, var(--a2ui-color-surface, #fff) 70%, transparent);color:var(--a2ui-color-text-secondary, #5d5d5d);padding:0 4px}",
|
|
77
|
+
".maplibregl-ctrl-attrib a{color:inherit}",
|
|
78
|
+
".maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font:14px/1.3 system-ui,sans-serif;inset:0;justify-content:center;opacity:0;padding:1rem;pointer-events:none;position:absolute;text-align:center;transition:opacity 1s ease 1s;z-index:2}",
|
|
79
|
+
".maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}",
|
|
80
|
+
".maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}",
|
|
81
|
+
"@media (hover:none){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}",
|
|
82
|
+
".a2ui-std-map-places[data-collapsed]:not(:focus-within){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}"
|
|
83
|
+
].join("\n");
|
|
84
|
+
/**
|
|
85
|
+
* True when `value` looks like the maplibre-gl module: it has a `Map`
|
|
86
|
+
* constructor. Use it on the module that a map loader resolves.
|
|
87
|
+
*/
|
|
88
|
+
function isMapLibre(value) {
|
|
89
|
+
return typeof value === "object" && value !== null && "Map" in value && typeof value.Map === "function";
|
|
90
|
+
}
|
|
91
|
+
/** True when the marker has finite coordinates, so the map can place it. */
|
|
92
|
+
const isValidMarker = (marker) => Number.isFinite(marker.lat) && Number.isFinite(marker.lng);
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
exports.DEFAULT_DARK_MAP_STYLE = DEFAULT_DARK_MAP_STYLE;
|
|
96
|
+
exports.DEFAULT_MAP_STYLE = DEFAULT_MAP_STYLE;
|
|
97
|
+
exports.MAP_CSS = MAP_CSS;
|
|
98
|
+
exports.MAP_STYLE_ID = MAP_STYLE_ID;
|
|
99
|
+
exports.ROUTE_SOURCE = ROUTE_SOURCE;
|
|
100
|
+
exports.guardNumericFilter = guardNumericFilter;
|
|
101
|
+
exports.guardStyleFilters = guardStyleFilters;
|
|
102
|
+
exports.isMapLibre = isMapLibre;
|
|
103
|
+
exports.isValidMarker = isValidMarker;
|
|
104
|
+
//# sourceMappingURL=map-helpers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-helpers.cjs","names":[],"sources":["../../../src/generative-ui/standard/map-helpers.ts"],"sourcesContent":["// Framework-free map helpers of the standard Map component. The maplibre-gl\n// parts are typed structurally, so maplibre-gl stays an optional peer of\n// each framework package.\nimport type { MapMarker } from \"./map\";\n\n/**\n * The default basemap: the Positron style of OpenFreeMap. It is a keyless\n * OpenStreetMap vector style with streets and labels at city zoom. A host\n * sets another style with `theme: { mapStyle: \"<style url>\" }`, and a\n * dark one with `theme: { dark: { mapStyle: \"<style url>\" } }`.\n */\nexport const DEFAULT_MAP_STYLE =\n \"https://tiles.openfreemap.org/styles/positron\";\n\n/** The default basemap in dark mode: the Dark style of OpenFreeMap. */\nexport const DEFAULT_DARK_MAP_STYLE =\n \"https://tiles.openfreemap.org/styles/dark\";\n\nconst ORDERING_OPS = new Set([\"<\", \"<=\", \">\", \">=\"]);\n\n// guardNumericFilter keeps its return type: the function calls itself, so\n// TypeScript cannot infer it.\n/**\n * A filter expression with every numeric comparison of a feature property\n * guarded by `[\"has\", property]`.\n *\n * MapLibre adds a number assertion to `[\"get\", key]` in a comparison with a\n * number. The assertion logs a warning for each feature without the\n * property. OpenFreeMap styles compare `ref_length` on roads that mostly do\n * not have it. The comparison is false for a missing property in both\n * cases, so the guard changes no result.\n *\n * @param filter - A MapLibre filter expression, at any depth.\n */\nexport function guardNumericFilter(filter: unknown): unknown {\n if (!Array.isArray(filter)) return filter;\n const [op, left, right] = filter;\n const isPropertyComparison =\n typeof op === \"string\" &&\n ORDERING_OPS.has(op) &&\n Array.isArray(left) &&\n left[0] === \"get\" &&\n typeof left[1] === \"string\" &&\n typeof right === \"number\";\n if (isPropertyComparison) return [\"all\", [\"has\", left[1]], filter];\n return filter.map((part) => guardNumericFilter(part));\n}\n\n/**\n * The style with `guardNumericFilter` applied to the filter of each layer.\n * Pass it as the `transformStyle` of MapLibre's `setStyle`.\n *\n * @param style - A MapLibre style object.\n */\nexport function guardStyleFilters<Style extends { layers?: readonly object[] }>(\n style: Style,\n) {\n const layers = style.layers;\n if (layers === undefined) return style;\n const guarded = layers.map((layer) =>\n \"filter\" in layer\n ? { ...layer, filter: guardNumericFilter(layer.filter) }\n : layer,\n );\n // The guard only wraps a comparison in [\"all\", [\"has\", key], comparison],\n // which is a valid filter, so each layer keeps its type.\n return { ...style, layers: guarded } as Style;\n}\n\n/** The id of the map stylesheet (`MAP_CSS`) in the document. */\nexport const MAP_STYLE_ID = \"a2ui-standard-map\";\n\n/** The source and layer id of the route line between the markers. */\nexport const ROUTE_SOURCE = \"a2ui-route\";\n\n/**\n * The few maplibre-gl rules that markers and popups need, so a host does not\n * have to import maplibre-gl.css. The list of places is hidden while the map\n * shows. It shows when a keyboard user moves focus into it.\n */\nexport const MAP_CSS = [\n \".maplibregl-map{position:relative;overflow:hidden}\",\n \".maplibregl-canvas{position:absolute;left:0;top:0}\",\n \".maplibregl-canvas-container{width:100%;height:100%}\",\n \".maplibregl-marker{position:absolute;top:0;left:0;will-change:transform;cursor:pointer}\",\n \".maplibregl-popup{position:absolute;top:0;left:0;display:flex;will-change:transform;pointer-events:none}\",\n \".maplibregl-popup-content{position:relative;background:var(--a2ui-color-surface-elevated, #fff);color:var(--a2ui-color-text-default, #0d0d0d);border-radius:6px;padding:6px 10px;font:12px/1.4 system-ui,sans-serif;box-shadow:var(--a2ui-shadow-sm, 0 1px 4px rgba(0,0,0,.2));pointer-events:auto}\",\n \".maplibregl-popup-tip{display:none}\",\n \".maplibregl-popup-close-button{display:none}\",\n \".maplibregl-ctrl-attrib{font:10px system-ui,sans-serif;position:absolute;right:0;bottom:0;background:color-mix(in srgb, var(--a2ui-color-surface, #fff) 70%, transparent);color:var(--a2ui-color-text-secondary, #5d5d5d);padding:0 4px}\",\n \".maplibregl-ctrl-attrib a{color:inherit}\",\n // The cooperative-gesture hint is hidden until MapLibre adds `maplibregl-show`.\n \".maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font:14px/1.3 system-ui,sans-serif;inset:0;justify-content:center;opacity:0;padding:1rem;pointer-events:none;position:absolute;text-align:center;transition:opacity 1s ease 1s;z-index:2}\",\n \".maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}\",\n \".maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}\",\n \"@media (hover:none){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}\",\n \".a2ui-std-map-places[data-collapsed]:not(:focus-within){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}\",\n].join(\"\\n\");\n\n/** The part of a maplibre-gl `Map` that the standard Map component uses. */\nexport interface MapLibreMap {\n setStyle(\n style: string,\n options: {\n transformStyle: (\n previous: unknown,\n next: { layers?: readonly object[] },\n ) => unknown;\n },\n ): void;\n on(\n event: string,\n handler: (event: { originalEvent?: unknown }) => void,\n ): void;\n fitBounds(bounds: unknown, options: Record<string, unknown>): void;\n getSource(id: string): unknown;\n addSource(id: string, source: Record<string, unknown>): void;\n addLayer(layer: Record<string, unknown>): void;\n remove(): void;\n}\n\n/** The part of a maplibre-gl `Marker` that the standard Map component uses. */\nexport interface MapLibreMarker {\n setLngLat(position: [number, number]): MapLibreMarker;\n setPopup(popup: unknown): MapLibreMarker;\n addTo(map: MapLibreMap): MapLibreMarker;\n getElement(): HTMLElement;\n}\n\n/** The part of the maplibre-gl module that the standard Map component uses. */\nexport interface MapLibre {\n Map: new (options: Record<string, unknown>) => MapLibreMap;\n Marker: new () => MapLibreMarker;\n Popup: new (options: Record<string, unknown>) => {\n setText(text: string): unknown;\n };\n LngLatBounds: new () => { extend(position: [number, number]): void };\n}\n\n/**\n * True when `value` looks like the maplibre-gl module: it has a `Map`\n * constructor. Use it on the module that a map loader resolves.\n */\nexport function isMapLibre(value: unknown): value is MapLibre {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"Map\" in value &&\n typeof value.Map === \"function\"\n );\n}\n\n/** True when the marker has finite coordinates, so the map can place it. */\nexport const isValidMarker = (marker: MapMarker) =>\n Number.isFinite(marker.lat) && Number.isFinite(marker.lng);\n"],"mappings":";;;;;;;;AAWA,MAAa,oBACX;;AAGF,MAAa,yBACX;AAEF,MAAM,eAAe,IAAI,IAAI;CAAC;CAAK;CAAM;CAAK;CAAK,CAAC;;;;;;;;;;;;;AAgBpD,SAAgB,mBAAmB,QAA0B;AAC3D,KAAI,CAAC,MAAM,QAAQ,OAAO,CAAE,QAAO;CACnC,MAAM,CAAC,IAAI,MAAM,SAAS;AAQ1B,KANE,OAAO,OAAO,YACd,aAAa,IAAI,GAAG,IACpB,MAAM,QAAQ,KAAK,IACnB,KAAK,OAAO,SACZ,OAAO,KAAK,OAAO,YACnB,OAAO,UAAU,SACO,QAAO;EAAC;EAAO,CAAC,OAAO,KAAK,GAAG;EAAE;EAAO;AAClE,QAAO,OAAO,KAAK,SAAS,mBAAmB,KAAK,CAAC;;;;;;;;AASvD,SAAgB,kBACd,OACA;CACA,MAAM,SAAS,MAAM;AACrB,KAAI,WAAW,OAAW,QAAO;CACjC,MAAM,UAAU,OAAO,KAAK,UAC1B,YAAY,QACR;EAAE,GAAG;EAAO,QAAQ,mBAAmB,MAAM,OAAO;EAAE,GACtD,MACL;AAGD,QAAO;EAAE,GAAG;EAAO,QAAQ;EAAS;;;AAItC,MAAa,eAAe;;AAG5B,MAAa,eAAe;;;;;;AAO5B,MAAa,UAAU;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACD,CAAC,KAAK,KAAK;;;;;AA8CZ,SAAgB,WAAW,OAAmC;AAC5D,QACE,OAAO,UAAU,YACjB,UAAU,QACV,SAAS,SACT,OAAO,MAAM,QAAQ;;;AAKzB,MAAa,iBAAiB,WAC5B,OAAO,SAAS,OAAO,IAAI,IAAI,OAAO,SAAS,OAAO,IAAI"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { MapMarker } from "./map.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/generative-ui/standard/map-helpers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The default basemap: the Positron style of OpenFreeMap. It is a keyless
|
|
6
|
+
* OpenStreetMap vector style with streets and labels at city zoom. A host
|
|
7
|
+
* sets another style with `theme: { mapStyle: "<style url>" }`, and a
|
|
8
|
+
* dark one with `theme: { dark: { mapStyle: "<style url>" } }`.
|
|
9
|
+
*/
|
|
10
|
+
declare const DEFAULT_MAP_STYLE = "https://tiles.openfreemap.org/styles/positron";
|
|
11
|
+
/** The default basemap in dark mode: the Dark style of OpenFreeMap. */
|
|
12
|
+
declare const DEFAULT_DARK_MAP_STYLE = "https://tiles.openfreemap.org/styles/dark";
|
|
13
|
+
/**
|
|
14
|
+
* A filter expression with every numeric comparison of a feature property
|
|
15
|
+
* guarded by `["has", property]`.
|
|
16
|
+
*
|
|
17
|
+
* MapLibre adds a number assertion to `["get", key]` in a comparison with a
|
|
18
|
+
* number. The assertion logs a warning for each feature without the
|
|
19
|
+
* property. OpenFreeMap styles compare `ref_length` on roads that mostly do
|
|
20
|
+
* not have it. The comparison is false for a missing property in both
|
|
21
|
+
* cases, so the guard changes no result.
|
|
22
|
+
*
|
|
23
|
+
* @param filter - A MapLibre filter expression, at any depth.
|
|
24
|
+
*/
|
|
25
|
+
declare function guardNumericFilter(filter: unknown): unknown;
|
|
26
|
+
/**
|
|
27
|
+
* The style with `guardNumericFilter` applied to the filter of each layer.
|
|
28
|
+
* Pass it as the `transformStyle` of MapLibre's `setStyle`.
|
|
29
|
+
*
|
|
30
|
+
* @param style - A MapLibre style object.
|
|
31
|
+
*/
|
|
32
|
+
declare function guardStyleFilters<Style extends {
|
|
33
|
+
layers?: readonly object[];
|
|
34
|
+
}>(style: Style): Style;
|
|
35
|
+
/** The id of the map stylesheet (`MAP_CSS`) in the document. */
|
|
36
|
+
declare const MAP_STYLE_ID = "a2ui-standard-map";
|
|
37
|
+
/** The source and layer id of the route line between the markers. */
|
|
38
|
+
declare const ROUTE_SOURCE = "a2ui-route";
|
|
39
|
+
/**
|
|
40
|
+
* The few maplibre-gl rules that markers and popups need, so a host does not
|
|
41
|
+
* have to import maplibre-gl.css. The list of places is hidden while the map
|
|
42
|
+
* shows. It shows when a keyboard user moves focus into it.
|
|
43
|
+
*/
|
|
44
|
+
declare const MAP_CSS: string;
|
|
45
|
+
/** The part of a maplibre-gl `Map` that the standard Map component uses. */
|
|
46
|
+
interface MapLibreMap {
|
|
47
|
+
setStyle(style: string, options: {
|
|
48
|
+
transformStyle: (previous: unknown, next: {
|
|
49
|
+
layers?: readonly object[];
|
|
50
|
+
}) => unknown;
|
|
51
|
+
}): void;
|
|
52
|
+
on(event: string, handler: (event: {
|
|
53
|
+
originalEvent?: unknown;
|
|
54
|
+
}) => void): void;
|
|
55
|
+
fitBounds(bounds: unknown, options: Record<string, unknown>): void;
|
|
56
|
+
getSource(id: string): unknown;
|
|
57
|
+
addSource(id: string, source: Record<string, unknown>): void;
|
|
58
|
+
addLayer(layer: Record<string, unknown>): void;
|
|
59
|
+
remove(): void;
|
|
60
|
+
}
|
|
61
|
+
/** The part of a maplibre-gl `Marker` that the standard Map component uses. */
|
|
62
|
+
interface MapLibreMarker {
|
|
63
|
+
setLngLat(position: [number, number]): MapLibreMarker;
|
|
64
|
+
setPopup(popup: unknown): MapLibreMarker;
|
|
65
|
+
addTo(map: MapLibreMap): MapLibreMarker;
|
|
66
|
+
getElement(): HTMLElement;
|
|
67
|
+
}
|
|
68
|
+
/** The part of the maplibre-gl module that the standard Map component uses. */
|
|
69
|
+
interface MapLibre {
|
|
70
|
+
Map: new (options: Record<string, unknown>) => MapLibreMap;
|
|
71
|
+
Marker: new () => MapLibreMarker;
|
|
72
|
+
Popup: new (options: Record<string, unknown>) => {
|
|
73
|
+
setText(text: string): unknown;
|
|
74
|
+
};
|
|
75
|
+
LngLatBounds: new () => {
|
|
76
|
+
extend(position: [number, number]): void;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* True when `value` looks like the maplibre-gl module: it has a `Map`
|
|
81
|
+
* constructor. Use it on the module that a map loader resolves.
|
|
82
|
+
*/
|
|
83
|
+
declare function isMapLibre(value: unknown): value is MapLibre;
|
|
84
|
+
/** True when the marker has finite coordinates, so the map can place it. */
|
|
85
|
+
declare const isValidMarker: (marker: MapMarker) => boolean;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { DEFAULT_DARK_MAP_STYLE, DEFAULT_MAP_STYLE, MAP_CSS, MAP_STYLE_ID, MapLibre, MapLibreMap, MapLibreMarker, ROUTE_SOURCE, guardNumericFilter, guardStyleFilters, isMapLibre, isValidMarker };
|
|
88
|
+
//# sourceMappingURL=map-helpers.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-helpers.d.cts","names":[],"sources":["../../../src/generative-ui/standard/map-helpers.ts"],"mappings":";;;;;AAWA;;;;cAAa,iBAAA;AAIb;AAAA,cAAa,sBAAA;;;;AAmBb;;;;;AAoBA;;;;iBApBgB,kBAAA,CAAmB,MAAA;;;;;;;iBAoBnB,iBAAA;EAAkC,MAAA;AAAA,EAAA,CAChD,KAAA,EAAO,KAAA,GAAK,KAAA;;cAeD,YAAA;AAGb;AAAA,cAAa,YAAA;;;;AAOb;;cAAa,OAAA;;UAoBI,WAAA;EACf,QAAA,CACE,KAAA,UACA,OAAA;IACE,cAAA,GACE,QAAA,WACA,IAAA;MAAQ,MAAA;IAAA;EAAA;EAId,EAAA,CACE,KAAA,UACA,OAAA,GAAU,KAAA;IAAS,aAAA;EAAA;EAErB,SAAA,CAAU,MAAA,WAAiB,OAAA,EAAS,MAAA;EACpC,SAAA,CAAU,EAAA;EACV,SAAA,CAAU,EAAA,UAAY,MAAA,EAAQ,MAAA;EAC9B,QAAA,CAAS,KAAA,EAAO,MAAA;EAChB,MAAA;AAAA;;UAIe,cAAA;EACf,SAAA,CAAU,QAAA,qBAA6B,cAAA;EACvC,QAAA,CAAS,KAAA,YAAiB,cAAA;EAC1B,KAAA,CAAM,GAAA,EAAK,WAAA,GAAc,cAAA;EACzB,UAAA,IAAc,WAAA;AAAA;;UAIC,QAAA;EACf,GAAA,OAAU,OAAA,EAAS,MAAA,sBAA4B,WAAA;EAC/C,MAAA,YAAkB,cAAA;EAClB,KAAA,OAAY,OAAA,EAAS,MAAA;IACnB,OAAA,CAAQ,IAAA;EAAA;EAEV,YAAA;IAA0B,MAAA,CAAO,QAAA;EAAA;AAAA;;;;;iBAOnB,UAAA,CAAW,KAAA,YAAiB,KAAA,IAAS,QAAA;;cAUxC,aAAA,GAAiB,MAAA,EAAQ,SAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { MapMarker } from "./map.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/generative-ui/standard/map-helpers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The default basemap: the Positron style of OpenFreeMap. It is a keyless
|
|
6
|
+
* OpenStreetMap vector style with streets and labels at city zoom. A host
|
|
7
|
+
* sets another style with `theme: { mapStyle: "<style url>" }`, and a
|
|
8
|
+
* dark one with `theme: { dark: { mapStyle: "<style url>" } }`.
|
|
9
|
+
*/
|
|
10
|
+
declare const DEFAULT_MAP_STYLE = "https://tiles.openfreemap.org/styles/positron";
|
|
11
|
+
/** The default basemap in dark mode: the Dark style of OpenFreeMap. */
|
|
12
|
+
declare const DEFAULT_DARK_MAP_STYLE = "https://tiles.openfreemap.org/styles/dark";
|
|
13
|
+
/**
|
|
14
|
+
* A filter expression with every numeric comparison of a feature property
|
|
15
|
+
* guarded by `["has", property]`.
|
|
16
|
+
*
|
|
17
|
+
* MapLibre adds a number assertion to `["get", key]` in a comparison with a
|
|
18
|
+
* number. The assertion logs a warning for each feature without the
|
|
19
|
+
* property. OpenFreeMap styles compare `ref_length` on roads that mostly do
|
|
20
|
+
* not have it. The comparison is false for a missing property in both
|
|
21
|
+
* cases, so the guard changes no result.
|
|
22
|
+
*
|
|
23
|
+
* @param filter - A MapLibre filter expression, at any depth.
|
|
24
|
+
*/
|
|
25
|
+
declare function guardNumericFilter(filter: unknown): unknown;
|
|
26
|
+
/**
|
|
27
|
+
* The style with `guardNumericFilter` applied to the filter of each layer.
|
|
28
|
+
* Pass it as the `transformStyle` of MapLibre's `setStyle`.
|
|
29
|
+
*
|
|
30
|
+
* @param style - A MapLibre style object.
|
|
31
|
+
*/
|
|
32
|
+
declare function guardStyleFilters<Style extends {
|
|
33
|
+
layers?: readonly object[];
|
|
34
|
+
}>(style: Style): Style;
|
|
35
|
+
/** The id of the map stylesheet (`MAP_CSS`) in the document. */
|
|
36
|
+
declare const MAP_STYLE_ID = "a2ui-standard-map";
|
|
37
|
+
/** The source and layer id of the route line between the markers. */
|
|
38
|
+
declare const ROUTE_SOURCE = "a2ui-route";
|
|
39
|
+
/**
|
|
40
|
+
* The few maplibre-gl rules that markers and popups need, so a host does not
|
|
41
|
+
* have to import maplibre-gl.css. The list of places is hidden while the map
|
|
42
|
+
* shows. It shows when a keyboard user moves focus into it.
|
|
43
|
+
*/
|
|
44
|
+
declare const MAP_CSS: string;
|
|
45
|
+
/** The part of a maplibre-gl `Map` that the standard Map component uses. */
|
|
46
|
+
interface MapLibreMap {
|
|
47
|
+
setStyle(style: string, options: {
|
|
48
|
+
transformStyle: (previous: unknown, next: {
|
|
49
|
+
layers?: readonly object[];
|
|
50
|
+
}) => unknown;
|
|
51
|
+
}): void;
|
|
52
|
+
on(event: string, handler: (event: {
|
|
53
|
+
originalEvent?: unknown;
|
|
54
|
+
}) => void): void;
|
|
55
|
+
fitBounds(bounds: unknown, options: Record<string, unknown>): void;
|
|
56
|
+
getSource(id: string): unknown;
|
|
57
|
+
addSource(id: string, source: Record<string, unknown>): void;
|
|
58
|
+
addLayer(layer: Record<string, unknown>): void;
|
|
59
|
+
remove(): void;
|
|
60
|
+
}
|
|
61
|
+
/** The part of a maplibre-gl `Marker` that the standard Map component uses. */
|
|
62
|
+
interface MapLibreMarker {
|
|
63
|
+
setLngLat(position: [number, number]): MapLibreMarker;
|
|
64
|
+
setPopup(popup: unknown): MapLibreMarker;
|
|
65
|
+
addTo(map: MapLibreMap): MapLibreMarker;
|
|
66
|
+
getElement(): HTMLElement;
|
|
67
|
+
}
|
|
68
|
+
/** The part of the maplibre-gl module that the standard Map component uses. */
|
|
69
|
+
interface MapLibre {
|
|
70
|
+
Map: new (options: Record<string, unknown>) => MapLibreMap;
|
|
71
|
+
Marker: new () => MapLibreMarker;
|
|
72
|
+
Popup: new (options: Record<string, unknown>) => {
|
|
73
|
+
setText(text: string): unknown;
|
|
74
|
+
};
|
|
75
|
+
LngLatBounds: new () => {
|
|
76
|
+
extend(position: [number, number]): void;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* True when `value` looks like the maplibre-gl module: it has a `Map`
|
|
81
|
+
* constructor. Use it on the module that a map loader resolves.
|
|
82
|
+
*/
|
|
83
|
+
declare function isMapLibre(value: unknown): value is MapLibre;
|
|
84
|
+
/** True when the marker has finite coordinates, so the map can place it. */
|
|
85
|
+
declare const isValidMarker: (marker: MapMarker) => boolean;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { DEFAULT_DARK_MAP_STYLE, DEFAULT_MAP_STYLE, MAP_CSS, MAP_STYLE_ID, MapLibre, MapLibreMap, MapLibreMarker, ROUTE_SOURCE, guardNumericFilter, guardStyleFilters, isMapLibre, isValidMarker };
|
|
88
|
+
//# sourceMappingURL=map-helpers.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-helpers.d.mts","names":[],"sources":["../../../src/generative-ui/standard/map-helpers.ts"],"mappings":";;;;;AAWA;;;;cAAa,iBAAA;AAIb;AAAA,cAAa,sBAAA;;;;AAmBb;;;;;AAoBA;;;;iBApBgB,kBAAA,CAAmB,MAAA;;;;;;;iBAoBnB,iBAAA;EAAkC,MAAA;AAAA,EAAA,CAChD,KAAA,EAAO,KAAA,GAAK,KAAA;;cAeD,YAAA;AAGb;AAAA,cAAa,YAAA;;;;AAOb;;cAAa,OAAA;;UAoBI,WAAA;EACf,QAAA,CACE,KAAA,UACA,OAAA;IACE,cAAA,GACE,QAAA,WACA,IAAA;MAAQ,MAAA;IAAA;EAAA;EAId,EAAA,CACE,KAAA,UACA,OAAA,GAAU,KAAA;IAAS,aAAA;EAAA;EAErB,SAAA,CAAU,MAAA,WAAiB,OAAA,EAAS,MAAA;EACpC,SAAA,CAAU,EAAA;EACV,SAAA,CAAU,EAAA,UAAY,MAAA,EAAQ,MAAA;EAC9B,QAAA,CAAS,KAAA,EAAO,MAAA;EAChB,MAAA;AAAA;;UAIe,cAAA;EACf,SAAA,CAAU,QAAA,qBAA6B,cAAA;EACvC,QAAA,CAAS,KAAA,YAAiB,cAAA;EAC1B,KAAA,CAAM,GAAA,EAAK,WAAA,GAAc,cAAA;EACzB,UAAA,IAAc,WAAA;AAAA;;UAIC,QAAA;EACf,GAAA,OAAU,OAAA,EAAS,MAAA,sBAA4B,WAAA;EAC/C,MAAA,YAAkB,cAAA;EAClB,KAAA,OAAY,OAAA,EAAS,MAAA;IACnB,OAAA,CAAQ,IAAA;EAAA;EAEV,YAAA;IAA0B,MAAA,CAAO,QAAA;EAAA;AAAA;;;;;iBAOnB,UAAA,CAAW,KAAA,YAAiB,KAAA,IAAS,QAAA;;cAUxC,aAAA,GAAiB,MAAA,EAAQ,SAAA"}
|