@pie-players/pie-tool-calculator-inline-desmos 0.3.43 → 0.3.44

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.
@@ -1,3 +1,2 @@
1
1
  declare const _default: import('vite').UserConfig;
2
2
  export default _default;
3
- //# sourceMappingURL=vite.config.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-players/pie-tool-calculator-inline-desmos",
3
- "version": "0.3.43",
3
+ "version": "0.3.44",
4
4
  "type": "module",
5
5
  "description": "Inline calculator toggle button for PIE assessment player question headers",
6
6
  "repository": {
@@ -20,26 +20,23 @@
20
20
  "wcag",
21
21
  "accessibility"
22
22
  ],
23
- "svelte": "./tool-calculator-inline.svelte",
24
23
  "main": "./dist/tool-calculator-inline.js",
25
24
  "types": "./dist/tool-calculator-inline.svelte.d.ts",
26
25
  "exports": {
27
26
  ".": {
28
27
  "types": "./dist/tool-calculator-inline.svelte.d.ts",
29
- "import": "./dist/tool-calculator-inline.js",
30
- "svelte": "./tool-calculator-inline.svelte"
28
+ "import": "./dist/tool-calculator-inline.js"
31
29
  }
32
30
  },
33
31
  "files": [
34
- "dist",
35
- "tool-calculator-inline.svelte"
32
+ "dist"
36
33
  ],
37
34
  "license": "MIT",
38
35
  "unpkg": "./dist/tool-calculator-inline.js",
39
36
  "jsdelivr": "./dist/tool-calculator-inline.js",
40
37
  "dependencies": {
41
- "@pie-players/pie-assessment-toolkit": "0.3.43",
42
- "@pie-players/pie-context": "0.3.43"
38
+ "@pie-players/pie-assessment-toolkit": "0.3.44",
39
+ "@pie-players/pie-context": "0.3.44"
43
40
  },
44
41
  "scripts": {
45
42
  "build": "vite build",
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite.config.d.ts","sourceRoot":"","sources":["../vite.config.ts"],"names":[],"mappings":";AAIA,wBA+BG"}
@@ -1,285 +0,0 @@
1
- <svelte:options
2
- customElement={{
3
- tag: 'pie-tool-calculator-inline',
4
- shadow: 'open',
5
- props: {
6
- toolId: { type: 'String', attribute: 'tool-id' },
7
- targetToolId: { type: 'String', attribute: 'target-tool-id' },
8
- calculatorType: { type: 'String', attribute: 'calculator-type' },
9
- availableTypes: { type: 'String', attribute: 'available-types' },
10
- size: { type: 'String', attribute: 'size' }
11
- }
12
- }}
13
- />
14
-
15
- <script lang="ts">
16
- import {
17
- connectToolRuntimeContext,
18
- toOverlayToolId,
19
- ZIndexLayer,
20
- } from '@pie-players/pie-assessment-toolkit';
21
- import type {
22
- AssessmentToolkitRuntimeContext,
23
- ToolCoordinatorApi,
24
- } from '@pie-players/pie-assessment-toolkit';
25
- // Props
26
- let {
27
- toolId = 'calculator-inline',
28
- targetToolId = '',
29
- calculatorType = 'basic',
30
- availableTypes = 'basic,scientific,graphing',
31
- size = 'md' as 'sm' | 'md' | 'lg'
32
- }: {
33
- toolId?: string;
34
- targetToolId?: string;
35
- calculatorType?: string;
36
- availableTypes?: string;
37
- size?: 'sm' | 'md' | 'lg';
38
- } = $props();
39
-
40
- const isBrowser = typeof window !== 'undefined';
41
-
42
- // State
43
- let containerEl = $state<HTMLDivElement | undefined>();
44
- let runtimeContext = $state<AssessmentToolkitRuntimeContext | null>(null);
45
- const coordinator = $derived(
46
- runtimeContext?.toolCoordinator as ToolCoordinatorApi | undefined,
47
- );
48
- let registered = $state(false);
49
- let calculatorVisible = $state(false);
50
- let statusMessage = $state('');
51
- const supportedCalculatorTypes = $derived(
52
- new Set(
53
- availableTypes
54
- .split(',')
55
- .map((type) => type.trim())
56
- .filter(Boolean),
57
- ),
58
- );
59
- const effectiveCalculatorType = $derived(
60
- supportedCalculatorTypes.has(calculatorType) ? calculatorType : 'basic',
61
- );
62
-
63
- $effect(() => {
64
- if (!containerEl) return;
65
- return connectToolRuntimeContext(containerEl, (value: AssessmentToolkitRuntimeContext) => {
66
- runtimeContext = value;
67
- });
68
- });
69
-
70
- // Register with coordinator
71
- $effect(() => {
72
- if (coordinator && toolId && containerEl && !registered) {
73
- coordinator.registerTool(toolId, 'Calculator Inline', containerEl, ZIndexLayer.TOOL);
74
- registered = true;
75
- }
76
- });
77
-
78
- const effectiveTargetToolId = $derived(
79
- targetToolId ? targetToolId : toOverlayToolId(toolId),
80
- );
81
-
82
- // Subscribe to coordinator to track calculator visibility
83
- $effect(() => {
84
- if (!isBrowser || !coordinator) return;
85
-
86
- const unsubscribe = coordinator.subscribe(() => {
87
- calculatorVisible = coordinator.isToolVisible(effectiveTargetToolId);
88
- });
89
-
90
- // Initial update
91
- calculatorVisible = coordinator.isToolVisible(effectiveTargetToolId);
92
-
93
- return unsubscribe;
94
- });
95
-
96
- // Cleanup when component unmounts
97
- $effect(() => {
98
- return () => {
99
- if (coordinator && toolId) {
100
- coordinator.unregisterTool(toolId);
101
- }
102
- };
103
- });
104
-
105
- // Handle toggle click
106
- function handleToggle() {
107
- if (!coordinator) return;
108
-
109
- // Toggle the calculator tool visibility
110
- coordinator.toggleTool(effectiveTargetToolId);
111
-
112
- statusMessage = calculatorVisible
113
- ? `${effectiveCalculatorType} calculator closed`
114
- : `${effectiveCalculatorType} calculator opened`;
115
- }
116
-
117
- // Size classes
118
- const sizeClass = $derived(
119
- size === 'sm'
120
- ? 'pie-tool-calculator-inline__button--sm'
121
- : size === 'lg'
122
- ? 'pie-tool-calculator-inline__button--lg'
123
- : 'pie-tool-calculator-inline__button--md'
124
- );
125
- </script>
126
-
127
- {#if isBrowser}
128
- <div bind:this={containerEl} class="pie-tool-calculator-inline">
129
- <!-- Calculator Toggle Button -->
130
- <button
131
- type="button"
132
- class="pie-tool-calculator-inline__button {sizeClass}"
133
- class:pie-tool-calculator-inline__button--active={calculatorVisible}
134
- onclick={handleToggle}
135
- aria-label={calculatorVisible ? `Close ${effectiveCalculatorType} calculator` : `Open ${effectiveCalculatorType} calculator`}
136
- aria-pressed={calculatorVisible}
137
- title={calculatorVisible ? `Close ${effectiveCalculatorType} calculator` : `Open ${effectiveCalculatorType} calculator`}
138
- data-calculator-type={effectiveCalculatorType}
139
- disabled={!coordinator}
140
- >
141
- <!-- Material Design Calculator Icon -->
142
- <svg
143
- xmlns="http://www.w3.org/2000/svg"
144
- viewBox="0 0 24 24"
145
- class="pie-tool-calculator-inline__icon"
146
- aria-hidden="true"
147
- >
148
- <path
149
- d="M7,2H17A2,2 0 0,1 19,4V20A2,2 0 0,1 17,22H7A2,2 0 0,1 5,20V4A2,2 0 0,1 7,2M7,4V8H17V4H7M7,10V12H9V10H7M11,10V12H13V10H11M15,10V12H17V10H15M7,14V16H9V14H7M11,14V16H13V14H11M15,14V16H17V14H15M7,18V20H9V18H7M11,18V20H13V18H11M15,18V20H17V18H15Z"
150
- />
151
- </svg>
152
- </button>
153
-
154
- <!-- Screen reader status announcements -->
155
- <div class="pie-sr-only" role="status" aria-live="polite" aria-atomic="true">
156
- {statusMessage}
157
- </div>
158
- </div>
159
- {/if}
160
-
161
- <style>
162
- .pie-tool-calculator-inline {
163
- display: inline-flex;
164
- align-items: center;
165
- gap: 0.25rem;
166
- }
167
-
168
- .pie-tool-calculator-inline__button {
169
- display: inline-flex;
170
- align-items: center;
171
- justify-content: center;
172
- border: 1px solid var(--pie-border, #ccc);
173
- background-color: var(--pie-background, white);
174
- color: var(--pie-text, #333);
175
- border-radius: 4px;
176
- cursor: pointer;
177
- transition:
178
- background-color 0.15s ease,
179
- transform 0.1s ease,
180
- box-shadow 0.15s ease;
181
- padding: 0.25rem;
182
- position: relative;
183
- }
184
-
185
- .pie-tool-calculator-inline__button:hover:not(:disabled) {
186
- background-color: var(--pie-secondary-background, #f5f5f5);
187
- transform: translateY(-1px);
188
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
189
- }
190
-
191
- .pie-tool-calculator-inline__button:active:not(:disabled) {
192
- transform: translateY(0);
193
- box-shadow: none;
194
- }
195
-
196
- /* Focus indicator - WCAG 2.4.7, 2.4.13 */
197
- .pie-tool-calculator-inline__button:focus-visible {
198
- outline: 2px solid #0066cc;
199
- outline-offset: 2px;
200
- box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.2);
201
- z-index: 1;
202
- }
203
-
204
- .pie-tool-calculator-inline__button--active {
205
- background-color: var(--pie-primary, #1976d2);
206
- color: white;
207
- border-color: var(--pie-primary, #1976d2);
208
- }
209
-
210
- .pie-tool-calculator-inline__button--active:hover:not(:disabled) {
211
- background-color: var(--pie-primary-dark, #1565c0);
212
- }
213
-
214
- .pie-tool-calculator-inline__button:disabled {
215
- cursor: not-allowed;
216
- opacity: 0.6;
217
- }
218
-
219
- /* Size variants */
220
- .pie-tool-calculator-inline__button--sm {
221
- width: 1.5rem;
222
- height: 1.5rem;
223
- /* Increase padding to meet 44px touch target - WCAG 2.5.2 */
224
- padding: 0.625rem;
225
- }
226
-
227
- .pie-tool-calculator-inline__button--sm .pie-tool-calculator-inline__icon {
228
- width: 1rem;
229
- height: 1rem;
230
- }
231
-
232
- .pie-tool-calculator-inline__button--md {
233
- width: 2rem;
234
- height: 2rem;
235
- }
236
-
237
- .pie-tool-calculator-inline__button--md .pie-tool-calculator-inline__icon {
238
- width: 1.25rem;
239
- height: 1.25rem;
240
- }
241
-
242
- .pie-tool-calculator-inline__button--lg {
243
- width: 2.5rem;
244
- height: 2.5rem;
245
- }
246
-
247
- .pie-tool-calculator-inline__button--lg .pie-tool-calculator-inline__icon {
248
- width: 1.5rem;
249
- height: 1.5rem;
250
- }
251
-
252
- .pie-tool-calculator-inline__icon {
253
- fill: currentColor;
254
- color: #555;
255
- }
256
-
257
- .pie-tool-calculator-inline__button:hover:not(:disabled) .pie-tool-calculator-inline__icon {
258
- color: #667eea;
259
- }
260
-
261
- .pie-tool-calculator-inline__button--active .pie-tool-calculator-inline__icon {
262
- color: white;
263
- }
264
-
265
- /* Screen reader only content */
266
- .pie-sr-only {
267
- position: absolute;
268
- width: 1px;
269
- height: 1px;
270
- padding: 0;
271
- margin: -1px;
272
- overflow: hidden;
273
- clip: rect(0, 0, 0, 0);
274
- white-space: nowrap;
275
- border: 0;
276
- }
277
-
278
- /* Accessibility */
279
- @media (prefers-reduced-motion: reduce) {
280
- .pie-tool-calculator-inline__button {
281
- animation: none !important;
282
- transition: none !important;
283
- }
284
- }
285
- </style>