@pie-players/pie-tool-calculator-inline-desmos 0.3.72 → 0.3.74
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 +31 -99
- package/dist/index.d.ts +8 -0
- package/dist/tool-calculator-inline.js +1207 -1962
- package/package.json +12 -13
- package/dist/tool-calculator-inline.svelte.d.ts +0 -1
package/README.md
CHANGED
|
@@ -4,126 +4,59 @@ Inline calculator toggle button for PIE assessment player question headers.
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
`@pie-players/pie-tool-calculator-shared
|
|
7
|
+
`<pie-tool-calculator-inline>` is a toggle button for the calculator an item
|
|
8
|
+
toolbar renders. It wraps the provider-neutral inline surface from
|
|
9
|
+
`@pie-players/pie-tool-calculator-shared`, which the GeoGebra and Cortex inline
|
|
10
|
+
packages share.
|
|
10
11
|
|
|
11
12
|
## Features
|
|
12
13
|
|
|
13
|
-
- **Web Component** - Custom element with
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
14
|
+
- **Web Component** - Custom element with an open shadow root
|
|
15
|
+
- **Toolkit context** - Takes its ToolCoordinator from the toolkit runtime context and its item from the enclosing item shell
|
|
16
|
+
- **Shared state** - Opens the item toolbar's calculator instance, so the button and the toolbar stay in step
|
|
16
17
|
- **Size Variants** - Supports sm, md, lg button sizes
|
|
17
18
|
- **WCAG 2.2 Level AA** - Fully accessible with proper ARIA attributes
|
|
18
19
|
- **Material Design Icon** - Calculator icon from Material Design
|
|
19
20
|
|
|
20
21
|
## Usage
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<!-- Import the component -->
|
|
26
|
-
<script>
|
|
27
|
-
import '@pie-players/pie-tool-calculator-inline-desmos';
|
|
28
|
-
import '@pie-players/pie-tool-calculator-desmos';
|
|
29
|
-
import { ToolCoordinator } from '@pie-players/pie-assessment-toolkit';
|
|
30
|
-
|
|
31
|
-
const coordinator = new ToolCoordinator();
|
|
32
|
-
let calculatorInlineEl;
|
|
33
|
-
let calculatorEl;
|
|
34
|
-
let calculatorVisible = false;
|
|
35
|
-
|
|
36
|
-
// Bind services imperatively (after element creation)
|
|
37
|
-
$effect(() => {
|
|
38
|
-
if (calculatorInlineEl) {
|
|
39
|
-
calculatorInlineEl.coordinator = coordinator;
|
|
40
|
-
}
|
|
41
|
-
if (calculatorEl) {
|
|
42
|
-
calculatorEl.coordinator = coordinator;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Subscribe to visibility changes
|
|
47
|
-
$effect(() => {
|
|
48
|
-
if (coordinator) {
|
|
49
|
-
const unsubscribe = coordinator.subscribe(() => {
|
|
50
|
-
calculatorVisible = coordinator.isToolVisible('calculator');
|
|
51
|
-
});
|
|
52
|
-
return unsubscribe;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
</script>
|
|
56
|
-
|
|
57
|
-
<!-- Inline toggle button -->
|
|
58
|
-
<pie-tool-calculator-inline
|
|
59
|
-
bind:this={calculatorInlineEl}
|
|
60
|
-
tool-id="calculator-inline"
|
|
61
|
-
calculator-type="scientific"
|
|
62
|
-
available-types="basic,scientific,graphing"
|
|
63
|
-
size="md"
|
|
64
|
-
></pie-tool-calculator-inline>
|
|
65
|
-
|
|
66
|
-
<!-- Calculator tool instance (hidden/shown by coordinator) -->
|
|
67
|
-
<pie-tool-calculator
|
|
68
|
-
bind:this={calculatorEl}
|
|
69
|
-
visible={calculatorVisible}
|
|
70
|
-
tool-id="calculator"
|
|
71
|
-
></pie-tool-calculator>
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### In ItemToolBar
|
|
23
|
+
The element renders inside `<pie-item-shell>` under `<pie-assessment-toolkit>`.
|
|
24
|
+
The toolkit runtime context supplies the ToolCoordinator and the shell supplies
|
|
25
|
+
the item; section players provide both.
|
|
75
26
|
|
|
76
|
-
|
|
27
|
+
```javascript
|
|
28
|
+
import '@pie-players/pie-tool-calculator-inline-desmos';
|
|
77
29
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
size="md"
|
|
83
|
-
></pie-item-toolbar>
|
|
30
|
+
// itemHeader: an element inside <pie-item-shell>
|
|
31
|
+
const calculatorButton = document.createElement('pie-tool-calculator-inline');
|
|
32
|
+
calculatorButton.setAttribute('calculator-type', 'scientific');
|
|
33
|
+
itemHeader.append(calculatorButton);
|
|
84
34
|
```
|
|
85
35
|
|
|
86
|
-
The toolbar
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
36
|
+
The calculator it opens is the item toolbar's: the toolkit's tool configuration
|
|
37
|
+
places `calculator` in the item toolbar and names its provider, and the item
|
|
38
|
+
toolbar renders that calculator. The button adds no calculator of its own, so
|
|
39
|
+
an item whose tool policy leaves the calculator out has nothing for it to open.
|
|
90
40
|
|
|
91
41
|
### Props
|
|
92
42
|
|
|
93
43
|
#### Attributes (String)
|
|
94
44
|
|
|
95
|
-
- `tool-id` -
|
|
96
|
-
- `calculator-type` -
|
|
45
|
+
- `target-tool-id` - Coordinator tool id the button toggles (default: `''`). Empty resolves the enclosing item's calculator, `calculator:item:<itemId>`; set it only to toggle a calculator registered under another id
|
|
46
|
+
- `calculator-type` - Calculator type named in the button's label and announcements (default: `'basic'`); a type outside `available-types` falls back to `'basic'`
|
|
97
47
|
- `available-types` - Comma-separated list of calculator types (default: `'basic,scientific,graphing'`)
|
|
98
48
|
- `size` - Button size: `'sm' | 'md' | 'lg'` (default: `'md'`)
|
|
99
49
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
-
|
|
103
|
-
|
|
104
|
-
**Important:** The `coordinator` property must be set via JavaScript, not as an attribute:
|
|
105
|
-
|
|
106
|
-
```javascript
|
|
107
|
-
element.coordinator = coordinatorInstance;
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Calculator Tool Integration
|
|
111
|
-
|
|
112
|
-
This component works in tandem with `@pie-players/pie-tool-calculator-desmos`. The flow is:
|
|
113
|
-
|
|
114
|
-
1. **Button renders** - `pie-tool-calculator-inline` shows a toggle button
|
|
115
|
-
2. **User clicks** - Button calls `coordinator.toggleTool('calculator')`
|
|
116
|
-
3. **Calculator shows/hides** - `pie-tool-calculator` reacts to visibility state
|
|
117
|
-
4. **Button updates** - Active state reflects calculator visibility
|
|
118
|
-
|
|
119
|
-
## Tool ID Convention
|
|
120
|
-
|
|
121
|
-
The inline button typically uses a different tool ID than the calculator instance:
|
|
50
|
+
The button is disabled until the toolkit runtime context supplies a
|
|
51
|
+
ToolCoordinator and a target resolves. With no item shell and no
|
|
52
|
+
`target-tool-id`, it stays disabled and logs a console warning.
|
|
122
53
|
|
|
123
|
-
|
|
124
|
-
- Calculator tool: `calculator` or `calculator-{itemId}`
|
|
54
|
+
## Toggle behavior
|
|
125
55
|
|
|
126
|
-
The
|
|
56
|
+
1. The button resolves its target from the item shell context: `calculator:item:<canonicalItemId or itemId>`, the id the item toolbar uses.
|
|
57
|
+
2. A click registers that id with the coordinator if the toolbar has not yet, then calls `toggleTool`.
|
|
58
|
+
3. The item toolbar renders or hides its calculator from the coordinator's visibility state.
|
|
59
|
+
4. `aria-pressed`, the active style and a status announcement follow the target's visibility, including changes made from the toolbar.
|
|
127
60
|
|
|
128
61
|
## Accessibility
|
|
129
62
|
|
|
@@ -199,8 +132,7 @@ bun run lint
|
|
|
199
132
|
|
|
200
133
|
## Dependencies
|
|
201
134
|
|
|
202
|
-
- `@pie-players/pie-assessment-toolkit` -
|
|
203
|
-
- `svelte` - Framework (peer dependency)
|
|
135
|
+
- `@pie-players/pie-assessment-toolkit` - Toolkit contexts and scoped tool ids
|
|
204
136
|
|
|
205
137
|
## License
|
|
206
138
|
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pie-tool-calculator-inline-desmos
|
|
3
|
+
*
|
|
4
|
+
* Importing this package registers `<pie-tool-calculator-inline>`. The build
|
|
5
|
+
* entry is the component, so this file is the type entry alone and declares
|
|
6
|
+
* nothing: a runtime export here would not exist in the built bundle.
|
|
7
|
+
*/
|
|
8
|
+
export type {};
|