@lushly-dev/fast-element 3.0.1-preview.0 → 3.0.1-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/command/command.api.json +7857 -0
- package/dist/context/context.api.json +1084 -0
- package/dist/declarative/declarative.api.json +8130 -0
- package/dist/definition-schema/definition-schema.api.json +2689 -0
- package/dist/di/di.api.json +4945 -0
- package/dist/dts/arrays.d.ts +2 -0
- package/dist/dts/binding/binding.d.ts +59 -0
- package/dist/dts/binding/exports.d.ts +9 -0
- package/dist/dts/binding/normalize.d.ts +9 -0
- package/dist/dts/binding/one-time.d.ts +11 -0
- package/dist/dts/binding/one-way.d.ts +20 -0
- package/dist/dts/binding/signal.d.ts +36 -0
- package/dist/dts/binding/two-way.d.ts +44 -0
- package/dist/dts/command/behavior.d.ts +94 -0
- package/dist/dts/command/behaviors/confirm-behavior.d.ts +139 -0
- package/dist/dts/command/behaviors/undo-behavior.d.ts +178 -0
- package/dist/dts/command/command.d.ts +79 -0
- package/dist/dts/command/component-registry.d.ts +50 -0
- package/dist/dts/command/components/confirm-dialog.d.ts +117 -0
- package/dist/dts/command/index.d.ts +21 -0
- package/dist/dts/command/registry.d.ts +201 -0
- package/dist/dts/command/schema-validation.d.ts +45 -0
- package/dist/dts/command/types.d.ts +332 -0
- package/dist/dts/command/validation.d.ts +116 -0
- package/dist/dts/command/weak-ref.d.ts +11 -0
- package/dist/dts/components/attributes.d.ts +153 -0
- package/dist/dts/components/definition-schema-transforms.d.ts +9 -0
- package/dist/dts/components/element-controller.d.ts +349 -0
- package/dist/dts/components/element-hydration.d.ts +2 -0
- package/dist/dts/components/enable-hydration.d.ts +66 -0
- package/dist/dts/components/fast-definitions.d.ts +211 -0
- package/dist/dts/components/fast-element-registry.d.ts +23 -0
- package/dist/dts/components/fast-element.d.ts +91 -0
- package/dist/dts/components/hydration-tracker.d.ts +110 -0
- package/dist/dts/components/hydration.d.ts +52 -0
- package/dist/dts/components/schema.d.ts +205 -0
- package/dist/dts/context.d.ts +171 -0
- package/dist/dts/debug.d.ts +5 -0
- package/dist/dts/declarative/attribute-map.d.ts +58 -0
- package/dist/dts/declarative/debug.d.ts +4 -0
- package/dist/dts/declarative/index.d.ts +14 -0
- package/dist/dts/declarative/interfaces.d.ts +8 -0
- package/dist/dts/declarative/observer-map-utilities.d.ts +58 -0
- package/dist/dts/declarative/observer-map.d.ts +89 -0
- package/dist/dts/declarative/runtime.d.ts +5 -0
- package/dist/dts/declarative/syntax.d.ts +21 -0
- package/dist/dts/declarative/template-bridge.d.ts +33 -0
- package/dist/dts/declarative/template-parser.d.ts +98 -0
- package/dist/dts/declarative/template.d.ts +9 -0
- package/dist/dts/declarative/utilities.d.ts +358 -0
- package/dist/dts/definition-schema/api.d.ts +42 -0
- package/dist/dts/definition-schema/cem.d.ts +78 -0
- package/dist/dts/definition-schema/extension.d.ts +18 -0
- package/dist/dts/definition-schema/extract.d.ts +38 -0
- package/dist/dts/definition-schema/index.d.ts +9 -0
- package/dist/dts/definition-schema/storage.d.ts +35 -0
- package/dist/dts/definition-schema/types.d.ts +176 -0
- package/dist/dts/dev-mode.d.ts +13 -0
- package/dist/dts/di/di.d.ts +894 -0
- package/dist/dts/dom-policy.d.ts +101 -0
- package/dist/dts/dom.d.ts +88 -0
- package/dist/dts/hydration/diagnostics.d.ts +93 -0
- package/dist/dts/hydration/exports.d.ts +18 -0
- package/dist/dts/hydration/hydration-debugger.d.ts +35 -0
- package/dist/dts/hydration/messages.d.ts +62 -0
- package/dist/dts/hydration/runtime.d.ts +7 -0
- package/dist/dts/hydration/target-builder.d.ts +107 -0
- package/dist/dts/index.d.ts +51 -0
- package/dist/dts/index.debug.d.ts +1 -0
- package/dist/dts/index.rollup.d.ts +1 -0
- package/dist/dts/index.rollup.debug.d.ts +1 -0
- package/dist/dts/interfaces.d.ts +106 -0
- package/dist/dts/metadata.d.ts +26 -0
- package/dist/dts/observation/arrays.d.ts +248 -0
- package/dist/dts/observation/notifier.d.ts +127 -0
- package/dist/dts/observation/observable.d.ts +276 -0
- package/dist/dts/observation/update-queue.d.ts +40 -0
- package/dist/dts/observation/volatile.d.ts +9 -0
- package/dist/dts/platform.d.ts +87 -0
- package/dist/dts/registry.d.ts +2 -0
- package/dist/dts/render.d.ts +7 -0
- package/dist/dts/schema.d.ts +1 -0
- package/dist/dts/scoped/detection.d.ts +55 -0
- package/dist/dts/scoped/index.d.ts +68 -0
- package/dist/dts/scoped/mixin.d.ts +118 -0
- package/dist/dts/scoped/registry.d.ts +76 -0
- package/dist/dts/scoped/types.d.ts +48 -0
- package/dist/dts/state/exports.d.ts +3 -0
- package/dist/dts/state/reactive.d.ts +8 -0
- package/dist/dts/state/state.d.ts +141 -0
- package/dist/dts/state/visitor.d.ts +6 -0
- package/dist/dts/state/watch.d.ts +10 -0
- package/dist/dts/styles/css-directive.d.ts +50 -0
- package/dist/dts/styles/css.d.ts +34 -0
- package/dist/dts/styles/element-styles.d.ts +61 -0
- package/dist/dts/styles/host.d.ts +65 -0
- package/dist/dts/styles/style-strategy.d.ts +42 -0
- package/dist/dts/templating/children.d.ts +62 -0
- package/dist/dts/templating/compiler.d.ts +54 -0
- package/dist/dts/templating/html-binding-directive.d.ts +155 -0
- package/dist/dts/templating/html-directive.d.ts +218 -0
- package/dist/dts/templating/html.d.ts +1 -0
- package/dist/dts/templating/hydration-view.d.ts +130 -0
- package/dist/dts/templating/markup.d.ts +48 -0
- package/dist/dts/templating/node-observation.d.ts +99 -0
- package/dist/dts/templating/ref.d.ts +23 -0
- package/dist/dts/templating/render.d.ts +318 -0
- package/dist/dts/templating/repeat.d.ts +131 -0
- package/dist/dts/templating/slotted.d.ts +38 -0
- package/dist/dts/templating/template.d.ts +221 -0
- package/dist/dts/templating/view.d.ts +268 -0
- package/dist/dts/templating/when.d.ts +12 -0
- package/dist/dts/testing/exports.d.ts +3 -0
- package/dist/dts/testing/fakes.d.ts +16 -0
- package/dist/dts/testing/fixture.d.ts +84 -0
- package/dist/dts/testing/models.d.ts +20 -0
- package/dist/dts/testing/timeout.d.ts +7 -0
- package/dist/dts/trust/index.d.ts +8 -0
- package/dist/dts/trust/types.d.ts +48 -0
- package/dist/dts/trust/utils.d.ts +26 -0
- package/dist/dts/tsdoc-metadata.json +11 -0
- package/dist/dts/utilities.d.ts +76 -0
- package/dist/esm/arrays.js +1 -0
- package/dist/esm/binding/binding.js +18 -0
- package/dist/esm/binding/exports.js +6 -0
- package/dist/esm/binding/normalize.js +17 -0
- package/dist/esm/binding/one-time.js +21 -0
- package/dist/esm/binding/one-way.js +30 -0
- package/dist/esm/binding/signal.js +99 -0
- package/dist/esm/binding/two-way.js +109 -0
- package/dist/esm/command/behavior.js +155 -0
- package/dist/esm/command/behaviors/confirm-behavior.js +225 -0
- package/dist/esm/command/behaviors/undo-behavior.js +313 -0
- package/dist/esm/command/command.js +104 -0
- package/dist/esm/command/component-registry.js +107 -0
- package/dist/esm/command/components/confirm-dialog.js +370 -0
- package/dist/esm/command/index.js +22 -0
- package/dist/esm/command/registry.js +755 -0
- package/dist/esm/command/schema-validation.js +194 -0
- package/dist/esm/command/types.js +86 -0
- package/dist/esm/command/validation.js +508 -0
- package/dist/esm/command/weak-ref.js +5 -0
- package/dist/esm/components/attributes.js +219 -0
- package/dist/esm/components/definition-schema-transforms.js +23 -0
- package/dist/esm/components/element-controller.js +840 -0
- package/dist/esm/components/element-hydration.js +2 -0
- package/dist/esm/components/enable-hydration.js +123 -0
- package/dist/esm/components/fast-definitions.js +294 -0
- package/dist/esm/components/fast-element-registry.js +67 -0
- package/dist/esm/components/fast-element.js +82 -0
- package/dist/esm/components/hydration-tracker.js +211 -0
- package/dist/esm/components/hydration.js +187 -0
- package/dist/esm/components/schema.js +253 -0
- package/dist/esm/context.js +185 -0
- package/dist/esm/debug.js +71 -0
- package/dist/esm/declarative/attribute-map.js +122 -0
- package/dist/esm/declarative/debug.js +4 -0
- package/dist/esm/declarative/index.js +10 -0
- package/dist/esm/declarative/interfaces.js +9 -0
- package/dist/esm/declarative/observer-map-utilities.js +565 -0
- package/dist/esm/declarative/observer-map.js +216 -0
- package/dist/esm/declarative/runtime.js +14 -0
- package/dist/esm/declarative/syntax.js +36 -0
- package/dist/esm/declarative/template-bridge.js +160 -0
- package/dist/esm/declarative/template-parser.js +306 -0
- package/dist/esm/declarative/template.js +116 -0
- package/dist/esm/declarative/utilities.js +1069 -0
- package/dist/esm/definition-schema/api.js +129 -0
- package/dist/esm/definition-schema/cem.js +89 -0
- package/dist/esm/definition-schema/extension.js +53 -0
- package/dist/esm/definition-schema/extract.js +167 -0
- package/dist/esm/definition-schema/index.js +8 -0
- package/dist/esm/definition-schema/storage.js +58 -0
- package/dist/esm/definition-schema/types.js +8 -0
- package/dist/esm/dev-mode.js +22 -0
- package/dist/esm/di/di.js +1441 -0
- package/dist/esm/dom-policy.js +374 -0
- package/dist/esm/dom.js +101 -0
- package/dist/esm/hydration/diagnostics.js +50 -0
- package/dist/esm/hydration/exports.js +6 -0
- package/dist/esm/hydration/hydration-debugger.js +112 -0
- package/dist/esm/hydration/messages.js +84 -0
- package/dist/esm/hydration/runtime.js +33 -0
- package/dist/esm/hydration/target-builder.js +264 -0
- package/dist/esm/index.debug.js +3 -0
- package/dist/esm/index.js +49 -0
- package/dist/esm/index.rollup.debug.js +6 -0
- package/dist/esm/index.rollup.js +4 -0
- package/dist/esm/interfaces.js +55 -0
- package/dist/esm/metadata.js +57 -0
- package/dist/esm/observation/arrays.js +661 -0
- package/dist/esm/observation/notifier.js +162 -0
- package/dist/esm/observation/observable.js +324 -0
- package/dist/esm/observation/update-queue.js +56 -0
- package/dist/esm/observation/volatile.js +16 -0
- package/dist/esm/platform.js +98 -0
- package/dist/esm/registry.js +2 -0
- package/dist/esm/render.js +1 -0
- package/dist/esm/schema.js +1 -0
- package/dist/esm/scoped/detection.js +102 -0
- package/dist/esm/scoped/index.js +69 -0
- package/dist/esm/scoped/mixin.js +127 -0
- package/dist/esm/scoped/registry.js +125 -0
- package/dist/esm/scoped/types.js +4 -0
- package/dist/esm/state/exports.js +3 -0
- package/dist/esm/state/reactive.js +34 -0
- package/dist/esm/state/state.js +148 -0
- package/dist/esm/state/visitor.js +28 -0
- package/dist/esm/state/watch.js +36 -0
- package/dist/esm/styles/css-directive.js +36 -0
- package/dist/esm/styles/css.js +56 -0
- package/dist/esm/styles/element-styles.js +144 -0
- package/dist/esm/styles/host.js +1 -0
- package/dist/esm/styles/style-strategy.js +1 -0
- package/dist/esm/templating/children.js +67 -0
- package/dist/esm/templating/compiler.js +359 -0
- package/dist/esm/templating/html-binding-directive.js +288 -0
- package/dist/esm/templating/html-directive.js +113 -0
- package/dist/esm/templating/html.js +1 -0
- package/dist/esm/templating/hydration-view.js +228 -0
- package/dist/esm/templating/markup.js +83 -0
- package/dist/esm/templating/node-observation.js +84 -0
- package/dist/esm/templating/ref.js +21 -0
- package/dist/esm/templating/render.js +468 -0
- package/dist/esm/templating/repeat.js +434 -0
- package/dist/esm/templating/slotted.js +49 -0
- package/dist/esm/templating/template.js +206 -0
- package/dist/esm/templating/view.js +298 -0
- package/dist/esm/templating/when.js +22 -0
- package/dist/esm/testing/exports.js +3 -0
- package/dist/esm/testing/fakes.js +107 -0
- package/dist/esm/testing/fixture.js +86 -0
- package/dist/esm/testing/models.js +58 -0
- package/dist/esm/testing/timeout.js +24 -0
- package/dist/esm/trust/index.js +7 -0
- package/dist/esm/trust/types.js +6 -0
- package/dist/esm/trust/utils.js +126 -0
- package/dist/esm/utilities.js +140 -0
- package/dist/fast-element.api.json +26798 -0
- package/dist/fast-element.d.ts +3985 -0
- package/dist/fast-element.debug.js +7604 -0
- package/dist/fast-element.debug.min.js +3 -0
- package/dist/fast-element.js +7603 -0
- package/dist/fast-element.min.js +3 -0
- package/dist/fast-element.untrimmed.d.ts +4103 -0
- package/dist/observation/arrays/arrays.api.json +2621 -0
- package/dist/scoped/scoped.api.json +891 -0
- package/dist/trust/trust.api.json +629 -0
- package/package.json +21 -23
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component introspection commands for FAST elements.
|
|
3
|
+
* Pure runtime introspection - no Creator dependencies.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* These commands expose FAST component metadata to AI agents and command palettes.
|
|
7
|
+
* Task 9 will add fast.component.getAPI to this file.
|
|
8
|
+
*/
|
|
9
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
10
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
13
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
14
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
15
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
import { CommandRegistry } from "./registry.js";
|
|
19
|
+
import { success, failure } from "./types.js";
|
|
20
|
+
import { createWeakReference } from "./weak-ref.js";
|
|
21
|
+
import { getAllSchemas, getSchema } from "../definition-schema/api.js";
|
|
22
|
+
/**
|
|
23
|
+
* Register fast.component.* commands with the CommandRegistry.
|
|
24
|
+
* Called during fast-element initialization.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* These commands provide runtime introspection of registered FAST elements.
|
|
28
|
+
* They have no dependencies on Creator or design-to-code packages.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export function registerComponentCommands() {
|
|
33
|
+
// fast.component.list
|
|
34
|
+
CommandRegistry.register("fast.component.list", {
|
|
35
|
+
id: "fast.component.list",
|
|
36
|
+
label: "List all registered FAST components",
|
|
37
|
+
description: "Returns a list of all FAST elements registered with FASTElementDefinition, " +
|
|
38
|
+
"including their tag names and constructor information.",
|
|
39
|
+
category: "FAST",
|
|
40
|
+
execute: () => __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
if (typeof customElements === "undefined") {
|
|
42
|
+
return success([]);
|
|
43
|
+
}
|
|
44
|
+
const components = Array.from(getAllSchemas(), ([name]) => {
|
|
45
|
+
var _a;
|
|
46
|
+
const elementClass = customElements.get(name);
|
|
47
|
+
return {
|
|
48
|
+
name,
|
|
49
|
+
constructor: (_a = elementClass === null || elementClass === void 0 ? void 0 : elementClass.name) !== null && _a !== void 0 ? _a : "Unknown",
|
|
50
|
+
isDefined: elementClass !== void 0,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
return success(components);
|
|
54
|
+
}),
|
|
55
|
+
canExecute: true,
|
|
56
|
+
when: true,
|
|
57
|
+
expose: { palette: true, agent: true, mcp: true, cli: true },
|
|
58
|
+
source: typeof document !== "undefined"
|
|
59
|
+
? createWeakReference(document.body)
|
|
60
|
+
: createWeakReference({}),
|
|
61
|
+
});
|
|
62
|
+
// fast.component.getAPI
|
|
63
|
+
CommandRegistry.register("fast.component.getAPI", {
|
|
64
|
+
id: "fast.component.getAPI",
|
|
65
|
+
label: "Get component API schema",
|
|
66
|
+
description: "Returns the full API schema for a FAST component including properties, events, slots, " +
|
|
67
|
+
"and CSS custom properties. Data is extracted directly from ElementDefinition.",
|
|
68
|
+
category: "FAST",
|
|
69
|
+
execute: (args) => __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const { name } = args !== null && args !== void 0 ? args : {};
|
|
71
|
+
if (!name) {
|
|
72
|
+
return failure({
|
|
73
|
+
code: "INVALID_PARAMETERS",
|
|
74
|
+
message: "Component name is required",
|
|
75
|
+
suggestion: "Provide a valid custom element tag name (e.g., 'fast-button')",
|
|
76
|
+
retryable: false,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Try to get the schema for this component
|
|
80
|
+
const schema = getSchema(name);
|
|
81
|
+
if (!schema) {
|
|
82
|
+
return failure({
|
|
83
|
+
code: "NOT_FOUND",
|
|
84
|
+
message: `Component '${name}' not found in registry`,
|
|
85
|
+
suggestion: "Ensure the component is registered and defined. Use fast.component.list to see available components.",
|
|
86
|
+
retryable: false,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const apiInfo = {
|
|
90
|
+
name: schema.name,
|
|
91
|
+
properties: schema.properties,
|
|
92
|
+
events: schema.events,
|
|
93
|
+
slots: schema.slots,
|
|
94
|
+
cssProperties: schema.cssProperties,
|
|
95
|
+
commands: schema.commands,
|
|
96
|
+
};
|
|
97
|
+
// confidence: 1.0 because data comes directly from ElementDefinition source
|
|
98
|
+
return success(apiInfo, { confidence: 1.0 });
|
|
99
|
+
}),
|
|
100
|
+
canExecute: true,
|
|
101
|
+
when: true,
|
|
102
|
+
expose: { palette: true, agent: true, mcp: true, cli: true },
|
|
103
|
+
source: typeof document !== "undefined"
|
|
104
|
+
? createWeakReference(document.body)
|
|
105
|
+
: createWeakReference({}),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConfirmDialog component for command safety confirmations.
|
|
3
|
+
* Modal dialog for confirming destructive actions.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Provides an accessible modal dialog with:
|
|
7
|
+
* - open/prompt attributes for state management
|
|
8
|
+
* - confirm/cancel events for user response
|
|
9
|
+
* - Full ARIA support (role, aria-modal, aria-labelledby, aria-describedby)
|
|
10
|
+
* - Focus trap to keep keyboard navigation within dialog
|
|
11
|
+
* - Escape key to cancel
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```html
|
|
15
|
+
* <fast-af-confirm-dialog
|
|
16
|
+
* open
|
|
17
|
+
* prompt="Are you sure you want to delete this item?"
|
|
18
|
+
* @confirm=${handleConfirm}
|
|
19
|
+
* @cancel=${handleCancel}
|
|
20
|
+
* ></fast-af-confirm-dialog>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
24
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
26
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
27
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
28
|
+
};
|
|
29
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
30
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
31
|
+
};
|
|
32
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
33
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
34
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
35
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
36
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
37
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
38
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
import { FASTElementDefinition } from "../../components/fast-definitions.js";
|
|
42
|
+
import { FASTElement } from "../../components/fast-element.js";
|
|
43
|
+
import { attr } from "../../components/attributes.js";
|
|
44
|
+
import { html } from "../../templating/template.js";
|
|
45
|
+
import { css } from "../../styles/css.js";
|
|
46
|
+
import { when } from "../../templating/when.js";
|
|
47
|
+
/**
|
|
48
|
+
* Styles for the confirm dialog component.
|
|
49
|
+
* Uses CSS custom properties for theming.
|
|
50
|
+
*/
|
|
51
|
+
const styles = css `
|
|
52
|
+
:host {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
:host([open]) {
|
|
57
|
+
display: block;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.overlay {
|
|
61
|
+
position: fixed;
|
|
62
|
+
inset: 0;
|
|
63
|
+
background: rgba(0, 0, 0, 0.5);
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
z-index: var(--confirm-dialog-z-index, 1000);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.dialog {
|
|
71
|
+
background: var(--confirm-dialog-background, #fff);
|
|
72
|
+
border-radius: var(--confirm-dialog-border-radius, 8px);
|
|
73
|
+
box-shadow: var(--confirm-dialog-shadow, 0 4px 24px rgba(0, 0, 0, 0.2));
|
|
74
|
+
max-width: var(--confirm-dialog-max-width, 400px);
|
|
75
|
+
width: 90%;
|
|
76
|
+
padding: var(--confirm-dialog-padding, 24px);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.title {
|
|
80
|
+
font-size: var(--confirm-dialog-title-size, 1.25rem);
|
|
81
|
+
font-weight: var(--confirm-dialog-title-weight, 600);
|
|
82
|
+
margin: 0 0 16px;
|
|
83
|
+
color: var(--confirm-dialog-title-color, inherit);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.prompt {
|
|
87
|
+
margin: 0 0 24px;
|
|
88
|
+
color: var(--confirm-dialog-prompt-color, inherit);
|
|
89
|
+
line-height: 1.5;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.actions {
|
|
93
|
+
display: flex;
|
|
94
|
+
justify-content: flex-end;
|
|
95
|
+
gap: 12px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
button {
|
|
99
|
+
padding: 8px 16px;
|
|
100
|
+
border-radius: 4px;
|
|
101
|
+
font-size: 0.875rem;
|
|
102
|
+
font-weight: 500;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
transition: background-color 0.2s, border-color 0.2s;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.cancel-button {
|
|
108
|
+
background: var(--confirm-dialog-cancel-bg, transparent);
|
|
109
|
+
border: 1px solid var(--confirm-dialog-cancel-border, #ccc);
|
|
110
|
+
color: var(--confirm-dialog-cancel-color, inherit);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.cancel-button:hover {
|
|
114
|
+
background: var(--confirm-dialog-cancel-hover-bg, #f5f5f5);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.cancel-button:focus-visible {
|
|
118
|
+
outline: 2px solid var(--confirm-dialog-focus-color, #0066cc);
|
|
119
|
+
outline-offset: 2px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.confirm-button {
|
|
123
|
+
background: var(--confirm-dialog-confirm-bg, #dc3545);
|
|
124
|
+
border: 1px solid var(--confirm-dialog-confirm-border, #dc3545);
|
|
125
|
+
color: var(--confirm-dialog-confirm-color, #fff);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.confirm-button:hover {
|
|
129
|
+
background: var(--confirm-dialog-confirm-hover-bg, #c82333);
|
|
130
|
+
border-color: var(--confirm-dialog-confirm-hover-border, #c82333);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.confirm-button:focus-visible {
|
|
134
|
+
outline: 2px solid var(--confirm-dialog-focus-color, #0066cc);
|
|
135
|
+
outline-offset: 2px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* Slot for custom content */
|
|
139
|
+
::slotted(*) {
|
|
140
|
+
margin-bottom: 16px;
|
|
141
|
+
}
|
|
142
|
+
`;
|
|
143
|
+
/**
|
|
144
|
+
* Template for the confirm dialog component.
|
|
145
|
+
*/
|
|
146
|
+
const template = html `
|
|
147
|
+
${when(x => x.open, html `
|
|
148
|
+
<div
|
|
149
|
+
class="overlay"
|
|
150
|
+
@click="${(x, c) => x.handleOverlayClick(c.event)}"
|
|
151
|
+
>
|
|
152
|
+
<div
|
|
153
|
+
class="dialog"
|
|
154
|
+
role="alertdialog"
|
|
155
|
+
aria-modal="true"
|
|
156
|
+
aria-labelledby="dialog-title"
|
|
157
|
+
aria-describedby="dialog-prompt"
|
|
158
|
+
@click="${(x, c) => c.event.stopPropagation()}"
|
|
159
|
+
@keydown="${(x, c) => x.handleKeydown(c.event)}"
|
|
160
|
+
>
|
|
161
|
+
<h2 id="dialog-title" class="title">
|
|
162
|
+
<slot name="title">Confirm Action</slot>
|
|
163
|
+
</h2>
|
|
164
|
+
<p id="dialog-prompt" class="prompt">${x => x.prompt}</p>
|
|
165
|
+
<slot></slot>
|
|
166
|
+
<div class="actions">
|
|
167
|
+
<button
|
|
168
|
+
type="button"
|
|
169
|
+
class="cancel-button"
|
|
170
|
+
@click="${x => x.handleCancel()}"
|
|
171
|
+
>
|
|
172
|
+
<slot name="cancel-text">Cancel</slot>
|
|
173
|
+
</button>
|
|
174
|
+
<button
|
|
175
|
+
type="button"
|
|
176
|
+
class="confirm-button"
|
|
177
|
+
@click="${x => x.handleConfirm()}"
|
|
178
|
+
>
|
|
179
|
+
<slot name="confirm-text">Confirm</slot>
|
|
180
|
+
</button>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
`)}
|
|
185
|
+
`;
|
|
186
|
+
/**
|
|
187
|
+
* A modal dialog component for confirming destructive actions.
|
|
188
|
+
*
|
|
189
|
+
* Events: `confirm` is dispatched when the user confirms; `cancel` is dispatched
|
|
190
|
+
* when the user cancels, presses Escape, or clicks the overlay.
|
|
191
|
+
*
|
|
192
|
+
* Slots: the default slot supplies additional content; `title`, `cancel-text`, and
|
|
193
|
+
* `confirm-text` replace their corresponding labels.
|
|
194
|
+
*
|
|
195
|
+
* CSS parts: `overlay`, `dialog`, `title`, `prompt`, `actions`, `cancel-button`, and
|
|
196
|
+
* `confirm-button`.
|
|
197
|
+
*
|
|
198
|
+
* @internal
|
|
199
|
+
*/
|
|
200
|
+
export class ConfirmDialog extends FASTElement {
|
|
201
|
+
constructor() {
|
|
202
|
+
super(...arguments);
|
|
203
|
+
/**
|
|
204
|
+
* Whether the dialog is open/visible.
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
this.open = false;
|
|
208
|
+
/**
|
|
209
|
+
* The prompt message to display in the dialog.
|
|
210
|
+
* @public
|
|
211
|
+
*/
|
|
212
|
+
this.prompt = "";
|
|
213
|
+
/**
|
|
214
|
+
* Reference to the previously focused element for restoring focus on close.
|
|
215
|
+
* @internal
|
|
216
|
+
*/
|
|
217
|
+
this.previouslyFocused = null;
|
|
218
|
+
/**
|
|
219
|
+
* List of focusable elements within the dialog for focus trapping.
|
|
220
|
+
* @internal
|
|
221
|
+
*/
|
|
222
|
+
this.focusableElements = [];
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Called when the open attribute changes.
|
|
226
|
+
* Manages focus trap and body scroll lock.
|
|
227
|
+
* @param oldValue - Previous value
|
|
228
|
+
* @param newValue - New value
|
|
229
|
+
*/
|
|
230
|
+
openChanged(oldValue, newValue) {
|
|
231
|
+
var _a;
|
|
232
|
+
if (newValue) {
|
|
233
|
+
this.previouslyFocused = document.activeElement;
|
|
234
|
+
// Defer focus to allow template to render
|
|
235
|
+
requestAnimationFrame(() => {
|
|
236
|
+
this.trapFocus();
|
|
237
|
+
});
|
|
238
|
+
document.body.style.overflow = "hidden";
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
document.body.style.overflow = "";
|
|
242
|
+
(_a = this.previouslyFocused) === null || _a === void 0 ? void 0 : _a.focus();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Sets up focus trap within the dialog.
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
249
|
+
trapFocus() {
|
|
250
|
+
var _a;
|
|
251
|
+
const dialog = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(".dialog");
|
|
252
|
+
if (!dialog)
|
|
253
|
+
return;
|
|
254
|
+
// Get all focusable elements
|
|
255
|
+
this.focusableElements = Array.from(dialog.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'));
|
|
256
|
+
// Focus the first button (cancel by default for safety)
|
|
257
|
+
const cancelButton = dialog.querySelector(".cancel-button");
|
|
258
|
+
cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.focus();
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Handles keydown events for focus trap and escape key.
|
|
262
|
+
* @param event - The keyboard event
|
|
263
|
+
* @internal
|
|
264
|
+
*/
|
|
265
|
+
handleKeydown(event) {
|
|
266
|
+
if (event.key === "Escape") {
|
|
267
|
+
this.handleCancel();
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (event.key === "Tab") {
|
|
271
|
+
this.handleTabKey(event);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Handles tab key for focus trapping.
|
|
276
|
+
* @param event - The keyboard event
|
|
277
|
+
* @internal
|
|
278
|
+
*/
|
|
279
|
+
handleTabKey(event) {
|
|
280
|
+
var _a;
|
|
281
|
+
const focusable = this.focusableElements;
|
|
282
|
+
if (focusable.length === 0)
|
|
283
|
+
return;
|
|
284
|
+
const firstElement = focusable[0];
|
|
285
|
+
const lastElement = focusable[focusable.length - 1];
|
|
286
|
+
const activeElement = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement;
|
|
287
|
+
if (event.shiftKey) {
|
|
288
|
+
// Shift+Tab: wrap to last element if on first
|
|
289
|
+
if (activeElement === firstElement) {
|
|
290
|
+
event.preventDefault();
|
|
291
|
+
lastElement.focus();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
// Tab: wrap to first element if on last
|
|
296
|
+
if (activeElement === lastElement) {
|
|
297
|
+
event.preventDefault();
|
|
298
|
+
firstElement.focus();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Handles overlay click to cancel.
|
|
304
|
+
* @param event - The mouse event
|
|
305
|
+
* @internal
|
|
306
|
+
*/
|
|
307
|
+
handleOverlayClick(event) {
|
|
308
|
+
// Only close if clicking the overlay itself, not the dialog
|
|
309
|
+
if (event.target.classList.contains("overlay")) {
|
|
310
|
+
this.handleCancel();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Handles confirm button click.
|
|
315
|
+
* Emits 'confirm' event and closes the dialog.
|
|
316
|
+
* @public
|
|
317
|
+
*/
|
|
318
|
+
handleConfirm() {
|
|
319
|
+
this.$emit("confirm");
|
|
320
|
+
this.open = false;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Handles cancel button click.
|
|
324
|
+
* Emits 'cancel' event and closes the dialog.
|
|
325
|
+
* @public
|
|
326
|
+
*/
|
|
327
|
+
handleCancel() {
|
|
328
|
+
this.$emit("cancel");
|
|
329
|
+
this.open = false;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
__decorate([
|
|
333
|
+
attr({ mode: "boolean" }),
|
|
334
|
+
__metadata("design:type", Object)
|
|
335
|
+
], ConfirmDialog.prototype, "open", void 0);
|
|
336
|
+
__decorate([
|
|
337
|
+
attr,
|
|
338
|
+
__metadata("design:type", Object)
|
|
339
|
+
], ConfirmDialog.prototype, "prompt", void 0);
|
|
340
|
+
/**
|
|
341
|
+
* The namespaced tag used by the opt-in confirmation dialog.
|
|
342
|
+
* @public
|
|
343
|
+
*/
|
|
344
|
+
export const confirmDialogTagName = "fast-af-confirm-dialog";
|
|
345
|
+
let definitionPromise;
|
|
346
|
+
/**
|
|
347
|
+
* Defines the confirmation dialog in the provided registry.
|
|
348
|
+
*
|
|
349
|
+
* @remarks
|
|
350
|
+
* Registration is explicit so importing the command API remains side-effect free.
|
|
351
|
+
* Repeated calls for the same registry are safe.
|
|
352
|
+
*
|
|
353
|
+
* @param registry - Registry in which to define the dialog.
|
|
354
|
+
* @public
|
|
355
|
+
*/
|
|
356
|
+
export function defineConfirmDialog() {
|
|
357
|
+
return __awaiter(this, arguments, void 0, function* (registry = customElements) {
|
|
358
|
+
if (registry.get(confirmDialogTagName) !== undefined) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
definitionPromise !== null && definitionPromise !== void 0 ? definitionPromise : (definitionPromise = FASTElementDefinition.compose(ConfirmDialog, {
|
|
362
|
+
name: confirmDialogTagName,
|
|
363
|
+
template,
|
|
364
|
+
styles,
|
|
365
|
+
}));
|
|
366
|
+
const definition = yield definitionPromise;
|
|
367
|
+
definition.define(registry);
|
|
368
|
+
yield registry.whenDefined(confirmDialogTagName);
|
|
369
|
+
});
|
|
370
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API for the `command` decorator system.
|
|
3
|
+
* Enables AI agents to interact with FASTElement components through structured commands.
|
|
4
|
+
*/
|
|
5
|
+
// Re-export helper functions and constants
|
|
6
|
+
export { ErrorCodes, success, failure, isSuccess, isFailure, createError, DEFAULT_EXPOSE_CONFIG, } from "./types.js";
|
|
7
|
+
// Re-export decorator and metadata helper
|
|
8
|
+
export { command, getCommandMetadata } from "./command.js";
|
|
9
|
+
// Re-export behavior for lifecycle management
|
|
10
|
+
export { CommandBehavior } from "./behavior.js";
|
|
11
|
+
// Re-export confirmation behavior
|
|
12
|
+
export { ConfirmBehavior, USER_CANCELLED } from "./behaviors/confirm-behavior.js";
|
|
13
|
+
// Re-export undo behavior
|
|
14
|
+
export { UndoBehavior } from "./behaviors/undo-behavior.js";
|
|
15
|
+
// Re-export registry singleton and types
|
|
16
|
+
export { CommandRegistry } from "./registry.js";
|
|
17
|
+
// Re-export opt-in command safety components
|
|
18
|
+
export { confirmDialogTagName, defineConfirmDialog, } from "./components/confirm-dialog.js";
|
|
19
|
+
// Re-export component introspection commands
|
|
20
|
+
export { registerComponentCommands } from "./component-registry.js";
|
|
21
|
+
// Re-export validation commands
|
|
22
|
+
export { registerValidationCommands } from "./validation.js";
|