@qti-components/base 1.5.1 → 2.0.1
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/dist/abstract/interaction.d.ts +65 -64
- package/dist/abstract/interaction.js +114 -276
- package/dist/abstract/interaction.js.map +1 -1
- package/dist/abstract/qti-expression.d.ts +1 -1
- package/dist/abstract/qti-expression.js +23 -2
- package/dist/abstract/qti-expression.js.map +1 -1
- package/dist/abstract/qti-feedback.js +1 -1
- package/dist/abstract/qti-feedback.js.map +1 -1
- package/dist/context/computed-item.context.d.ts +1 -16
- package/dist/context/computed-item.context.js.map +1 -1
- package/dist/context/computed.context.d.ts +1 -26
- package/dist/context/computed.context.js.map +1 -1
- package/dist/context/config.context.d.ts +61 -12
- package/dist/context/config.context.js.map +1 -1
- package/dist/context/interaction.context.d.ts +36 -0
- package/dist/context/interaction.context.js +3 -0
- package/dist/context/interaction.context.js.map +1 -0
- package/dist/context/item.context.d.ts +4 -12
- package/dist/context/item.context.js +2 -16
- package/dist/context/item.context.js.map +1 -1
- package/dist/context/test.context.d.ts +1 -1
- package/dist/context/test.context.js.map +1 -1
- package/dist/context/types/computed-item.types.d.ts +16 -0
- package/dist/context/types/computed-item.types.js +2 -0
- package/dist/context/types/computed-item.types.js.map +1 -0
- package/dist/context/types/computed.types.d.ts +28 -0
- package/dist/context/types/computed.types.js +2 -0
- package/dist/context/types/computed.types.js.map +1 -0
- package/dist/context/types/item.types.d.ts +12 -0
- package/dist/context/types/item.types.js +17 -0
- package/dist/context/types/item.types.js.map +1 -0
- package/dist/elements.d.ts +24 -0
- package/dist/elements.js +22 -0
- package/dist/elements.js.map +1 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/interaction.interface.d.ts +39 -15
- package/dist/lib/interaction.interface.js.map +1 -1
- package/dist/lib/response.d.ts +104 -0
- package/dist/lib/response.js +168 -0
- package/dist/lib/response.js.map +1 -0
- package/dist/register.d.ts +1 -0
- package/dist/register.js +7 -0
- package/dist/register.js.map +1 -0
- package/dist/styles/box-sizing.styles.d.ts +19 -0
- package/dist/styles/box-sizing.styles.js +31 -0
- package/dist/styles/box-sizing.styles.js.map +1 -0
- package/dist/styles/drop-region.styles.d.ts +36 -0
- package/dist/styles/drop-region.styles.js +78 -0
- package/dist/styles/drop-region.styles.js.map +1 -0
- package/dist/styles/validation-message.styles.d.ts +18 -0
- package/dist/styles/validation-message.styles.js +24 -0
- package/dist/styles/validation-message.styles.js.map +1 -0
- package/package.json +16 -1
- package/dist/context/qti-assessment-item.context.d.ts +0 -4
- package/dist/context/qti-assessment-item.context.js +0 -3
- package/dist/context/qti-assessment-item.context.js.map +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `drop` region of every drop target.
|
|
3
|
+
*
|
|
4
|
+
* One rule: **a drop container hosts a chip, it never sizes one.** No `flex: 1`, no stretch, no
|
|
5
|
+
* centring. The chip's box is decided by the chip — in the drag bank, mid-flight as a clone, and
|
|
6
|
+
* once dropped — and a container that centres or stretches it makes the drop the one place where
|
|
7
|
+
* that stops being true. That is felt as the chip jumping the instant it lands.
|
|
8
|
+
*
|
|
9
|
+
* `flex: 0 1 auto` on the children says "intrinsic size, no growing, shrink if you must".
|
|
10
|
+
* `align-items: flex-start` stops the cross axis stretching them, which is the flex default and
|
|
11
|
+
* the reason a chip in a tall dropzone used to grow to fill it.
|
|
12
|
+
*
|
|
13
|
+
* The shrink half used to be 0 as well, on the reading that a drop must not resize a chip. It does
|
|
14
|
+
* not say that. `flex-shrink: 0` does not preserve the chip's size, it preserves the chip's
|
|
15
|
+
* UNCONSTRAINED max-content size — and those are the same number only while the bank is wide enough
|
|
16
|
+
* to give the chip its full width. Once the bank is narrower, the bank chip (`flex: 0 1 auto`, like
|
|
17
|
+
* any flex item) shrinks and wraps, the placed chip does not, and the two disagree.
|
|
18
|
+
*
|
|
19
|
+
* Measured on the order fixture, bank vs placed: 209x36 / 209x36 at a 480px interaction, but
|
|
20
|
+
* 204x55 / 209x36 at 440px and 154x55 / 209x36 at 340px — the placed chip a fixed 209px wide,
|
|
21
|
+
* overflowing a drop that had correctly reserved 156px for it. It reached CI as a font difference:
|
|
22
|
+
* the same label measures ~227px under the Linux fonts, which puts 480px on the wrong side of the
|
|
23
|
+
* boundary too.
|
|
24
|
+
*
|
|
25
|
+
* Shrinking cannot make a placed chip smaller than the reservation, because the reservation IS the
|
|
26
|
+
* measured chip (`--qti-dropzone-min-*`, applied to this region's content box). So the floor a
|
|
27
|
+
* shrink stops at is the chip's own size, which is the rule above, not an exception to it.
|
|
28
|
+
* `flex-grow: 0` is what actually prevents the stretch this block cares about, and it is untouched.
|
|
29
|
+
*
|
|
30
|
+
* A container that wants a *minimum* size still declares one (see `--qti-dropzone-min-*`). That
|
|
31
|
+
* sizes the container, never its contents.
|
|
32
|
+
*
|
|
33
|
+
* Verified by drag-drop.invariance.spec.ts: "a chip is the same chip wherever it lives" — including
|
|
34
|
+
* the narrow-bank order fixture, which is there because the wide one passes either way.
|
|
35
|
+
*/
|
|
36
|
+
export declare const dropRegion: import("lit").CSSResult;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* The `drop` region of every drop target.
|
|
4
|
+
*
|
|
5
|
+
* One rule: **a drop container hosts a chip, it never sizes one.** No `flex: 1`, no stretch, no
|
|
6
|
+
* centring. The chip's box is decided by the chip — in the drag bank, mid-flight as a clone, and
|
|
7
|
+
* once dropped — and a container that centres or stretches it makes the drop the one place where
|
|
8
|
+
* that stops being true. That is felt as the chip jumping the instant it lands.
|
|
9
|
+
*
|
|
10
|
+
* `flex: 0 1 auto` on the children says "intrinsic size, no growing, shrink if you must".
|
|
11
|
+
* `align-items: flex-start` stops the cross axis stretching them, which is the flex default and
|
|
12
|
+
* the reason a chip in a tall dropzone used to grow to fill it.
|
|
13
|
+
*
|
|
14
|
+
* The shrink half used to be 0 as well, on the reading that a drop must not resize a chip. It does
|
|
15
|
+
* not say that. `flex-shrink: 0` does not preserve the chip's size, it preserves the chip's
|
|
16
|
+
* UNCONSTRAINED max-content size — and those are the same number only while the bank is wide enough
|
|
17
|
+
* to give the chip its full width. Once the bank is narrower, the bank chip (`flex: 0 1 auto`, like
|
|
18
|
+
* any flex item) shrinks and wraps, the placed chip does not, and the two disagree.
|
|
19
|
+
*
|
|
20
|
+
* Measured on the order fixture, bank vs placed: 209x36 / 209x36 at a 480px interaction, but
|
|
21
|
+
* 204x55 / 209x36 at 440px and 154x55 / 209x36 at 340px — the placed chip a fixed 209px wide,
|
|
22
|
+
* overflowing a drop that had correctly reserved 156px for it. It reached CI as a font difference:
|
|
23
|
+
* the same label measures ~227px under the Linux fonts, which puts 480px on the wrong side of the
|
|
24
|
+
* boundary too.
|
|
25
|
+
*
|
|
26
|
+
* Shrinking cannot make a placed chip smaller than the reservation, because the reservation IS the
|
|
27
|
+
* measured chip (`--qti-dropzone-min-*`, applied to this region's content box). So the floor a
|
|
28
|
+
* shrink stops at is the chip's own size, which is the rule above, not an exception to it.
|
|
29
|
+
* `flex-grow: 0` is what actually prevents the stretch this block cares about, and it is untouched.
|
|
30
|
+
*
|
|
31
|
+
* A container that wants a *minimum* size still declares one (see `--qti-dropzone-min-*`). That
|
|
32
|
+
* sizes the container, never its contents.
|
|
33
|
+
*
|
|
34
|
+
* Verified by drag-drop.invariance.spec.ts: "a chip is the same chip wherever it lives" — including
|
|
35
|
+
* the narrow-bank order fixture, which is there because the wide one passes either way.
|
|
36
|
+
*/
|
|
37
|
+
export const dropRegion = css `
|
|
38
|
+
[part~='drop'] {
|
|
39
|
+
/*
|
|
40
|
+
* The one deliberate opt-out from the border-box reset.
|
|
41
|
+
*
|
|
42
|
+
* --qti-dropzone-min-* is the border-box of the largest chip, and what has to hold that chip is
|
|
43
|
+
* this region's *content* area. Under border-box a theme's dashed drop border is subtracted
|
|
44
|
+
* from the chip's own size, the content comes up short, and the drop grows the moment a chip
|
|
45
|
+
* lands in it. Order's drop did exactly that: 64px empty, 66px full, for a 1px border.
|
|
46
|
+
*/
|
|
47
|
+
box-sizing: content-box;
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
* No padding, and no token for one.
|
|
51
|
+
*
|
|
52
|
+
* A drop reserves --qti-dropzone-min-*, which is the chip's BORDER-box, as this region's CONTENT
|
|
53
|
+
* area — so the chip already fits exactly, with nothing to spare and nothing squeezed. An inset
|
|
54
|
+
* on top would only make the drop bigger than the thing it holds.
|
|
55
|
+
*
|
|
56
|
+
* There was a 1px one, to make the drop read as a frame a hair outside the chip. It never painted:
|
|
57
|
+
* an EMPTY slot has nothing inside the inset to separate from, and a FILLED one hides its edge
|
|
58
|
+
* (DROP-SIZING.md §4), so both states spent 2px on an invisible ring. The one drop that genuinely
|
|
59
|
+
* wants breathing room — match's category card — declares padding on its own rule, which a
|
|
60
|
+
* theme reaches with ::part(drop). A token in between bought nothing.
|
|
61
|
+
*/
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-wrap: wrap;
|
|
64
|
+
align-items: flex-start;
|
|
65
|
+
justify-content: flex-start;
|
|
66
|
+
/* No gap either: 0 is the flex initial value, so the declaration only existed to host a token.
|
|
67
|
+
A drop that wants space between chips sets gap on its own rule. */
|
|
68
|
+
/* Containing block for anything a theme draws over the drop. Was 'position: relative' in the
|
|
69
|
+
theme's 'drop' mixin, which put a document stylesheet in charge of a shadow node's position. */
|
|
70
|
+
position: relative;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
[part~='drop'] > * {
|
|
74
|
+
flex: 0 1 auto;
|
|
75
|
+
align-self: flex-start;
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
//# sourceMappingURL=drop-region.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-region.styles.js","sourceRoot":"","sources":["../../src/styles/drop-region.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwC5B,CAAC","sourcesContent":["import { css } from 'lit';\n\n/**\n * The `drop` region of every drop target.\n *\n * One rule: **a drop container hosts a chip, it never sizes one.** No `flex: 1`, no stretch, no\n * centring. The chip's box is decided by the chip — in the drag bank, mid-flight as a clone, and\n * once dropped — and a container that centres or stretches it makes the drop the one place where\n * that stops being true. That is felt as the chip jumping the instant it lands.\n *\n * `flex: 0 1 auto` on the children says \"intrinsic size, no growing, shrink if you must\".\n * `align-items: flex-start` stops the cross axis stretching them, which is the flex default and\n * the reason a chip in a tall dropzone used to grow to fill it.\n *\n * The shrink half used to be 0 as well, on the reading that a drop must not resize a chip. It does\n * not say that. `flex-shrink: 0` does not preserve the chip's size, it preserves the chip's\n * UNCONSTRAINED max-content size — and those are the same number only while the bank is wide enough\n * to give the chip its full width. Once the bank is narrower, the bank chip (`flex: 0 1 auto`, like\n * any flex item) shrinks and wraps, the placed chip does not, and the two disagree.\n *\n * Measured on the order fixture, bank vs placed: 209x36 / 209x36 at a 480px interaction, but\n * 204x55 / 209x36 at 440px and 154x55 / 209x36 at 340px — the placed chip a fixed 209px wide,\n * overflowing a drop that had correctly reserved 156px for it. It reached CI as a font difference:\n * the same label measures ~227px under the Linux fonts, which puts 480px on the wrong side of the\n * boundary too.\n *\n * Shrinking cannot make a placed chip smaller than the reservation, because the reservation IS the\n * measured chip (`--qti-dropzone-min-*`, applied to this region's content box). So the floor a\n * shrink stops at is the chip's own size, which is the rule above, not an exception to it.\n * `flex-grow: 0` is what actually prevents the stretch this block cares about, and it is untouched.\n *\n * A container that wants a *minimum* size still declares one (see `--qti-dropzone-min-*`). That\n * sizes the container, never its contents.\n *\n * Verified by drag-drop.invariance.spec.ts: \"a chip is the same chip wherever it lives\" — including\n * the narrow-bank order fixture, which is there because the wide one passes either way.\n */\nexport const dropRegion = css`\n [part~='drop'] {\n /*\n * The one deliberate opt-out from the border-box reset.\n *\n * --qti-dropzone-min-* is the border-box of the largest chip, and what has to hold that chip is\n * this region's *content* area. Under border-box a theme's dashed drop border is subtracted\n * from the chip's own size, the content comes up short, and the drop grows the moment a chip\n * lands in it. Order's drop did exactly that: 64px empty, 66px full, for a 1px border.\n */\n box-sizing: content-box;\n\n /*\n * No padding, and no token for one.\n *\n * A drop reserves --qti-dropzone-min-*, which is the chip's BORDER-box, as this region's CONTENT\n * area — so the chip already fits exactly, with nothing to spare and nothing squeezed. An inset\n * on top would only make the drop bigger than the thing it holds.\n *\n * There was a 1px one, to make the drop read as a frame a hair outside the chip. It never painted:\n * an EMPTY slot has nothing inside the inset to separate from, and a FILLED one hides its edge\n * (DROP-SIZING.md §4), so both states spent 2px on an invisible ring. The one drop that genuinely\n * wants breathing room — match's category card — declares padding on its own rule, which a\n * theme reaches with ::part(drop). A token in between bought nothing.\n */\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n justify-content: flex-start;\n /* No gap either: 0 is the flex initial value, so the declaration only existed to host a token.\n A drop that wants space between chips sets gap on its own rule. */\n /* Containing block for anything a theme draws over the drop. Was 'position: relative' in the\n theme's 'drop' mixin, which put a document stylesheet in charge of a shadow node's position. */\n position: relative;\n }\n\n [part~='drop'] > * {\n flex: 0 1 auto;\n align-self: flex-start;\n }\n`;\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `#validation-message` region every interaction renders, hidden until there is a message.
|
|
3
|
+
*
|
|
4
|
+
* `Interaction` owns showing and hiding it: `reportValidity` sets
|
|
5
|
+
* `display: block !important` inline when `_internals.validationMessage` is non-empty, and clears the
|
|
6
|
+
* text and sets `display: none` inline again when it is not (see interaction.ts). An inline
|
|
7
|
+
* `!important` beats this rule, so the JS still wins whenever it speaks.
|
|
8
|
+
*
|
|
9
|
+
* What it did not own was the *initial* state. Before first validation the div has no inline style,
|
|
10
|
+
* so it needs a stylesheet to start hidden — otherwise it paints as an empty box with the theme's
|
|
11
|
+
* warning border and padding. That hide used to be a `display: none` inside the theme's
|
|
12
|
+
* `validation-message` mixin, which made a document stylesheet responsible for a shadow node's box.
|
|
13
|
+
* Two components had already noticed and worked around it with `style="display:none"` in their
|
|
14
|
+
* template; the other five relied on the theme.
|
|
15
|
+
*
|
|
16
|
+
* The theme still paints the message — colour, border, padding, radius — via `::part(message)`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const validationMessage: import("lit").CSSResult;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* The `#validation-message` region every interaction renders, hidden until there is a message.
|
|
4
|
+
*
|
|
5
|
+
* `Interaction` owns showing and hiding it: `reportValidity` sets
|
|
6
|
+
* `display: block !important` inline when `_internals.validationMessage` is non-empty, and clears the
|
|
7
|
+
* text and sets `display: none` inline again when it is not (see interaction.ts). An inline
|
|
8
|
+
* `!important` beats this rule, so the JS still wins whenever it speaks.
|
|
9
|
+
*
|
|
10
|
+
* What it did not own was the *initial* state. Before first validation the div has no inline style,
|
|
11
|
+
* so it needs a stylesheet to start hidden — otherwise it paints as an empty box with the theme's
|
|
12
|
+
* warning border and padding. That hide used to be a `display: none` inside the theme's
|
|
13
|
+
* `validation-message` mixin, which made a document stylesheet responsible for a shadow node's box.
|
|
14
|
+
* Two components had already noticed and worked around it with `style="display:none"` in their
|
|
15
|
+
* template; the other five relied on the theme.
|
|
16
|
+
*
|
|
17
|
+
* The theme still paints the message — colour, border, padding, radius — via `::part(message)`.
|
|
18
|
+
*/
|
|
19
|
+
export const validationMessage = css `
|
|
20
|
+
[part~='message'] {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
//# sourceMappingURL=validation-message.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-message.styles.js","sourceRoot":"","sources":["../../src/styles/validation-message.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;CAInC,CAAC","sourcesContent":["import { css } from 'lit';\n\n/**\n * The `#validation-message` region every interaction renders, hidden until there is a message.\n *\n * `Interaction` owns showing and hiding it: `reportValidity` sets\n * `display: block !important` inline when `_internals.validationMessage` is non-empty, and clears the\n * text and sets `display: none` inline again when it is not (see interaction.ts). An inline\n * `!important` beats this rule, so the JS still wins whenever it speaks.\n *\n * What it did not own was the *initial* state. Before first validation the div has no inline style,\n * so it needs a stylesheet to start hidden — otherwise it paints as an empty box with the theme's\n * warning border and padding. That hide used to be a `display: none` inside the theme's\n * `validation-message` mixin, which made a document stylesheet responsible for a shadow node's box.\n * Two components had already noticed and worked around it with `style=\"display:none\"` in their\n * template; the other five relied on the theme.\n *\n * The theme still paints the message — colour, border, padding, radius — via `::part(message)`.\n */\nexport const validationMessage = css`\n [part~='message'] {\n display: none;\n }\n`;\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qti-components/base",
|
|
3
3
|
"description": "QTI shared utilities",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"author": "",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@qti-components/utilities": "^1.3.3"
|
|
@@ -16,6 +16,21 @@
|
|
|
16
16
|
],
|
|
17
17
|
"license": "GPL-3.0-only",
|
|
18
18
|
"main": "dist/index.js",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./elements": {
|
|
25
|
+
"types": "./dist/elements.d.ts",
|
|
26
|
+
"import": "./dist/elements.js"
|
|
27
|
+
},
|
|
28
|
+
"./register": {
|
|
29
|
+
"types": "./dist/register.d.ts",
|
|
30
|
+
"import": "./dist/register.js"
|
|
31
|
+
},
|
|
32
|
+
"./*": "./dist/*"
|
|
33
|
+
},
|
|
19
34
|
"peerDependencies": {
|
|
20
35
|
"@lit/context": "^1.1.6",
|
|
21
36
|
"lit": "^3.3.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"qti-assessment-item.context.js","sourceRoot":"","sources":["../../src/context/qti-assessment-item.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAc,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\n\nimport type { ItemContext } from './item.context';\n\nexport const itemContext = createContext<ItemContext>(Symbol('item'));\n"]}
|