@craft-ts/component 0.7.0-beta.13
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/LICENSE +21 -0
- package/package.json +36 -0
- package/src/index.d.ts +40 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +38 -0
- package/src/index.js.map +1 -0
- package/src/lib/a11y-control.d.ts +58 -0
- package/src/lib/a11y-control.d.ts.map +1 -0
- package/src/lib/a11y-control.js +74 -0
- package/src/lib/a11y-control.js.map +1 -0
- package/src/lib/a11y.d.ts +87 -0
- package/src/lib/a11y.d.ts.map +1 -0
- package/src/lib/a11y.js +96 -0
- package/src/lib/a11y.js.map +1 -0
- package/src/lib/ai/ai-context-menu.d.ts +140 -0
- package/src/lib/ai/ai-context-menu.d.ts.map +1 -0
- package/src/lib/ai/ai-context-menu.js +66 -0
- package/src/lib/ai/ai-context-menu.js.map +1 -0
- package/src/lib/ai/ai-send-dialog.d.ts +1263 -0
- package/src/lib/ai/ai-send-dialog.d.ts.map +1 -0
- package/src/lib/ai/ai-send-dialog.js +288 -0
- package/src/lib/ai/ai-send-dialog.js.map +1 -0
- package/src/lib/ai/send-context-to-ai.d.ts +29 -0
- package/src/lib/ai/send-context-to-ai.d.ts.map +1 -0
- package/src/lib/ai/send-context-to-ai.js +127 -0
- package/src/lib/ai/send-context-to-ai.js.map +1 -0
- package/src/lib/assert-defined-input.d.ts +26 -0
- package/src/lib/assert-defined-input.d.ts.map +1 -0
- package/src/lib/assert-defined-input.js +47 -0
- package/src/lib/assert-defined-input.js.map +1 -0
- package/src/lib/block.d.ts +36 -0
- package/src/lib/block.d.ts.map +1 -0
- package/src/lib/block.js +55 -0
- package/src/lib/block.js.map +1 -0
- package/src/lib/bootstrap.d.ts +32 -0
- package/src/lib/bootstrap.d.ts.map +1 -0
- package/src/lib/bootstrap.js +60 -0
- package/src/lib/bootstrap.js.map +1 -0
- package/src/lib/bridge.d.ts +56 -0
- package/src/lib/bridge.d.ts.map +1 -0
- package/src/lib/bridge.js +81 -0
- package/src/lib/bridge.js.map +1 -0
- package/src/lib/component.d.ts +46 -0
- package/src/lib/component.d.ts.map +1 -0
- package/src/lib/component.js +118 -0
- package/src/lib/component.js.map +1 -0
- package/src/lib/composition.d.ts +17 -0
- package/src/lib/composition.d.ts.map +1 -0
- package/src/lib/composition.js +28 -0
- package/src/lib/composition.js.map +1 -0
- package/src/lib/craft-defaults.d.ts +2 -0
- package/src/lib/craft-defaults.d.ts.map +1 -0
- package/src/lib/craft-defaults.js +41 -0
- package/src/lib/craft-defaults.js.map +1 -0
- package/src/lib/craft-host-tokens.d.ts +6 -0
- package/src/lib/craft-host-tokens.d.ts.map +1 -0
- package/src/lib/craft-host-tokens.js +7 -0
- package/src/lib/craft-host-tokens.js.map +1 -0
- package/src/lib/craft-router-outlet.d.ts +15 -0
- package/src/lib/craft-router-outlet.d.ts.map +1 -0
- package/src/lib/craft-router-outlet.js +10 -0
- package/src/lib/craft-router-outlet.js.map +1 -0
- package/src/lib/css-vars.d.ts +31 -0
- package/src/lib/css-vars.d.ts.map +1 -0
- package/src/lib/css-vars.js +43 -0
- package/src/lib/css-vars.js.map +1 -0
- package/src/lib/css-vars.type.d.ts +151 -0
- package/src/lib/css-vars.type.d.ts.map +1 -0
- package/src/lib/css-vars.type.js +1 -0
- package/src/lib/css-vars.type.js.map +1 -0
- package/src/lib/defer.d.ts +31 -0
- package/src/lib/defer.d.ts.map +1 -0
- package/src/lib/defer.js +19 -0
- package/src/lib/defer.js.map +1 -0
- package/src/lib/directive.d.ts +9 -0
- package/src/lib/directive.d.ts.map +1 -0
- package/src/lib/directive.js +31 -0
- package/src/lib/directive.js.map +1 -0
- package/src/lib/each-scheduling.d.ts +59 -0
- package/src/lib/each-scheduling.d.ts.map +1 -0
- package/src/lib/each-scheduling.js +120 -0
- package/src/lib/each-scheduling.js.map +1 -0
- package/src/lib/each.d.ts +29 -0
- package/src/lib/each.d.ts.map +1 -0
- package/src/lib/each.js +23 -0
- package/src/lib/each.js.map +1 -0
- package/src/lib/factory-runtime.d.ts +5 -0
- package/src/lib/factory-runtime.d.ts.map +1 -0
- package/src/lib/factory-runtime.js +26 -0
- package/src/lib/factory-runtime.js.map +1 -0
- package/src/lib/field-exception-block.d.ts +96 -0
- package/src/lib/field-exception-block.d.ts.map +1 -0
- package/src/lib/field-exception-block.js +44 -0
- package/src/lib/field-exception-block.js.map +1 -0
- package/src/lib/host-runtime.d.ts +60 -0
- package/src/lib/host-runtime.d.ts.map +1 -0
- package/src/lib/host-runtime.js +16 -0
- package/src/lib/host-runtime.js.map +1 -0
- package/src/lib/hydrate.d.ts +15 -0
- package/src/lib/hydrate.d.ts.map +1 -0
- package/src/lib/hydrate.js +79 -0
- package/src/lib/hydrate.js.map +1 -0
- package/src/lib/hyperscript.d.ts +148 -0
- package/src/lib/hyperscript.d.ts.map +1 -0
- package/src/lib/hyperscript.js +96 -0
- package/src/lib/hyperscript.js.map +1 -0
- package/src/lib/if-block.d.ts +8 -0
- package/src/lib/if-block.d.ts.map +1 -0
- package/src/lib/if-block.js +16 -0
- package/src/lib/if-block.js.map +1 -0
- package/src/lib/locator.d.ts +170 -0
- package/src/lib/locator.d.ts.map +1 -0
- package/src/lib/locator.js +151 -0
- package/src/lib/locator.js.map +1 -0
- package/src/lib/match-block.d.ts +38 -0
- package/src/lib/match-block.d.ts.map +1 -0
- package/src/lib/match-block.js +29 -0
- package/src/lib/match-block.js.map +1 -0
- package/src/lib/pending-block.d.ts +125 -0
- package/src/lib/pending-block.d.ts.map +1 -0
- package/src/lib/pending-block.js +48 -0
- package/src/lib/pending-block.js.map +1 -0
- package/src/lib/project.d.ts +19 -0
- package/src/lib/project.d.ts.map +1 -0
- package/src/lib/project.js +56 -0
- package/src/lib/project.js.map +1 -0
- package/src/lib/render/hydration-metadata.d.ts +3 -0
- package/src/lib/render/hydration-metadata.d.ts.map +1 -0
- package/src/lib/render/hydration-metadata.js +8 -0
- package/src/lib/render/hydration-metadata.js.map +1 -0
- package/src/lib/render/hydration.d.ts +24 -0
- package/src/lib/render/hydration.d.ts.map +1 -0
- package/src/lib/render/hydration.js +181 -0
- package/src/lib/render/hydration.js.map +1 -0
- package/src/lib/render/interpreter.d.ts +32 -0
- package/src/lib/render/interpreter.d.ts.map +1 -0
- package/src/lib/render/interpreter.js +3588 -0
- package/src/lib/render/interpreter.js.map +1 -0
- package/src/lib/render/server-style-collector.d.ts +6 -0
- package/src/lib/render/server-style-collector.d.ts.map +1 -0
- package/src/lib/render/server-style-collector.js +23 -0
- package/src/lib/render/server-style-collector.js.map +1 -0
- package/src/lib/render/ssr-coordinator.d.ts +20 -0
- package/src/lib/render/ssr-coordinator.d.ts.map +1 -0
- package/src/lib/render/ssr-coordinator.js +99 -0
- package/src/lib/render/ssr-coordinator.js.map +1 -0
- package/src/lib/render/string-dom.d.ts +9 -0
- package/src/lib/render/string-dom.d.ts.map +1 -0
- package/src/lib/render/string-dom.js +377 -0
- package/src/lib/render/string-dom.js.map +1 -0
- package/src/lib/render/style-registry.d.ts +14 -0
- package/src/lib/render/style-registry.d.ts.map +1 -0
- package/src/lib/render/style-registry.js +79 -0
- package/src/lib/render/style-registry.js.map +1 -0
- package/src/lib/render/style-scope.d.ts +30 -0
- package/src/lib/render/style-scope.d.ts.map +1 -0
- package/src/lib/render/style-scope.js +261 -0
- package/src/lib/render/style-scope.js.map +1 -0
- package/src/lib/render/vnode.d.ts +330 -0
- package/src/lib/render/vnode.d.ts.map +1 -0
- package/src/lib/render/vnode.js +293 -0
- package/src/lib/render/vnode.js.map +1 -0
- package/src/lib/server-render.d.ts +34 -0
- package/src/lib/server-render.d.ts.map +1 -0
- package/src/lib/server-render.js +84 -0
- package/src/lib/server-render.js.map +1 -0
- package/src/lib/start.d.ts +13 -0
- package/src/lib/start.d.ts.map +1 -0
- package/src/lib/start.js +20 -0
- package/src/lib/start.js.map +1 -0
- package/src/lib/template-contract.d.ts +347 -0
- package/src/lib/template-contract.d.ts.map +1 -0
- package/src/lib/template-contract.js +1 -0
- package/src/lib/template-contract.js.map +1 -0
- package/src/lib/template.d.ts +11 -0
- package/src/lib/template.d.ts.map +1 -0
- package/src/lib/template.js +21 -0
- package/src/lib/template.js.map +1 -0
- package/src/lib/testing.d.ts +157 -0
- package/src/lib/testing.d.ts.map +1 -0
- package/src/lib/testing.js +416 -0
- package/src/lib/testing.js.map +1 -0
- package/src/lib/types.d.ts +442 -0
- package/src/lib/types.d.ts.map +1 -0
- package/src/lib/types.js +22 -0
- package/src/lib/types.js.map +1 -0
- package/testing/public-api.d.ts +3 -0
- package/testing/public-api.d.ts.map +1 -0
- package/testing/public-api.js +3 -0
- package/testing/public-api.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Romain Geffrault
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@craft-ts/component",
|
|
3
|
+
"version": "0.7.0-beta.13",
|
|
4
|
+
"description": "Functional single-file components for CraftTS",
|
|
5
|
+
"author": "Romain Geffrault",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://craft-ts.github.io/craft/",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/craft-ts/craft-ts/issues"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/craft-ts/craft-ts.git"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@craft-ts/core": "^0.7.0-beta.0"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=20.19.0"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./src/index.js",
|
|
27
|
+
"types": "./src/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./src/index.d.ts",
|
|
32
|
+
"default": "./src/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"module": "./src/index.js"
|
|
36
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export * from './lib/ai/ai-context-menu';
|
|
2
|
+
export * from './lib/ai/ai-send-dialog';
|
|
3
|
+
export * from './lib/ai/send-context-to-ai';
|
|
4
|
+
export * from './lib/assert-defined-input';
|
|
5
|
+
export * from './lib/bridge';
|
|
6
|
+
export { bootstrapCraft, type CraftAppRef } from './lib/bootstrap';
|
|
7
|
+
export * from './lib/server-render';
|
|
8
|
+
export * from './lib/hydrate';
|
|
9
|
+
export * from './lib/start';
|
|
10
|
+
export * from './lib/render/hydration';
|
|
11
|
+
export { createStringDomAdapter } from './lib/render/string-dom';
|
|
12
|
+
import './lib/craft-defaults';
|
|
13
|
+
export * from './lib/component';
|
|
14
|
+
export * from './lib/css-vars';
|
|
15
|
+
export type { CssVarContract, CssVarsOf, CssVarsContractOfMeta, CssVarsAfterCall, } from './lib/css-vars.type';
|
|
16
|
+
export * from './lib/composition';
|
|
17
|
+
export * from './lib/block';
|
|
18
|
+
export * from './lib/pending-block';
|
|
19
|
+
export * from './lib/field-exception-block';
|
|
20
|
+
export * from './lib/match-block';
|
|
21
|
+
export * from './lib/directive';
|
|
22
|
+
export * from './lib/craft-router-outlet';
|
|
23
|
+
export * from './lib/defer';
|
|
24
|
+
export * from './lib/each';
|
|
25
|
+
export * from './lib/each-scheduling';
|
|
26
|
+
export * from './lib/if-block';
|
|
27
|
+
export * from './lib/project';
|
|
28
|
+
export * from './lib/template';
|
|
29
|
+
export * from './lib/hyperscript';
|
|
30
|
+
export * from './lib/a11y';
|
|
31
|
+
export * from './lib/a11y-control';
|
|
32
|
+
export * from './lib/render/style-registry';
|
|
33
|
+
export * from './lib/testing';
|
|
34
|
+
export type { CraftLocatorResult, CraftTemplateLocatorApi, LocatorCriteria, LocatorCriteriaFor, LocatorContentNamesFor, MaybeDefined, StaticLocatorCriteria, TemplateLocatorCandidates, } from './lib/locator';
|
|
35
|
+
export * from './lib/template-contract';
|
|
36
|
+
export type { ComponentFactory, ComponentTemplate, CraftDirective, CraftComponent, HostRequiredLogic, HostTemplate, Input, InputValue, LogicDecorator, Output, PropsOf, TemplateDecorator, ComponentMeta, DirectiveMeta, CraftDirectiveTemplateDependencies, ComponentTemplateOf, ComponentTemplateNameOf, ComponentLogicOutputOf, YieldableTemplateCallback, YieldableTemplateContext, TemplateMethodUse, TemplateCssVars, ComponentCssVars, ComponentCssVarsOf, ComponentNameOf, ComponentInitializationExceptionsOf, ComponentFieldExceptionsOf, ComponentInitializationExceptionCodes, ContentOptions, ContentSlot, ContentRequirement, ContentRequirementOf, ContentRequirementsOfContext, ContentSelector, ContentSelectorCondition, ContentStyles, ContentStylePolicy, RequiredContent, RenderableContent, ProjectionContractOf, ProjectionOf, ProjectionSlot, ProjectionUnit, CraftTemplate, ContentDependencies, PropsFromFactory, CraftInputExceptionsCarrier, ComponentInputExceptionsOf, } from './lib/types';
|
|
37
|
+
export type { TemplateRenderAvailableActionWhen, TemplateRendersNamedElementWhen, TemplateRendersStateWhen, } from './lib/template-contract';
|
|
38
|
+
export type { CraftNode, CraftNodeChild, CraftNodeChildren, IfBlockNode, CatchBlockNode, MatchBlockNode, TemplateNode, CraftNodeCssVarsCarrier, } from './lib/render/vnode';
|
|
39
|
+
export { CRAFT_NODE_CSS_VARS } from './lib/render/vnode';
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/component/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnE,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAIjE,OAAO,sBAAsB,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EACV,cAAc,EACd,SAAS,EACT,qBAAqB,EACrB,gBAAgB,GAC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cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,iCAAiC,EACjC,+BAA+B,EAC/B,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,cAAc,EACd,YAAY,EACZ,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export * from './lib/ai/ai-context-menu';
|
|
2
|
+
export * from './lib/ai/ai-send-dialog';
|
|
3
|
+
export * from './lib/ai/send-context-to-ai';
|
|
4
|
+
export * from './lib/assert-defined-input';
|
|
5
|
+
export * from './lib/bridge';
|
|
6
|
+
export { bootstrapCraft } from './lib/bootstrap';
|
|
7
|
+
export * from './lib/server-render';
|
|
8
|
+
export * from './lib/hydrate';
|
|
9
|
+
export * from './lib/start';
|
|
10
|
+
export * from './lib/render/hydration';
|
|
11
|
+
export { createStringDomAdapter } from './lib/render/string-dom';
|
|
12
|
+
// Registers Craft's default pending loader and lazy-route recovery host.
|
|
13
|
+
// Side-effect only: nothing needs to name them, the router resolves them
|
|
14
|
+
// through CRAFT_PENDING_COMPONENT / CRAFT_ROUTE_LOAD_ERROR_COMPONENT.
|
|
15
|
+
import './lib/craft-defaults';
|
|
16
|
+
export * from './lib/component';
|
|
17
|
+
export * from './lib/css-vars';
|
|
18
|
+
export * from './lib/composition';
|
|
19
|
+
export * from './lib/block';
|
|
20
|
+
export * from './lib/pending-block';
|
|
21
|
+
export * from './lib/field-exception-block';
|
|
22
|
+
export * from './lib/match-block';
|
|
23
|
+
export * from './lib/directive';
|
|
24
|
+
export * from './lib/craft-router-outlet';
|
|
25
|
+
export * from './lib/defer';
|
|
26
|
+
export * from './lib/each';
|
|
27
|
+
export * from './lib/each-scheduling';
|
|
28
|
+
export * from './lib/if-block';
|
|
29
|
+
export * from './lib/project';
|
|
30
|
+
export * from './lib/template';
|
|
31
|
+
export * from './lib/hyperscript';
|
|
32
|
+
export * from './lib/a11y';
|
|
33
|
+
export * from './lib/a11y-control';
|
|
34
|
+
export * from './lib/render/style-registry';
|
|
35
|
+
export * from './lib/testing';
|
|
36
|
+
export * from './lib/template-contract';
|
|
37
|
+
export { CRAFT_NODE_CSS_VARS } from './lib/render/vnode';
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/component/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAoB,MAAM,iBAAiB,CAAC;AACnE,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,yEAAyE;AACzE,yEAAyE;AACzE,sEAAsE;AACtE,OAAO,sBAAsB,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAO/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAW9B,cAAc,yBAAyB,CAAC;AAkExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export * from './lib/ai/ai-context-menu';\nexport * from './lib/ai/ai-send-dialog';\nexport * from './lib/ai/send-context-to-ai';\nexport * from './lib/assert-defined-input';\nexport * from './lib/bridge';\nexport { bootstrapCraft, type CraftAppRef } from './lib/bootstrap';\nexport * from './lib/server-render';\nexport * from './lib/hydrate';\nexport * from './lib/start';\nexport * from './lib/render/hydration';\nexport { createStringDomAdapter } from './lib/render/string-dom';\n// Registers Craft's default pending loader and lazy-route recovery host.\n// Side-effect only: nothing needs to name them, the router resolves them\n// through CRAFT_PENDING_COMPONENT / CRAFT_ROUTE_LOAD_ERROR_COMPONENT.\nimport './lib/craft-defaults';\nexport * from './lib/component';\nexport * from './lib/css-vars';\nexport type {\n CssVarContract,\n CssVarsOf,\n CssVarsContractOfMeta,\n CssVarsAfterCall,\n} from './lib/css-vars.type';\nexport * from './lib/composition';\nexport * from './lib/block';\nexport * from './lib/pending-block';\nexport * from './lib/field-exception-block';\nexport * from './lib/match-block';\nexport * from './lib/directive';\nexport * from './lib/craft-router-outlet';\nexport * from './lib/defer';\nexport * from './lib/each';\nexport * from './lib/each-scheduling';\nexport * from './lib/if-block';\nexport * from './lib/project';\nexport * from './lib/template';\nexport * from './lib/hyperscript';\nexport * from './lib/a11y';\nexport * from './lib/a11y-control';\nexport * from './lib/render/style-registry';\nexport * from './lib/testing';\nexport type {\n CraftLocatorResult,\n CraftTemplateLocatorApi,\n LocatorCriteria,\n LocatorCriteriaFor,\n LocatorContentNamesFor,\n MaybeDefined,\n StaticLocatorCriteria,\n TemplateLocatorCandidates,\n} from './lib/locator';\nexport * from './lib/template-contract';\nexport type {\n ComponentFactory,\n ComponentTemplate,\n CraftDirective,\n CraftComponent,\n HostRequiredLogic,\n HostTemplate,\n Input,\n InputValue,\n LogicDecorator,\n Output,\n PropsOf,\n TemplateDecorator,\n ComponentMeta,\n DirectiveMeta,\n CraftDirectiveTemplateDependencies,\n ComponentTemplateOf,\n ComponentTemplateNameOf,\n ComponentLogicOutputOf,\n YieldableTemplateCallback,\n YieldableTemplateContext,\n TemplateMethodUse,\n TemplateCssVars,\n ComponentCssVars,\n ComponentCssVarsOf,\n ComponentNameOf,\n ComponentInitializationExceptionsOf,\n ComponentFieldExceptionsOf,\n ComponentInitializationExceptionCodes,\n ContentOptions,\n ContentSlot,\n ContentRequirement,\n ContentRequirementOf,\n ContentRequirementsOfContext,\n ContentSelector,\n ContentSelectorCondition,\n ContentStyles,\n ContentStylePolicy,\n RequiredContent,\n RenderableContent,\n ProjectionContractOf,\n ProjectionOf,\n ProjectionSlot,\n ProjectionUnit,\n CraftTemplate,\n ContentDependencies,\n PropsFromFactory,\n CraftInputExceptionsCarrier,\n ComponentInputExceptionsOf,\n} from './lib/types';\nexport type {\n TemplateRenderAvailableActionWhen,\n TemplateRendersNamedElementWhen,\n TemplateRendersStateWhen,\n} from './lib/template-contract';\nexport type {\n CraftNode,\n CraftNodeChild,\n CraftNodeChildren,\n IfBlockNode,\n CatchBlockNode,\n MatchBlockNode,\n TemplateNode,\n CraftNodeCssVarsCarrier,\n} from './lib/render/vnode';\nexport { CRAFT_NODE_CSS_VARS } from './lib/render/vnode';\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type FieldIds = {
|
|
2
|
+
readonly inputId: string;
|
|
3
|
+
readonly descriptionId: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function fieldIds(id: string): FieldIds;
|
|
6
|
+
export type FieldControl = {
|
|
7
|
+
readonly ids: FieldIds;
|
|
8
|
+
readonly input: {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly 'aria-describedby': string;
|
|
11
|
+
readonly 'aria-invalid'?: true;
|
|
12
|
+
readonly 'data-invalid'?: true;
|
|
13
|
+
};
|
|
14
|
+
readonly label: {
|
|
15
|
+
readonly htmlFor: string;
|
|
16
|
+
};
|
|
17
|
+
readonly description: {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare function fieldControl(id: string, options?: {
|
|
22
|
+
readonly invalid?: boolean;
|
|
23
|
+
}): FieldControl;
|
|
24
|
+
export type DisclosureControl = {
|
|
25
|
+
readonly buttonId: string;
|
|
26
|
+
readonly panelId: string;
|
|
27
|
+
readonly button: {
|
|
28
|
+
readonly type: 'button';
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly 'aria-expanded': boolean;
|
|
31
|
+
readonly 'aria-controls': string;
|
|
32
|
+
readonly 'data-open'?: true;
|
|
33
|
+
readonly 'aria-disabled'?: true;
|
|
34
|
+
readonly 'data-disabled'?: true;
|
|
35
|
+
};
|
|
36
|
+
readonly panel: {
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly 'data-open'?: true;
|
|
39
|
+
readonly 'aria-hidden'?: true;
|
|
40
|
+
readonly hidden?: true;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare function disclosureControl(id: string, isOpen: boolean, options?: {
|
|
44
|
+
readonly disabled?: boolean;
|
|
45
|
+
}): DisclosureControl;
|
|
46
|
+
export type ButtonControl = {
|
|
47
|
+
readonly type: 'button' | 'submit' | 'reset';
|
|
48
|
+
readonly disabled?: true;
|
|
49
|
+
readonly 'aria-disabled'?: true;
|
|
50
|
+
readonly 'data-disabled'?: true;
|
|
51
|
+
};
|
|
52
|
+
export declare function buttonControl(options?: {
|
|
53
|
+
readonly type?: 'button' | 'submit' | 'reset';
|
|
54
|
+
readonly disabled?: boolean;
|
|
55
|
+
readonly keepFocusable?: boolean;
|
|
56
|
+
}): ButtonControl;
|
|
57
|
+
export declare function clickFocus<E extends MouseEvent>(selector: string, handler?: (event: E) => unknown): (event: E) => unknown;
|
|
58
|
+
//# sourceMappingURL=a11y-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y-control.d.ts","sourceRoot":"","sources":["../../../../../libs/component/src/lib/a11y-control.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAK7C;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;QACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC;QAC/B,QAAQ,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC;KAChC,CAAC;IACF,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,QAAQ,CAAC,WAAW,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C,CAAC;AAEF,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GACvC,YAAY,CAcd;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,IAAI,EAA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BhB;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,EAC7C,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAC9B,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAOvB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export function fieldIds(id) {
|
|
2
|
+
return {
|
|
3
|
+
inputId: id,
|
|
4
|
+
descriptionId: `${id}-description`,
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function fieldControl(id, options) {
|
|
8
|
+
const ids = fieldIds(id);
|
|
9
|
+
return {
|
|
10
|
+
ids,
|
|
11
|
+
input: {
|
|
12
|
+
id: ids.inputId,
|
|
13
|
+
'aria-describedby': ids.descriptionId,
|
|
14
|
+
...(options?.invalid
|
|
15
|
+
? { 'aria-invalid': true, 'data-invalid': true }
|
|
16
|
+
: {}),
|
|
17
|
+
},
|
|
18
|
+
label: { htmlFor: ids.inputId },
|
|
19
|
+
description: { id: ids.descriptionId },
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function disclosureControl(id, isOpen, options) {
|
|
23
|
+
const buttonId = `${id}-button`;
|
|
24
|
+
const panelId = `${id}-panel`;
|
|
25
|
+
const openAttrs = isOpen ? { 'data-open': true } : {};
|
|
26
|
+
return {
|
|
27
|
+
buttonId,
|
|
28
|
+
panelId,
|
|
29
|
+
button: {
|
|
30
|
+
type: 'button',
|
|
31
|
+
id: buttonId,
|
|
32
|
+
'aria-expanded': isOpen,
|
|
33
|
+
'aria-controls': panelId,
|
|
34
|
+
...openAttrs,
|
|
35
|
+
...(options?.disabled
|
|
36
|
+
? { 'aria-disabled': true, 'data-disabled': true }
|
|
37
|
+
: {}),
|
|
38
|
+
},
|
|
39
|
+
panel: {
|
|
40
|
+
id: panelId,
|
|
41
|
+
...openAttrs,
|
|
42
|
+
...(isOpen
|
|
43
|
+
? {}
|
|
44
|
+
: { 'aria-hidden': true, hidden: true }),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function buttonControl(options) {
|
|
49
|
+
const type = options?.type ?? 'button';
|
|
50
|
+
if (!options?.disabled) {
|
|
51
|
+
return { type };
|
|
52
|
+
}
|
|
53
|
+
if (options.keepFocusable) {
|
|
54
|
+
return {
|
|
55
|
+
type,
|
|
56
|
+
'aria-disabled': true,
|
|
57
|
+
'data-disabled': true,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
type,
|
|
62
|
+
disabled: true,
|
|
63
|
+
'data-disabled': true,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function clickFocus(selector, handler) {
|
|
67
|
+
return (event) => {
|
|
68
|
+
const root = event.currentTarget?.ownerDocument ?? document;
|
|
69
|
+
const target = root.querySelector(selector);
|
|
70
|
+
target?.focus();
|
|
71
|
+
return handler?.(event);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=a11y-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y-control.js","sourceRoot":"","sources":["../../../../../libs/component/src/lib/a11y-control.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,OAAO;QACL,OAAO,EAAE,EAAE;QACX,aAAa,EAAE,GAAG,EAAE,cAAc;KACnC,CAAC;AACJ,CAAC;AAcD,MAAM,UAAU,YAAY,CAC1B,EAAU,EACV,OAAwC;IAExC,MAAM,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACzB,OAAO;QACL,GAAG;QACH,KAAK,EAAE;YACL,EAAE,EAAE,GAAG,CAAC,OAAO;YACf,kBAAkB,EAAE,GAAG,CAAC,aAAa;YACrC,GAAG,CAAC,OAAO,EAAE,OAAO;gBAClB,CAAC,CAAC,EAAE,cAAc,EAAE,IAAa,EAAE,cAAc,EAAE,IAAa,EAAE;gBAClE,CAAC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,eAAe,EAAE,IAAI;YACrB,eAAe,EAAE,IAAI;SACtB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,IAAI;QACd,eAAe,EAAE,IAAI;KACtB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,QAAgB,EAChB,OAA+B;IAE/B,OAAO,CAAC,KAAQ,EAAE,EAAE;QAClB,MAAM,IAAI,GAAI,KAAK,CAAC,aAAgC,EAAE,aAAa,IAAI,QAAQ,CAAC;QAChF,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAc,QAAQ,CAAC,CAAC;QACzD,MAAM,EAAE,KAAK,EAAE,CAAC;QAChB,OAAO,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["export type FieldIds = {\n readonly inputId: string;\n readonly descriptionId: string;\n};\n\nexport function fieldIds(id: string): FieldIds {\n return {\n inputId: id,\n descriptionId: `${id}-description`,\n };\n}\n\nexport type FieldControl = {\n readonly ids: FieldIds;\n readonly input: {\n readonly id: string;\n readonly 'aria-describedby': string;\n readonly 'aria-invalid'?: true;\n readonly 'data-invalid'?: true;\n };\n readonly label: { readonly htmlFor: string };\n readonly description: { readonly id: string };\n};\n\nexport function fieldControl(\n id: string,\n options?: { readonly invalid?: boolean },\n): FieldControl {\n const ids = fieldIds(id);\n return {\n ids,\n input: {\n id: ids.inputId,\n 'aria-describedby': ids.descriptionId,\n ...(options?.invalid\n ? { 'aria-invalid': true as const, 'data-invalid': true as const }\n : {}),\n },\n label: { htmlFor: ids.inputId },\n description: { id: ids.descriptionId },\n };\n}\n\nexport type DisclosureControl = {\n readonly buttonId: string;\n readonly panelId: string;\n readonly button: {\n readonly type: 'button';\n readonly id: string;\n readonly 'aria-expanded': boolean;\n readonly 'aria-controls': string;\n readonly 'data-open'?: true;\n readonly 'aria-disabled'?: true;\n readonly 'data-disabled'?: true;\n };\n readonly panel: {\n readonly id: string;\n readonly 'data-open'?: true;\n readonly 'aria-hidden'?: true;\n readonly hidden?: true;\n };\n};\n\nexport function disclosureControl(\n id: string,\n isOpen: boolean,\n options?: { readonly disabled?: boolean },\n): DisclosureControl {\n const buttonId = `${id}-button`;\n const panelId = `${id}-panel`;\n const openAttrs = isOpen ? ({ 'data-open': true as const } as const) : {};\n return {\n buttonId,\n panelId,\n button: {\n type: 'button',\n id: buttonId,\n 'aria-expanded': isOpen,\n 'aria-controls': panelId,\n ...openAttrs,\n ...(options?.disabled\n ? { 'aria-disabled': true as const, 'data-disabled': true as const }\n : {}),\n },\n panel: {\n id: panelId,\n ...openAttrs,\n ...(isOpen\n ? {}\n : { 'aria-hidden': true as const, hidden: true as const }),\n },\n };\n}\n\nexport type ButtonControl = {\n readonly type: 'button' | 'submit' | 'reset';\n readonly disabled?: true;\n readonly 'aria-disabled'?: true;\n readonly 'data-disabled'?: true;\n};\n\nexport function buttonControl(options?: {\n readonly type?: 'button' | 'submit' | 'reset';\n readonly disabled?: boolean;\n readonly keepFocusable?: boolean;\n}): ButtonControl {\n const type = options?.type ?? 'button';\n if (!options?.disabled) {\n return { type };\n }\n if (options.keepFocusable) {\n return {\n type,\n 'aria-disabled': true,\n 'data-disabled': true,\n };\n }\n return {\n type,\n disabled: true,\n 'data-disabled': true,\n };\n}\n\nexport function clickFocus<E extends MouseEvent>(\n selector: string,\n handler?: (event: E) => unknown,\n): (event: E) => unknown {\n return (event: E) => {\n const root = (event.currentTarget as Element | null)?.ownerDocument ?? document;\n const target = root.querySelector<HTMLElement>(selector);\n target?.focus();\n return handler?.(event);\n };\n}\n"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Yieldable } from '@craft-ts/core';
|
|
2
|
+
import { type CraftNodeChildren, type CraftNodeChildrenDependencies, type ElementNode, type HeadingNode, type HeadingSectionNode } from './render/vnode';
|
|
3
|
+
type HeadingProps = {
|
|
4
|
+
readonly class?: unknown;
|
|
5
|
+
readonly style?: unknown;
|
|
6
|
+
readonly id?: string | (() => string) | Yieldable<[], string, unknown>;
|
|
7
|
+
readonly [attribute: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Renders a heading whose rank comes from the current outline (`h1`–`h6`).
|
|
11
|
+
* The title does not pick `h2` vs `h3` — the parent outline does.
|
|
12
|
+
*
|
|
13
|
+
* A local `heading()` is allowed in this template (route page title = `h1`).
|
|
14
|
+
* A child component that renders `heading()` must be wrapped by **this**
|
|
15
|
+
* parent in {@link headingSection} (same DNA as `pendingBlock`). Otherwise
|
|
16
|
+
* the call does not compile:
|
|
17
|
+
* `ERROR_child_heading_rendered_outside_a_headingSection`.
|
|
18
|
+
*
|
|
19
|
+
* Prefer this over `h1()`…`h6()` inside a `craftComponent`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* heading('Liste des tâches');
|
|
23
|
+
* headingSection([
|
|
24
|
+
* heading('Détail'),
|
|
25
|
+
* TaskCard(), // child's heading() becomes hN+1
|
|
26
|
+
* ]);
|
|
27
|
+
*
|
|
28
|
+
* @see headingSection
|
|
29
|
+
* @see headingRoot
|
|
30
|
+
*/
|
|
31
|
+
export declare function heading<const Children extends CraftNodeChildren>(children?: Children): HeadingNode<CraftNodeChildrenDependencies<Children>, Children, HeadingProps, 'heading'>;
|
|
32
|
+
export declare function heading<const Children extends CraftNodeChildren>(props: HeadingProps | null, children?: Children): HeadingNode<CraftNodeChildrenDependencies<Children>, Children, HeadingProps, 'heading'>;
|
|
33
|
+
/**
|
|
34
|
+
* Increments the heading outline by one rank for the subtree.
|
|
35
|
+
*
|
|
36
|
+
* Not a visual box and not a `<section>`: comment-bounded fragment, no extra
|
|
37
|
+
* DOM node (same as `ifBlock`). Nested {@link heading} calls become
|
|
38
|
+
* `hN+1`. Also absorbs a child's heading need so the parent compiles.
|
|
39
|
+
*
|
|
40
|
+
* Nest to build the document outline: page `heading()` → `h1`, first
|
|
41
|
+
* `headingSection` → `h2`, nested `headingSection` → `h3`, clamped at `h6`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* heading('Page');
|
|
45
|
+
* headingSection([
|
|
46
|
+
* heading('Section'),
|
|
47
|
+
* headingSection([heading('Subsection')]),
|
|
48
|
+
* ]);
|
|
49
|
+
*
|
|
50
|
+
* @see heading
|
|
51
|
+
* @see headingRoot
|
|
52
|
+
*/
|
|
53
|
+
export declare function headingSection<const Children extends CraftNodeChildren>(children?: Children): HeadingSectionNode<CraftNodeChildrenDependencies<Children>, Children>;
|
|
54
|
+
/**
|
|
55
|
+
* Starts the heading outline at level 1 for the subtree. Absorbs children's
|
|
56
|
+
* heading need. Use for a route page, or a nested root (a `<dialog>` already
|
|
57
|
+
* resets via the native element — its title is `h1` **inside** the dialog).
|
|
58
|
+
*
|
|
59
|
+
* Unlike {@link headingSection}, this does not increment: every {@link heading}
|
|
60
|
+
* below is `h1` again.
|
|
61
|
+
*
|
|
62
|
+
* @see heading
|
|
63
|
+
* @see headingSection
|
|
64
|
+
*/
|
|
65
|
+
export declare function headingRoot<const Children extends CraftNodeChildren>(children?: Children): HeadingSectionNode<CraftNodeChildrenDependencies<Children>, Children>;
|
|
66
|
+
/**
|
|
67
|
+
* Skip link for the application shell. Pair with `main({ id: targetId }, …)`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function skipLink(targetId?: string, label?: string): ElementNode<CraftNodeChildrenDependencies<string>, "a", NoInfer<{
|
|
70
|
+
readonly href: `#${string}`;
|
|
71
|
+
readonly class: "skip-link";
|
|
72
|
+
}>, string, string | undefined, string, never, never, import("./css-vars.type").EmptyCssVarContract, never, never>;
|
|
73
|
+
/**
|
|
74
|
+
* Announces dynamic text to assistive technology (toasts, "Copied").
|
|
75
|
+
*/
|
|
76
|
+
type LiveRegionProps = {
|
|
77
|
+
readonly politeness?: 'polite' | 'assertive';
|
|
78
|
+
readonly label?: string;
|
|
79
|
+
};
|
|
80
|
+
export declare function liveRegion<const Children extends CraftNodeChildren>(children?: Children): ElementNode<CraftNodeChildrenDependencies<Children>, 'span', {
|
|
81
|
+
readonly 'aria-live': 'polite';
|
|
82
|
+
readonly 'aria-atomic': 'true';
|
|
83
|
+
readonly role: 'status';
|
|
84
|
+
}, Children>;
|
|
85
|
+
export declare function liveRegion<const Children extends CraftNodeChildren>(props: LiveRegionProps | null, children?: Children): ElementNode<CraftNodeChildrenDependencies<Children>, 'span', object, Children>;
|
|
86
|
+
export {};
|
|
87
|
+
//# sourceMappingURL=a11y.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y.d.ts","sourceRoot":"","sources":["../../../../../libs/component/src/lib/a11y.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAExB,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACvE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CACvC,CAAC;AAaF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,OAAO,CAAC,KAAK,CAAC,QAAQ,SAAS,iBAAiB,EAC9D,QAAQ,CAAC,EAAE,QAAQ,GAClB,WAAW,CAAC,6BAA6B,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;AAC3F,wBAAgB,OAAO,CAAC,KAAK,CAAC,QAAQ,SAAS,iBAAiB,EAC9D,KA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,GAClB,WAAW,CACZ,6BAA6B,CAAC,QAAQ,CAAC,EACvC,MAAM,EACN,MAAM,EACN,QAAQ,CACT,CAAC"}
|
package/src/lib/a11y.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { a, span } from './hyperscript';
|
|
2
|
+
import { pipeCraftNode, } from './render/vnode';
|
|
3
|
+
function looksLikeChildren(value) {
|
|
4
|
+
return (value === null ||
|
|
5
|
+
value === undefined ||
|
|
6
|
+
Array.isArray(value) ||
|
|
7
|
+
typeof value !== 'object' ||
|
|
8
|
+
('kind' in value &&
|
|
9
|
+
typeof value.kind === 'string'));
|
|
10
|
+
}
|
|
11
|
+
export function heading(propsOrChildren, maybeChildren) {
|
|
12
|
+
const props = looksLikeChildren(propsOrChildren)
|
|
13
|
+
? {}
|
|
14
|
+
: (propsOrChildren ?? {});
|
|
15
|
+
const children = looksLikeChildren(propsOrChildren)
|
|
16
|
+
? propsOrChildren
|
|
17
|
+
: maybeChildren;
|
|
18
|
+
const node = {
|
|
19
|
+
kind: 'heading',
|
|
20
|
+
props,
|
|
21
|
+
children: children ?? [],
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(node, 'pipe', {
|
|
24
|
+
value: (directive) => pipeCraftNode(node, directive),
|
|
25
|
+
enumerable: false,
|
|
26
|
+
});
|
|
27
|
+
return node;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Increments the heading outline by one rank for the subtree.
|
|
31
|
+
*
|
|
32
|
+
* Not a visual box and not a `<section>`: comment-bounded fragment, no extra
|
|
33
|
+
* DOM node (same as `ifBlock`). Nested {@link heading} calls become
|
|
34
|
+
* `hN+1`. Also absorbs a child's heading need so the parent compiles.
|
|
35
|
+
*
|
|
36
|
+
* Nest to build the document outline: page `heading()` → `h1`, first
|
|
37
|
+
* `headingSection` → `h2`, nested `headingSection` → `h3`, clamped at `h6`.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* heading('Page');
|
|
41
|
+
* headingSection([
|
|
42
|
+
* heading('Section'),
|
|
43
|
+
* headingSection([heading('Subsection')]),
|
|
44
|
+
* ]);
|
|
45
|
+
*
|
|
46
|
+
* @see heading
|
|
47
|
+
* @see headingRoot
|
|
48
|
+
*/
|
|
49
|
+
export function headingSection(children) {
|
|
50
|
+
return {
|
|
51
|
+
kind: 'heading-section',
|
|
52
|
+
children: (children ?? []),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Starts the heading outline at level 1 for the subtree. Absorbs children's
|
|
57
|
+
* heading need. Use for a route page, or a nested root (a `<dialog>` already
|
|
58
|
+
* resets via the native element — its title is `h1` **inside** the dialog).
|
|
59
|
+
*
|
|
60
|
+
* Unlike {@link headingSection}, this does not increment: every {@link heading}
|
|
61
|
+
* below is `h1` again.
|
|
62
|
+
*
|
|
63
|
+
* @see heading
|
|
64
|
+
* @see headingSection
|
|
65
|
+
*/
|
|
66
|
+
export function headingRoot(children) {
|
|
67
|
+
return {
|
|
68
|
+
kind: 'heading-section',
|
|
69
|
+
reset: true,
|
|
70
|
+
children: (children ?? []),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Skip link for the application shell. Pair with `main({ id: targetId }, …)`.
|
|
75
|
+
*/
|
|
76
|
+
export function skipLink(targetId = 'main', label = 'Skip to main content') {
|
|
77
|
+
return a({ href: `#${targetId}`, class: 'skip-link' }, label);
|
|
78
|
+
}
|
|
79
|
+
export function liveRegion(propsOrChildren, maybeChildren) {
|
|
80
|
+
const props = looksLikeChildren(propsOrChildren)
|
|
81
|
+
? { politeness: 'polite' }
|
|
82
|
+
: (propsOrChildren ?? {});
|
|
83
|
+
const children = looksLikeChildren(propsOrChildren)
|
|
84
|
+
? propsOrChildren
|
|
85
|
+
: maybeChildren;
|
|
86
|
+
const politeness = props.politeness ?? 'polite';
|
|
87
|
+
const label = props.label;
|
|
88
|
+
return span({
|
|
89
|
+
'aria-live': politeness,
|
|
90
|
+
'aria-atomic': 'true',
|
|
91
|
+
...(label !== undefined
|
|
92
|
+
? { role: 'region', 'aria-label': label }
|
|
93
|
+
: { role: politeness === 'assertive' ? 'alert' : 'status' }),
|
|
94
|
+
}, children);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=a11y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y.js","sourceRoot":"","sources":["../../../../../libs/component/src/lib/a11y.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,aAAa,GAMd,MAAM,gBAAgB,CAAC;AASxB,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,CACL,KAAK,KAAK,IAAI;QACd,KAAK,KAAK,SAAS;QACnB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACpB,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,MAAM,IAAK,KAAgB;YAC1B,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CAAC,CAC1D,CAAC;AACJ,CAAC;AAoCD,MAAM,UAAU,OAAO,CACrB,eAAyD,EACzD,aAAiC;IAEjC,MAAM,KAAK,GAAG,iBAAiB,CAAC,eAAe,CAAC;QAC9C,CAAC,CAAC,EAAE;QACJ,CAAC,CAAE,CAAC,eAAe,IAAI,EAAE,CAAkB,CAAC;IAC9C,MAAM,QAAQ,GAAG,iBAAiB,CAAC,eAAe,CAAC;QACjD,CAAC,CAAE,eAAqC;QACxC,CAAC,CAAC,aAAa,CAAC;IAClB,MAAM,IAAI,GAAG;QACX,IAAI,EAAE,SAAkB;QACxB,KAAK;QACL,QAAQ,EAAE,QAAQ,IAAI,EAAE;KACzB,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE;QAClC,KAAK,EAAE,CAAC,SAAkB,EAAE,EAAE,CAC5B,aAAa,CAAC,IAAa,EAAE,SAAkB,CAAC;QAClD,UA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QAAiB,EAAE,YAAY,EAAE,KAAK,EAAE;YAClD,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;KAC/D,EACD,QAAQ,CACT,CAAC;AACJ,CAAC","sourcesContent":["import type { Yieldable } from '@craft-ts/core';\nimport { a, span } from './hyperscript';\nimport {\n pipeCraftNode,\n type CraftNodeChildren,\n type CraftNodeChildrenDependencies,\n type ElementNode,\n type HeadingNode,\n type HeadingSectionNode,\n} from './render/vnode';\n\ntype HeadingProps = {\n readonly class?: unknown;\n readonly style?: unknown;\n readonly id?: string | (() => string) | Yieldable<[], string, unknown>;\n readonly [attribute: string]: unknown;\n};\n\nfunction looksLikeChildren(value: unknown): boolean {\n return (\n value === null ||\n value === undefined ||\n Array.isArray(value) ||\n typeof value !== 'object' ||\n ('kind' in (value as object) &&\n typeof (value as { kind?: unknown }).kind === 'string')\n );\n}\n\n/**\n * Renders a heading whose rank comes from the current outline (`h1`–`h6`).\n * The title does not pick `h2` vs `h3` — the parent outline does.\n *\n * A local `heading()` is allowed in this template (route page title = `h1`).\n * A child component that renders `heading()` must be wrapped by **this**\n * parent in {@link headingSection} (same DNA as `pendingBlock`). Otherwise\n * the call does not compile:\n * `ERROR_child_heading_rendered_outside_a_headingSection`.\n *\n * Prefer this over `h1()`…`h6()` inside a `craftComponent`.\n *\n * @example\n * heading('Liste des tâches');\n * headingSection([\n * heading('Détail'),\n * TaskCard(), // child's heading() becomes hN+1\n * ]);\n *\n * @see headingSection\n * @see headingRoot\n */\nexport function heading<const Children extends CraftNodeChildren>(\n children?: Children,\n): HeadingNode<CraftNodeChildrenDependencies<Children>, Children, HeadingProps, 'heading'>;\nexport function heading<const Children extends CraftNodeChildren>(\n props: HeadingProps | null,\n children?: Children,\n): HeadingNode<\n CraftNodeChildrenDependencies<Children>,\n Children,\n HeadingProps,\n 'heading'\n>;\nexport function heading(\n propsOrChildren?: HeadingProps | CraftNodeChildren | null,\n maybeChildren?: CraftNodeChildren,\n): HeadingNode<any, any, HeadingProps, 'heading'> {\n const props = looksLikeChildren(propsOrChildren)\n ? {}\n : ((propsOrChildren ?? {}) as HeadingProps);\n const children = looksLikeChildren(propsOrChildren)\n ? (propsOrChildren as CraftNodeChildren)\n : maybeChildren;\n const node = {\n kind: 'heading' as const,\n props,\n children: children ?? [],\n };\n Object.defineProperty(node, 'pipe', {\n value: (directive: unknown) =>\n pipeCraftNode(node as never, directive as never),\n enumerable: false,\n });\n return node as HeadingNode<any, any, HeadingProps, 'heading'>;\n}\n\n/**\n * Increments the heading outline by one rank for the subtree.\n *\n * Not a visual box and not a `<section>`: comment-bounded fragment, no extra\n * DOM node (same as `ifBlock`). Nested {@link heading} calls become\n * `hN+1`. Also absorbs a child's heading need so the parent compiles.\n *\n * Nest to build the document outline: page `heading()` → `h1`, first\n * `headingSection` → `h2`, nested `headingSection` → `h3`, clamped at `h6`.\n *\n * @example\n * heading('Page');\n * headingSection([\n * heading('Section'),\n * headingSection([heading('Subsection')]),\n * ]);\n *\n * @see heading\n * @see headingRoot\n */\nexport function headingSection<const Children extends CraftNodeChildren>(\n children?: Children,\n): HeadingSectionNode<CraftNodeChildrenDependencies<Children>, Children> {\n return {\n kind: 'heading-section',\n children: (children ?? []) as Children,\n };\n}\n\n/**\n * Starts the heading outline at level 1 for the subtree. Absorbs children's\n * heading need. Use for a route page, or a nested root (a `<dialog>` already\n * resets via the native element — its title is `h1` **inside** the dialog).\n *\n * Unlike {@link headingSection}, this does not increment: every {@link heading}\n * below is `h1` again.\n *\n * @see heading\n * @see headingSection\n */\nexport function headingRoot<const Children extends CraftNodeChildren>(\n children?: Children,\n): HeadingSectionNode<CraftNodeChildrenDependencies<Children>, Children> {\n return {\n kind: 'heading-section',\n reset: true,\n children: (children ?? []) as Children,\n };\n}\n\n/**\n * Skip link for the application shell. Pair with `main({ id: targetId }, …)`.\n */\nexport function skipLink(\n targetId = 'main',\n label = 'Skip to main content',\n) {\n return a({ href: `#${targetId}`, class: 'skip-link' }, label);\n}\n\n/**\n * Announces dynamic text to assistive technology (toasts, \"Copied\").\n */\ntype LiveRegionProps = {\n readonly politeness?: 'polite' | 'assertive';\n readonly label?: string;\n};\n\nexport function liveRegion<const Children extends CraftNodeChildren>(\n children?: Children,\n): ElementNode<\n CraftNodeChildrenDependencies<Children>,\n 'span',\n { readonly 'aria-live': 'polite'; readonly 'aria-atomic': 'true'; readonly role: 'status' },\n Children\n>;\nexport function liveRegion<const Children extends CraftNodeChildren>(\n props: LiveRegionProps | null,\n children?: Children,\n): ElementNode<\n CraftNodeChildrenDependencies<Children>,\n 'span',\n object,\n Children\n>;\nexport function liveRegion(\n propsOrChildren?:\n | LiveRegionProps\n | CraftNodeChildren\n | null,\n maybeChildren?: CraftNodeChildren,\n): unknown {\n const props = looksLikeChildren(propsOrChildren)\n ? { politeness: 'polite' as const }\n : ((propsOrChildren ?? {}) as LiveRegionProps);\n const children = looksLikeChildren(propsOrChildren)\n ? (propsOrChildren as CraftNodeChildren)\n : maybeChildren;\n const politeness = props.politeness ?? 'polite';\n const label = props.label;\n return span(\n {\n 'aria-live': politeness,\n 'aria-atomic': 'true',\n ...(label !== undefined\n ? { role: 'region' as const, 'aria-label': label }\n : { role: politeness === 'assertive' ? 'alert' : 'status' }),\n },\n children,\n );\n}\n"]}
|