@starci/grammar 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -55
- package/dist/common/index.d.ts +1 -69
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +5 -197
- package/dist/common/index.js.map +1 -1
- package/dist/core/LeadingNumber.d.ts +12 -0
- package/dist/core/LeadingNumber.d.ts.map +1 -0
- package/dist/core/LeadingNumber.js +10 -0
- package/dist/core/LeadingNumber.js.map +1 -0
- package/dist/core/OtpInput.d.ts +12 -0
- package/dist/core/OtpInput.d.ts.map +1 -0
- package/dist/core/OtpInput.js +21 -0
- package/dist/core/OtpInput.js.map +1 -0
- package/dist/core/StateMark.d.ts +3 -5
- package/dist/core/StateMark.d.ts.map +1 -1
- package/dist/core/StateMark.js +3 -3
- package/dist/core/StateMark.js.map +1 -1
- package/dist/core/branch/MarkdownArticle/classNames.d.ts +9 -0
- package/dist/core/branch/MarkdownArticle/classNames.d.ts.map +1 -0
- package/dist/core/branch/MarkdownArticle/classNames.js +10 -0
- package/dist/core/branch/MarkdownArticle/classNames.js.map +1 -0
- package/dist/core/branch/MarkdownArticle/index.d.ts +30 -0
- package/dist/core/branch/MarkdownArticle/index.d.ts.map +1 -0
- package/dist/core/branch/MarkdownArticle/index.js +12 -0
- package/dist/core/branch/MarkdownArticle/index.js.map +1 -0
- package/dist/core/branch/Rail/classNames.d.ts +9 -0
- package/dist/core/branch/Rail/classNames.d.ts.map +1 -0
- package/dist/core/branch/Rail/classNames.js +10 -0
- package/dist/core/branch/Rail/classNames.js.map +1 -0
- package/dist/core/branch/Rail/index.d.ts +3 -6
- package/dist/core/branch/Rail/index.d.ts.map +1 -1
- package/dist/core/branch/Rail/index.js +6 -5
- package/dist/core/branch/Rail/index.js.map +1 -1
- package/dist/core/branch/SurfaceAccordionCard/classNames.d.ts +15 -0
- package/dist/core/branch/SurfaceAccordionCard/classNames.d.ts.map +1 -0
- package/dist/core/branch/SurfaceAccordionCard/classNames.js +16 -0
- package/dist/core/branch/SurfaceAccordionCard/classNames.js.map +1 -0
- package/dist/core/branch/SurfaceAccordionCard/index.d.ts +37 -0
- package/dist/core/branch/SurfaceAccordionCard/index.d.ts.map +1 -0
- package/dist/core/branch/SurfaceAccordionCard/index.js +24 -0
- package/dist/core/branch/SurfaceAccordionCard/index.js.map +1 -0
- package/dist/core/branch/SurfaceCard/classNames.d.ts +13 -0
- package/dist/core/branch/SurfaceCard/classNames.d.ts.map +1 -0
- package/dist/core/branch/SurfaceCard/classNames.js +14 -0
- package/dist/core/branch/SurfaceCard/classNames.js.map +1 -0
- package/dist/core/branch/SurfaceCard/index.d.ts +3 -6
- package/dist/core/branch/SurfaceCard/index.d.ts.map +1 -1
- package/dist/core/branch/SurfaceCard/index.js +7 -4
- package/dist/core/branch/SurfaceCard/index.js.map +1 -1
- package/dist/core/branch/SurfaceListCard/classNames.d.ts +11 -0
- package/dist/core/branch/SurfaceListCard/classNames.d.ts.map +1 -0
- package/dist/core/branch/SurfaceListCard/classNames.js +12 -0
- package/dist/core/branch/SurfaceListCard/classNames.js.map +1 -0
- package/dist/core/branch/SurfaceListCard/index.d.ts +5 -19
- package/dist/core/branch/SurfaceListCard/index.d.ts.map +1 -1
- package/dist/core/branch/SurfaceListCard/index.js +5 -8
- package/dist/core/branch/SurfaceListCard/index.js.map +1 -1
- package/dist/core/classNames.d.ts +23 -0
- package/dist/core/classNames.d.ts.map +1 -0
- package/dist/core/classNames.js +24 -0
- package/dist/core/classNames.js.map +1 -0
- package/dist/core/composite/HorizontalScrollRegion/index.d.ts +7 -0
- package/dist/core/composite/HorizontalScrollRegion/index.d.ts.map +1 -0
- package/dist/core/composite/HorizontalScrollRegion/index.js +7 -0
- package/dist/core/composite/HorizontalScrollRegion/index.js.map +1 -0
- package/dist/core/composite/StaticStateRow/index.d.ts +1 -5
- package/dist/core/composite/StaticStateRow/index.d.ts.map +1 -1
- package/dist/core/composite/StaticStateRow/index.js +4 -3
- package/dist/core/composite/StaticStateRow/index.js.map +1 -1
- package/dist/core/composite/VerticalScrollRegion/index.d.ts +8 -0
- package/dist/core/composite/VerticalScrollRegion/index.d.ts.map +1 -0
- package/dist/core/composite/VerticalScrollRegion/index.js +10 -0
- package/dist/core/composite/VerticalScrollRegion/index.js.map +1 -0
- package/dist/core/index.d.ts +12 -10
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +11 -10
- package/dist/core/index.js.map +1 -1
- package/dist/core/scrollable-surfaces.spec.d.ts +2 -0
- package/dist/core/scrollable-surfaces.spec.d.ts.map +1 -0
- package/dist/core/scrollable-surfaces.spec.js +37 -0
- package/dist/core/scrollable-surfaces.spec.js.map +1 -0
- package/dist/core/state.d.ts +4 -4
- package/dist/core/state.d.ts.map +1 -1
- package/dist/core/state.js +3 -3
- package/dist/core/state.js.map +1 -1
- package/dist/core/styles.css +426 -70
- package/package.json +5 -9
- package/dist/core/contracts.d.ts +0 -190
- package/dist/core/contracts.d.ts.map +0 -1
- package/dist/core/contracts.js +0 -145
- package/dist/core/contracts.js.map +0 -1
- package/dist/core/grammar.d.ts +0 -18
- package/dist/core/grammar.d.ts.map +0 -1
- package/dist/core/grammar.js +0 -27
- package/dist/core/grammar.js.map +0 -1
- package/dist/core/layout.d.ts +0 -9
- package/dist/core/layout.d.ts.map +0 -1
- package/dist/core/layout.js +0 -43
- package/dist/core/layout.js.map +0 -1
- package/dist/core/rules.d.ts +0 -63
- package/dist/core/rules.d.ts.map +0 -1
- package/dist/core/rules.js +0 -66
- package/dist/core/rules.js.map +0 -1
- package/dist/offset-pop/index.d.ts +0 -266
- package/dist/offset-pop/index.d.ts.map +0 -1
- package/dist/offset-pop/index.js +0 -69
- package/dist/offset-pop/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,55 +1,44 @@
|
|
|
1
|
-
# `@starci/grammar`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- `@starci/grammar/
|
|
10
|
-
- `@starci/grammar/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Adapters must bind directly to the `core.*` contract identity and emit the canonical `data-grammar-*` anatomy. A product-prefixed contract with no resolved Core axis is not a substitute for conformance.
|
|
46
|
-
|
|
47
|
-
Contracts are immutable. Extensions may resolve only axes explicitly opened by the base contract. They cannot replace anatomy, mutate a closed invariant, substitute the owner or silently replace a duplicate registry key.
|
|
48
|
-
|
|
49
|
-
## Package checks
|
|
50
|
-
|
|
51
|
-
```sh
|
|
52
|
-
npm run typecheck
|
|
53
|
-
npm test
|
|
54
|
-
npm pack --dry-run
|
|
55
|
-
```
|
|
1
|
+
# `@starci/grammar`
|
|
2
|
+
|
|
3
|
+
`@starci/grammar` is a business-neutral React component package for StarCi Academy. It wraps
|
|
4
|
+
HeroUI primitives with stable, accessible presentation components and provides the Offset Pop
|
|
5
|
+
visual layer. It contains no application routes, data fetching, domain entities, or product state.
|
|
6
|
+
|
|
7
|
+
## Public entry points
|
|
8
|
+
|
|
9
|
+
- `@starci/grammar/common` — presentation-state helpers and shared CSS.
|
|
10
|
+
- `@starci/grammar/core` — `StateMark`, `LeadingNumber`, `StaticStateRow`, `SurfaceCard`,
|
|
11
|
+
`SurfaceListCard`, `MarkdownArticle`, `SurfaceAccordionCard`, and `Rail`.
|
|
12
|
+
- `@starci/grammar/common/styles.css`, `@starci/grammar/core/styles.css`, and
|
|
13
|
+
`@starci/grammar/offset-pop/styles.css` — package stylesheets. Short `.css` export aliases are
|
|
14
|
+
also available.
|
|
15
|
+
|
|
16
|
+
Install the workspace package while developing locally:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm install ./packages/grammar
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Import components from the focused entry point:
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { MarkdownArticle, SurfaceCard } from "@starci/grammar/core"
|
|
26
|
+
import "@starci/grammar/core/styles.css"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Core components accept ordinary typed React props and keep their own semantic DOM and accessibility
|
|
30
|
+
behavior. The consuming application remains responsible for translating business data into those
|
|
31
|
+
props. Offset Pop adds visual treatment only; it does not change ownership or business behavior.
|
|
32
|
+
The package deliberately exposes no rule registry, contract metadata, Tree DSL, projection, or
|
|
33
|
+
runtime visual-vocabulary object.
|
|
34
|
+
|
|
35
|
+
## Package checks
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm run typecheck
|
|
39
|
+
npm test
|
|
40
|
+
npm pack --dry-run
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The package requires Node.js 20 or newer and has peer dependencies on React 18+ and
|
|
44
|
+
`@heroui/react` 3.2+.
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,74 +1,6 @@
|
|
|
1
|
-
/** Render-neutral states
|
|
1
|
+
/** Render-neutral presentation states shared by Grammar components. */
|
|
2
2
|
export declare const PRESENTATION_STATES: readonly ["neutral", "informative", "affirmative", "cautionary", "negative", "pending", "unavailable"];
|
|
3
3
|
export type PresentationState = (typeof PRESENTATION_STATES)[number];
|
|
4
4
|
export declare const isPresentationState: (value: unknown) => value is PresentationState;
|
|
5
5
|
export declare const assertPresentationState: (value: unknown) => asserts value is PresentationState;
|
|
6
|
-
/** Package-owned component tiers. The spelling matches the public export topology. */
|
|
7
|
-
export type GrammarLayer = "leaves" | "branch" | "composites";
|
|
8
|
-
/** Contract boundaries that an extension can never reopen. */
|
|
9
|
-
export type ClosedContractChange = "anatomy" | "closed-invariant" | "owner-substitution";
|
|
10
|
-
/** The only dimensions on which a derived Grammar may supply values. */
|
|
11
|
-
export type GrammarExtensionPolicy<Axis extends string = string> = Readonly<{
|
|
12
|
-
allowedAxes: ReadonlyArray<Axis>;
|
|
13
|
-
forbiddenChanges: ReadonlyArray<ClosedContractChange>;
|
|
14
|
-
}>;
|
|
15
|
-
/** Business-neutral reusable owner contract. Additional package metadata must remain data-only. */
|
|
16
|
-
export type GrammarContractSpec<Axis extends string = string> = Readonly<{
|
|
17
|
-
version: string;
|
|
18
|
-
layer: GrammarLayer;
|
|
19
|
-
slots: ReadonlyArray<string>;
|
|
20
|
-
stateInputs: ReadonlyArray<string>;
|
|
21
|
-
variableAxes: ReadonlyArray<Axis>;
|
|
22
|
-
extensionPolicy: GrammarExtensionPolicy<Axis>;
|
|
23
|
-
closedInvariants: ReadonlyArray<string>;
|
|
24
|
-
}>;
|
|
25
|
-
/** One declared derivation. Every value key must have a matching requested axis. */
|
|
26
|
-
export type GrammarContractExtension<Axis extends string = string> = Readonly<{
|
|
27
|
-
id: string;
|
|
28
|
-
version: string;
|
|
29
|
-
base: Readonly<{
|
|
30
|
-
key: string;
|
|
31
|
-
version: string;
|
|
32
|
-
}>;
|
|
33
|
-
axes: ReadonlyArray<Axis>;
|
|
34
|
-
values: Readonly<Record<Axis, unknown>>;
|
|
35
|
-
}>;
|
|
36
|
-
/** Immutable provenance for a contract derived from another contract. */
|
|
37
|
-
export type GrammarContractBase = Readonly<{
|
|
38
|
-
key: string;
|
|
39
|
-
version: string;
|
|
40
|
-
rootKey: string;
|
|
41
|
-
rootVersion: string;
|
|
42
|
-
}>;
|
|
43
|
-
/** A closed, runtime-validated contract value. */
|
|
44
|
-
export type GrammarContract<Key extends string = string, Spec extends GrammarContractSpec = GrammarContractSpec> = Readonly<{
|
|
45
|
-
key: Key;
|
|
46
|
-
version: string;
|
|
47
|
-
spec: Readonly<Spec>;
|
|
48
|
-
base: GrammarContractBase | null;
|
|
49
|
-
resolvedAxes: Readonly<Record<string, unknown>>;
|
|
50
|
-
}>;
|
|
51
|
-
/** Stable refusal identities for callers and tests. */
|
|
52
|
-
export type GrammarContractErrorCode = "invalid-key" | "invalid-version" | "invalid-spec" | "duplicate-entry" | "allowed-axis-not-variable" | "duplicate-contract-key" | "missing-base-contract" | "same-extension-key" | "extension-id-mismatch" | "extension-base-mismatch" | "axis-not-allowed" | "axis-already-resolved" | "missing-axis-value" | "undeclared-axis-value" | "cyclic-value" | "unsupported-value";
|
|
53
|
-
/** Fail-closed error emitted by every runtime guard in this module. */
|
|
54
|
-
export declare class GrammarContractError extends Error {
|
|
55
|
-
readonly code: GrammarContractErrorCode;
|
|
56
|
-
constructor(code: GrammarContractErrorCode, message: string);
|
|
57
|
-
}
|
|
58
|
-
/** Define one immutable base contract after validating its closed boundaries. */
|
|
59
|
-
export declare const defineGrammarContract: <const Key extends string, const Spec extends GrammarContractSpec>(key: Key, spec: Spec) => GrammarContract<Key, Spec>;
|
|
60
|
-
/** Derive a contract by resolving declared axes without changing its base anatomy or invariants. */
|
|
61
|
-
export declare const extendGrammarContract: <const Key extends string, Spec extends GrammarContractSpec, Axis extends string>(key: Key, base: GrammarContract<string, Spec>, extension: GrammarContractExtension<Axis>) => GrammarContract<Key, Spec>;
|
|
62
|
-
/** Typed in-memory registry used by each Grammar bundle while it assembles its public contracts. */
|
|
63
|
-
export type GrammarContractRegistry<Spec extends GrammarContractSpec> = Readonly<{
|
|
64
|
-
define: <const Key extends string, const Input extends Spec>(key: Key, spec: Input) => GrammarContract<Key, Input>;
|
|
65
|
-
extend: <const Key extends string, Axis extends string>(key: Key, baseKey: string, extension: GrammarContractExtension<Axis>) => GrammarContract<Key, Spec>;
|
|
66
|
-
register: <const Key extends string, const Input extends Spec>(contract: GrammarContract<Key, Input>) => GrammarContract<Key, Input>;
|
|
67
|
-
get: (key: string) => GrammarContract<string, Spec> | undefined;
|
|
68
|
-
require: (key: string) => GrammarContract<string, Spec>;
|
|
69
|
-
has: (key: string) => boolean;
|
|
70
|
-
entries: () => ReadonlyArray<GrammarContract<string, Spec>>;
|
|
71
|
-
}>;
|
|
72
|
-
/** Create an isolated fail-closed registry. Duplicate keys never replace an earlier contract. */
|
|
73
|
-
export declare const createContractRegistry: <Spec extends GrammarContractSpec>() => GrammarContractRegistry<Spec>;
|
|
74
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,wGAEtB,CAAA;AACV,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEpE,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,iBAE7D,CAAA;AACD,eAAO,MAAM,uBAAuB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,KAAK,IAAI,iBAE1E,CAAA"}
|
package/dist/common/index.js
CHANGED
|
@@ -1,203 +1,11 @@
|
|
|
1
|
-
/** Render-neutral states
|
|
1
|
+
/** Render-neutral presentation states shared by Grammar components. */
|
|
2
2
|
export const PRESENTATION_STATES = [
|
|
3
|
-
"neutral",
|
|
4
|
-
"informative",
|
|
5
|
-
"affirmative",
|
|
6
|
-
"cautionary",
|
|
7
|
-
"negative",
|
|
8
|
-
"pending",
|
|
9
|
-
"unavailable",
|
|
3
|
+
"neutral", "informative", "affirmative", "cautionary", "negative", "pending", "unavailable",
|
|
10
4
|
];
|
|
11
|
-
const
|
|
12
|
-
export const isPresentationState = (value) => (typeof value === "string" &&
|
|
5
|
+
const stateSet = new Set(PRESENTATION_STATES);
|
|
6
|
+
export const isPresentationState = (value) => (typeof value === "string" && stateSet.has(value));
|
|
13
7
|
export const assertPresentationState = (value) => {
|
|
14
8
|
if (!isPresentationState(value))
|
|
15
|
-
throw new TypeError(`Unknown
|
|
16
|
-
};
|
|
17
|
-
/** Fail-closed error emitted by every runtime guard in this module. */
|
|
18
|
-
export class GrammarContractError extends Error {
|
|
19
|
-
code;
|
|
20
|
-
constructor(code, message) {
|
|
21
|
-
super(message);
|
|
22
|
-
this.name = "GrammarContractError";
|
|
23
|
-
this.code = code;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const stableKeyPattern = /^[a-z0-9]+(?:[./-][a-z0-9]+)*$/;
|
|
27
|
-
const exactVersionPattern = /^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?$/;
|
|
28
|
-
const requiredForbiddenChanges = [
|
|
29
|
-
"anatomy",
|
|
30
|
-
"closed-invariant",
|
|
31
|
-
"owner-substitution",
|
|
32
|
-
];
|
|
33
|
-
const fail = (code, message) => {
|
|
34
|
-
throw new GrammarContractError(code, message);
|
|
35
|
-
};
|
|
36
|
-
const validateStableKey = (value, label) => {
|
|
37
|
-
if (!stableKeyPattern.test(value))
|
|
38
|
-
fail("invalid-key", `${label} must be a stable lowercase key: ${value}`);
|
|
39
|
-
};
|
|
40
|
-
const validateExactVersion = (value, label) => {
|
|
41
|
-
if (!exactVersionPattern.test(value)) {
|
|
42
|
-
fail("invalid-version", `${label} must be one exact semantic version: ${value}`);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const validateStringSet = (values, label) => {
|
|
46
|
-
if (!Array.isArray(values))
|
|
47
|
-
fail("invalid-spec", `${label} must be an array`);
|
|
48
|
-
const seen = new Set();
|
|
49
|
-
for (const value of values) {
|
|
50
|
-
if (typeof value !== "string" || value.length === 0 || value.trim() !== value) {
|
|
51
|
-
fail("invalid-spec", `${label} contains an empty or untrimmed value`);
|
|
52
|
-
}
|
|
53
|
-
validateStableKey(value, label);
|
|
54
|
-
if (seen.has(value))
|
|
55
|
-
fail("duplicate-entry", `${label} contains duplicate value: ${value}`);
|
|
56
|
-
seen.add(value);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const cloneClosed = (value, path, ancestors) => {
|
|
60
|
-
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean")
|
|
61
|
-
return value;
|
|
62
|
-
if (Array.isArray(value)) {
|
|
63
|
-
if (ancestors.has(value))
|
|
64
|
-
fail("cyclic-value", `${path} contains a cycle`);
|
|
65
|
-
ancestors.add(value);
|
|
66
|
-
const copy = value.map((item, index) => cloneClosed(item, `${path}[${index}]`, ancestors));
|
|
67
|
-
ancestors.delete(value);
|
|
68
|
-
return Object.freeze(copy);
|
|
69
|
-
}
|
|
70
|
-
if (typeof value === "object") {
|
|
71
|
-
if (ancestors.has(value))
|
|
72
|
-
fail("cyclic-value", `${path} contains a cycle`);
|
|
73
|
-
const prototype = Object.getPrototypeOf(value);
|
|
74
|
-
if (prototype !== Object.prototype && prototype !== null) {
|
|
75
|
-
fail("unsupported-value", `${path} must contain only plain data`);
|
|
76
|
-
}
|
|
77
|
-
ancestors.add(value);
|
|
78
|
-
const copy = {};
|
|
79
|
-
for (const [key, child] of Object.entries(value))
|
|
80
|
-
copy[key] = cloneClosed(child, `${path}.${key}`, ancestors);
|
|
81
|
-
ancestors.delete(value);
|
|
82
|
-
return Object.freeze(copy);
|
|
83
|
-
}
|
|
84
|
-
return fail("unsupported-value", `${path} contains unsupported ${typeof value}`);
|
|
85
|
-
};
|
|
86
|
-
const closedCopy = (value, path) => cloneClosed(value, path, new WeakSet());
|
|
87
|
-
const validateSpec = (spec) => {
|
|
88
|
-
if (spec === null || typeof spec !== "object")
|
|
89
|
-
fail("invalid-spec", "contract spec must be an object");
|
|
90
|
-
validateExactVersion(spec.version, "contract version");
|
|
91
|
-
if (!["leaves", "branch", "composites"].includes(spec.layer)) {
|
|
92
|
-
fail("invalid-spec", `unsupported Grammar layer: ${String(spec.layer)}`);
|
|
93
|
-
}
|
|
94
|
-
validateStringSet(spec.slots, "slots");
|
|
95
|
-
validateStringSet(spec.stateInputs, "stateInputs");
|
|
96
|
-
validateStringSet(spec.variableAxes, "variableAxes");
|
|
97
|
-
if (spec.extensionPolicy === null || typeof spec.extensionPolicy !== "object") {
|
|
98
|
-
fail("invalid-spec", "extensionPolicy must be an object");
|
|
99
|
-
}
|
|
100
|
-
validateStringSet(spec.extensionPolicy.allowedAxes, "extensionPolicy.allowedAxes");
|
|
101
|
-
validateStringSet(spec.extensionPolicy.forbiddenChanges, "extensionPolicy.forbiddenChanges");
|
|
102
|
-
validateStringSet(spec.closedInvariants, "closedInvariants");
|
|
103
|
-
const variableAxes = new Set(spec.variableAxes);
|
|
104
|
-
for (const axis of spec.extensionPolicy.allowedAxes) {
|
|
105
|
-
if (!variableAxes.has(axis)) {
|
|
106
|
-
fail("allowed-axis-not-variable", `allowed extension axis is not a variable axis: ${axis}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
for (const change of requiredForbiddenChanges) {
|
|
110
|
-
if (!spec.extensionPolicy.forbiddenChanges.includes(change)) {
|
|
111
|
-
fail("invalid-spec", `extensionPolicy.forbiddenChanges must include ${change}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
/** Define one immutable base contract after validating its closed boundaries. */
|
|
116
|
-
export const defineGrammarContract = (key, spec) => {
|
|
117
|
-
validateStableKey(key, "contract key");
|
|
118
|
-
validateSpec(spec);
|
|
119
|
-
return Object.freeze({
|
|
120
|
-
key,
|
|
121
|
-
version: spec.version,
|
|
122
|
-
spec: closedCopy(spec, `contract ${key}`),
|
|
123
|
-
base: null,
|
|
124
|
-
resolvedAxes: Object.freeze({}),
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
/** Derive a contract by resolving declared axes without changing its base anatomy or invariants. */
|
|
128
|
-
export const extendGrammarContract = (key, base, extension) => {
|
|
129
|
-
validateStableKey(key, "extension key");
|
|
130
|
-
validateStableKey(extension.id, "extension id");
|
|
131
|
-
validateExactVersion(extension.version, "extension version");
|
|
132
|
-
validateStableKey(extension.base.key, "extension base key");
|
|
133
|
-
validateExactVersion(extension.base.version, "extension base version");
|
|
134
|
-
if (key === base.key)
|
|
135
|
-
fail("same-extension-key", `extension key must differ from base key: ${key}`);
|
|
136
|
-
if (extension.id !== key) {
|
|
137
|
-
fail("extension-id-mismatch", `extension id ${extension.id} does not match registered key ${key}`);
|
|
138
|
-
}
|
|
139
|
-
if (extension.base.key !== base.key || extension.base.version !== base.version) {
|
|
140
|
-
fail("extension-base-mismatch", `extension base ${extension.base.key}@${extension.base.version} does not match ${base.key}@${base.version}`);
|
|
141
|
-
}
|
|
142
|
-
validateStringSet(extension.axes, "extension.axes");
|
|
143
|
-
if (extension.values === null || typeof extension.values !== "object" || Array.isArray(extension.values)) {
|
|
144
|
-
fail("invalid-spec", "extension.values must be an object");
|
|
145
|
-
}
|
|
146
|
-
const requested = new Set(extension.axes);
|
|
147
|
-
const allowed = new Set(base.spec.extensionPolicy.allowedAxes);
|
|
148
|
-
for (const axis of extension.axes) {
|
|
149
|
-
if (!allowed.has(axis))
|
|
150
|
-
fail("axis-not-allowed", `extension axis is closed: ${axis}`);
|
|
151
|
-
if (Object.hasOwn(base.resolvedAxes, axis)) {
|
|
152
|
-
fail("axis-already-resolved", `extension axis is already resolved: ${axis}`);
|
|
153
|
-
}
|
|
154
|
-
if (!Object.hasOwn(extension.values, axis))
|
|
155
|
-
fail("missing-axis-value", `extension axis has no value: ${axis}`);
|
|
156
|
-
}
|
|
157
|
-
for (const axis of Object.keys(extension.values)) {
|
|
158
|
-
if (!requested.has(axis))
|
|
159
|
-
fail("undeclared-axis-value", `extension value has no declared axis: ${axis}`);
|
|
160
|
-
}
|
|
161
|
-
const values = closedCopy(extension.values, `extension ${key}`);
|
|
162
|
-
const baseRef = Object.freeze({
|
|
163
|
-
key: base.key,
|
|
164
|
-
version: base.version,
|
|
165
|
-
rootKey: base.base?.rootKey ?? base.key,
|
|
166
|
-
rootVersion: base.base?.rootVersion ?? base.version,
|
|
167
|
-
});
|
|
168
|
-
return Object.freeze({
|
|
169
|
-
key,
|
|
170
|
-
version: extension.version,
|
|
171
|
-
spec: base.spec,
|
|
172
|
-
base: baseRef,
|
|
173
|
-
resolvedAxes: Object.freeze({ ...base.resolvedAxes, ...values }),
|
|
174
|
-
});
|
|
175
|
-
};
|
|
176
|
-
/** Create an isolated fail-closed registry. Duplicate keys never replace an earlier contract. */
|
|
177
|
-
export const createContractRegistry = () => {
|
|
178
|
-
const contracts = new Map();
|
|
179
|
-
const register = (contract) => {
|
|
180
|
-
if (contracts.has(contract.key)) {
|
|
181
|
-
fail("duplicate-contract-key", `contract key is already registered: ${contract.key}`);
|
|
182
|
-
}
|
|
183
|
-
contracts.set(contract.key, contract);
|
|
184
|
-
return contract;
|
|
185
|
-
};
|
|
186
|
-
const requireContract = (key) => {
|
|
187
|
-
const contract = contracts.get(key);
|
|
188
|
-
if (contract === undefined) {
|
|
189
|
-
return fail("missing-base-contract", `contract key is not registered: ${key}`);
|
|
190
|
-
}
|
|
191
|
-
return contract;
|
|
192
|
-
};
|
|
193
|
-
return Object.freeze({
|
|
194
|
-
define: (key, spec) => (register(defineGrammarContract(key, spec))),
|
|
195
|
-
extend: (key, baseKey, extension) => register(extendGrammarContract(key, requireContract(baseKey), extension)),
|
|
196
|
-
register,
|
|
197
|
-
get: (key) => contracts.get(key),
|
|
198
|
-
require: requireContract,
|
|
199
|
-
has: (key) => contracts.has(key),
|
|
200
|
-
entries: () => Object.freeze(Array.from(contracts.values())),
|
|
201
|
-
});
|
|
9
|
+
throw new TypeError(`Unknown presentation state: ${JSON.stringify(value)}`);
|
|
202
10
|
};
|
|
203
11
|
//# sourceMappingURL=index.js.map
|
package/dist/common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa;CACrF,CAAA;AAEV,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAA8B,EAAE,CAAC,CAC/E,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CACnD,CAAA;AACD,MAAM,CAAC,MAAM,uBAAuB,GAA2D,CAAC,KAAK,EAAE,EAAE;IACrG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,+BAA+B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AAChH,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type LeadingNumberProps = {
|
|
2
|
+
/** One-based position of the item inside its authored sequence. */
|
|
3
|
+
readonly position: number;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Product-neutral ordinal prefix for readable ordered rows.
|
|
7
|
+
*
|
|
8
|
+
* The punctuation and treatment are intentionally closed: an ordinal prefix is
|
|
9
|
+
* quiet reading structure (`1.`), never a badge, chip, status, or decoration.
|
|
10
|
+
*/
|
|
11
|
+
export declare const LeadingNumber: (props: LeadingNumberProps) => import("react").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=LeadingNumber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LeadingNumber.d.ts","sourceRoot":"","sources":["../../src/core/LeadingNumber.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC5B,CAAA;AAID;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,kBAAkB,gCAMtD,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { leadingNumberClassName } from "./classNames.js";
|
|
3
|
+
/**
|
|
4
|
+
* Product-neutral ordinal prefix for readable ordered rows.
|
|
5
|
+
*
|
|
6
|
+
* The punctuation and treatment are intentionally closed: an ordinal prefix is
|
|
7
|
+
* quiet reading structure (`1.`), never a badge, chip, status, or decoration.
|
|
8
|
+
*/
|
|
9
|
+
export const LeadingNumber = (props) => (_jsxs("span", { className: leadingNumberClassName, children: [props.position, "."] }));
|
|
10
|
+
//# sourceMappingURL=LeadingNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LeadingNumber.js","sourceRoot":"","sources":["../../src/core/LeadingNumber.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAExD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAyB,EAAE,EAAE,CAAC,CACxD,gBACI,SAAS,EAAE,sBAAsB,aAEhC,KAAK,CAAC,QAAQ,SACZ,CACV,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type OtpInputProps = {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly defaultValue?: string;
|
|
5
|
+
readonly disabled?: boolean;
|
|
6
|
+
readonly invalid?: boolean;
|
|
7
|
+
readonly describedBy?: string;
|
|
8
|
+
readonly onChange?: (value: string) => void;
|
|
9
|
+
};
|
|
10
|
+
/** Own the conventional six-digit OTP control and its intrinsic-width overflow treatment. */
|
|
11
|
+
export declare const OtpInput: (props: OtpInputProps) => import("react").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=OtpInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OtpInput.d.ts","sourceRoot":"","sources":["../../src/core/OtpInput.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM,aAAa,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9C,CAAA;AAED,6FAA6F;AAC7F,eAAO,MAAM,QAAQ,GAAI,OAAO,aAAa,gCAqC5C,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useRef } from "react";
|
|
3
|
+
import { InputOTP, REGEXP_ONLY_DIGITS } from "@heroui/react";
|
|
4
|
+
import { horizontalScrollRegionClassName } from "./classNames.js";
|
|
5
|
+
import { HorizontalScrollRegion } from "./composite/HorizontalScrollRegion/index.js";
|
|
6
|
+
/** Own the conventional six-digit OTP control and its intrinsic-width overflow treatment. */
|
|
7
|
+
export const OtpInput = (props) => {
|
|
8
|
+
const regionRef = useRef(null);
|
|
9
|
+
const onChange = useCallback((nextValue) => {
|
|
10
|
+
props.onChange?.(nextValue);
|
|
11
|
+
window.requestAnimationFrame(() => {
|
|
12
|
+
const slots = regionRef.current?.querySelectorAll("[data-slot='input-otp-slot']");
|
|
13
|
+
if (!slots?.length)
|
|
14
|
+
return;
|
|
15
|
+
const activeIndex = Math.min(nextValue.length, slots.length - 1);
|
|
16
|
+
slots.item(activeIndex).scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
17
|
+
});
|
|
18
|
+
}, [props.onChange]);
|
|
19
|
+
return (_jsx(HorizontalScrollRegion, { ref: regionRef, className: horizontalScrollRegionClassName, children: _jsx(InputOTP, { id: props.id, name: props.name, maxLength: 6, pattern: REGEXP_ONLY_DIGITS, autoComplete: "one-time-code", inputMode: "numeric", defaultValue: props.defaultValue, isDisabled: props.disabled === true, isInvalid: props.invalid === true, "aria-invalid": props.invalid === true ? true : undefined, "aria-describedby": props.describedBy, variant: "secondary", onChange: onChange, children: _jsx(InputOTP.Group, { children: Array.from({ length: 6 }, (_, index) => (_jsx(InputOTP.Slot, { index: index }, index))) }) }) }));
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=OtpInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OtpInput.js","sourceRoot":"","sources":["../../src/core/OtpInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAA;AAYpF,6FAA6F;AAC7F,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAE,EAAE;IAC7C,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,SAAiB,EAAE,EAAE;QAC/C,KAAK,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAA;QAC3B,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE;YAC9B,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,EAAE,gBAAgB,CAAc,8BAA8B,CAAC,CAAA;YAC9F,IAAI,CAAC,KAAK,EAAE,MAAM;gBAAE,OAAM;YAC1B,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;YAChE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAA;QACnF,CAAC,CAAC,CAAA;IACN,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;IAEpB,OAAO,CACH,KAAC,sBAAsB,IAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,+BAA+B,YAC9E,KAAC,QAAQ,IACL,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,SAAS,EAAE,CAAC,EACZ,OAAO,EAAE,kBAAkB,EAC3B,YAAY,EAAC,eAAe,EAC5B,SAAS,EAAC,SAAS,EACnB,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,UAAU,EAAE,KAAK,CAAC,QAAQ,KAAK,IAAI,EACnC,SAAS,EAAE,KAAK,CAAC,OAAO,KAAK,IAAI,kBACnB,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,sBACrC,KAAK,CAAC,WAAW,EACnC,OAAO,EAAC,WAAW,EACnB,QAAQ,EAAE,QAAQ,YAElB,KAAC,QAAQ,CAAC,KAAK,cACV,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CACrC,KAAC,QAAQ,CAAC,IAAI,IAAa,KAAK,EAAE,KAAK,IAAnB,KAAK,CAAkB,CAC9C,CAAC,GACW,GACV,GACU,CAC5B,CAAA;AACL,CAAC,CAAA"}
|
package/dist/core/StateMark.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { PresentationState } from "./state.js";
|
|
2
|
+
/** Props for the neutral state mark. */
|
|
2
3
|
export type StateMarkProps = {
|
|
3
4
|
readonly state: PresentationState;
|
|
4
5
|
};
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
readonly shape: "leaf";
|
|
8
|
-
readonly grammar: "core";
|
|
9
|
-
};
|
|
6
|
+
/** Draw the check mark used by successful neutral states. */
|
|
7
|
+
export declare const StateMark: (props: StateMarkProps) => import("react").JSX.Element | null;
|
|
10
8
|
//# sourceMappingURL=StateMark.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateMark.d.ts","sourceRoot":"","sources":["../../src/core/StateMark.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAGnD,MAAM,MAAM,cAAc,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,
|
|
1
|
+
{"version":3,"file":"StateMark.d.ts","sourceRoot":"","sources":["../../src/core/StateMark.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAGnD,wCAAwC;AACxC,MAAM,MAAM,cAAc,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAA;CACpC,CAAA;AAED,6DAA6D;AAC7D,eAAO,MAAM,SAAS,GAAI,OAAO,cAAc,uCAc9C,CAAA"}
|
package/dist/core/StateMark.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { treatmentFor } from "./state.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/** Draw the check mark used by successful neutral states. */
|
|
4
|
+
export const StateMark = (props) => {
|
|
5
|
+
const treatment = treatmentFor(props.state);
|
|
5
6
|
if (treatment.mark !== "check")
|
|
6
7
|
return null;
|
|
7
8
|
return (_jsx("svg", { "aria-hidden": "true", "data-grammar-state-mark": "check", focusable: "false", viewBox: "0 0 20 20", children: _jsx("path", { d: "M5 10.5 8.25 14 15 6.5", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2" }) }));
|
|
8
9
|
};
|
|
9
|
-
export const meta = { shape: "leaf", grammar: "core" };
|
|
10
10
|
//# sourceMappingURL=StateMark.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateMark.js","sourceRoot":"","sources":["../../src/core/StateMark.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"StateMark.js","sourceRoot":"","sources":["../../src/core/StateMark.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAOzC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,EAAE;IAC/C,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAC3C,IAAI,SAAS,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,IAAI,CAAA;IAE3C,OAAO,CACH,6BACgB,MAAM,6BACM,OAAO,EAC/B,SAAS,EAAC,OAAO,EACjB,OAAO,EAAC,WAAW,YAEnB,eAAM,CAAC,EAAC,wBAAwB,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAC,WAAW,EAAC,GAAG,GAAG,GAChI,CACT,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Identifies the readable Markdown document frame. */
|
|
2
|
+
export declare const markdownArticleClassName: import("tailwind-variants").CnReturn;
|
|
3
|
+
/** Identifies a bounded fenced-code frame. */
|
|
4
|
+
export declare const fencedCodeBlockClassName: import("tailwind-variants").CnReturn;
|
|
5
|
+
/** Identifies the optional fenced-code header. */
|
|
6
|
+
export declare const fencedCodeHeaderClassName: import("tailwind-variants").CnReturn;
|
|
7
|
+
/** Identifies the bounded table overflow frame. */
|
|
8
|
+
export declare const markdownTableFrameClassName: import("tailwind-variants").CnReturn;
|
|
9
|
+
//# sourceMappingURL=classNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.d.ts","sourceRoot":"","sources":["../../../../src/core/branch/MarkdownArticle/classNames.ts"],"names":[],"mappings":"AAEA,uDAAuD;AACvD,eAAO,MAAM,wBAAwB,sCAA0B,CAAA;AAC/D,8CAA8C;AAC9C,eAAO,MAAM,wBAAwB,sCAAiC,CAAA;AACtE,kDAAkD;AAClD,eAAO,MAAM,yBAAyB,sCAAgD,CAAA;AACtF,mDAAmD;AACnD,eAAO,MAAM,2BAA2B,sCAAiC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { cn } from "@heroui/react";
|
|
2
|
+
/** Identifies the readable Markdown document frame. */
|
|
3
|
+
export const markdownArticleClassName = cn("min-w-0", "w-full");
|
|
4
|
+
/** Identifies a bounded fenced-code frame. */
|
|
5
|
+
export const fencedCodeBlockClassName = cn("min-w-0", "overflow-auto");
|
|
6
|
+
/** Identifies the optional fenced-code header. */
|
|
7
|
+
export const fencedCodeHeaderClassName = cn("flex", "items-center", "justify-between");
|
|
8
|
+
/** Identifies the bounded table overflow frame. */
|
|
9
|
+
export const markdownTableFrameClassName = cn("min-w-0", "overflow-auto");
|
|
10
|
+
//# sourceMappingURL=classNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.js","sourceRoot":"","sources":["../../../../src/core/branch/MarkdownArticle/classNames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAElC,uDAAuD;AACvD,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;AAC/D,8CAA8C;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;AACtE,kDAAkD;AAClD,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,iBAAiB,CAAC,CAAA;AACtF,mDAAmD;AACnD,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type MarkdownArticleProps = {
|
|
3
|
+
readonly children: ReactNode;
|
|
4
|
+
readonly ariaLabel?: string;
|
|
5
|
+
readonly measure?: "reading" | "compact";
|
|
6
|
+
};
|
|
7
|
+
type FencedCodeBlockFrameProps = {
|
|
8
|
+
readonly language?: string;
|
|
9
|
+
readonly action?: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
type AuthoredCodeProps = {
|
|
12
|
+
readonly code: string;
|
|
13
|
+
readonly children?: never;
|
|
14
|
+
};
|
|
15
|
+
type RenderedCodeProps = {
|
|
16
|
+
readonly children: ReactNode;
|
|
17
|
+
readonly code?: never;
|
|
18
|
+
};
|
|
19
|
+
export type FencedCodeBlockProps = FencedCodeBlockFrameProps & (AuthoredCodeProps | RenderedCodeProps);
|
|
20
|
+
export type MarkdownTableFrameProps = {
|
|
21
|
+
readonly children: ReactNode;
|
|
22
|
+
};
|
|
23
|
+
/** Own the business-neutral reading rhythm for one semantic Markdown document. */
|
|
24
|
+
export declare const MarkdownArticle: (props: MarkdownArticleProps) => import("react").JSX.Element;
|
|
25
|
+
/** Own bounded code overflow while allowing a caller-supplied neutral action such as Copy. */
|
|
26
|
+
export declare const FencedCodeBlock: (props: FencedCodeBlockProps) => import("react").JSX.Element;
|
|
27
|
+
/** Keep a vendor-rendered table inside the same bounded reading frame as semantic tables. */
|
|
28
|
+
export declare const MarkdownTableFrame: (props: MarkdownTableFrameProps) => import("react").JSX.Element;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/branch/MarkdownArticle/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,MAAM,MAAM,oBAAoB,GAAG;IAC/B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAC3C,CAAA;AAED,KAAK,yBAAyB,GAAG;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAA;CAC9B,CAAA;AAED,KAAK,iBAAiB,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAC5B,CAAA;AAED,KAAK,iBAAiB,GAAG;IACrB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,CAAA;AAEtG,MAAM,MAAM,uBAAuB,GAAG;IAClC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAC/B,CAAA;AAED,kFAAkF;AAClF,eAAO,MAAM,eAAe,GAAI,OAAO,oBAAoB,gCAQ1D,CAAA;AAED,8FAA8F;AAC9F,eAAO,MAAM,eAAe,GAAI,OAAO,oBAAoB,gCAe1D,CAAA;AAED,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,GAAI,OAAO,uBAAuB,gCAMhE,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { fencedCodeBlockClassName, fencedCodeHeaderClassName, markdownArticleClassName, markdownTableFrameClassName } from "./classNames.js";
|
|
3
|
+
/** Own the business-neutral reading rhythm for one semantic Markdown document. */
|
|
4
|
+
export const MarkdownArticle = (props) => (_jsx("div", { "aria-label": props.ariaLabel, className: markdownArticleClassName, "data-grammar-markdown-measure": props.measure ?? "reading", children: props.children }));
|
|
5
|
+
/** Own bounded code overflow while allowing a caller-supplied neutral action such as Copy. */
|
|
6
|
+
export const FencedCodeBlock = (props) => {
|
|
7
|
+
const body = "children" in props ? props.children : _jsx("pre", { children: _jsx("code", { children: props.code }) });
|
|
8
|
+
return (_jsxs("div", { className: fencedCodeBlockClassName, children: [props.language === undefined && props.action === undefined ? null : (_jsxs("div", { className: fencedCodeHeaderClassName, children: [props.language === undefined ? _jsx("span", {}) : _jsx("span", { children: props.language }), props.action] })), body] }));
|
|
9
|
+
};
|
|
10
|
+
/** Keep a vendor-rendered table inside the same bounded reading frame as semantic tables. */
|
|
11
|
+
export const MarkdownTableFrame = (props) => (_jsx("div", { className: markdownTableFrameClassName, children: props.children }));
|
|
12
|
+
//# sourceMappingURL=index.js.map
|