@pie-players/pie-tool-protractor 0.1.6 → 0.1.9
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/index.d.ts +1 -0
- package/dist/tool-protractor.js +8003 -6926
- package/package.json +15 -6
- package/tool-protractor.svelte +33 -17
- package/dist/tool-protractor.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-players/pie-tool-protractor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Draggable and rotatable protractor tool for PIE assessment player",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/pie-framework/pie-players.git"
|
|
8
|
+
"url": "git+https://github.com/pie-framework/pie-players.git",
|
|
9
|
+
"directory": "packages/tool-protractor"
|
|
9
10
|
},
|
|
10
11
|
"publishConfig": {
|
|
11
12
|
"access": "public"
|
|
@@ -41,9 +42,9 @@
|
|
|
41
42
|
"unpkg": "./dist/tool-protractor.js",
|
|
42
43
|
"jsdelivr": "./dist/tool-protractor.js",
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@pie-players/pie-assessment-toolkit": "0.2.
|
|
45
|
-
"@pie-players/pie-
|
|
46
|
-
"@
|
|
45
|
+
"@pie-players/pie-assessment-toolkit": "0.2.9",
|
|
46
|
+
"@pie-players/pie-context": "0.1.1",
|
|
47
|
+
"@pie-players/pie-players-shared": "0.2.5",
|
|
47
48
|
"daisyui": "^5.5.18",
|
|
48
49
|
"moveable": "^0.53.0"
|
|
49
50
|
},
|
|
@@ -61,5 +62,13 @@
|
|
|
61
62
|
"typescript": "^5.7.0",
|
|
62
63
|
"vite": "^7.0.8",
|
|
63
64
|
"vite-plugin-dts": "^4.5.3"
|
|
64
|
-
}
|
|
65
|
+
},
|
|
66
|
+
"homepage": "https://github.com/pie-framework/pie-players/tree/master/packages/tool-protractor#readme",
|
|
67
|
+
"bugs": {
|
|
68
|
+
"url": "https://github.com/pie-framework/pie-players/issues"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=18.0.0"
|
|
72
|
+
},
|
|
73
|
+
"sideEffects": true
|
|
65
74
|
}
|
package/tool-protractor.svelte
CHANGED
|
@@ -1,30 +1,39 @@
|
|
|
1
1
|
<svelte:options
|
|
2
2
|
customElement={{
|
|
3
3
|
tag: 'pie-tool-protractor',
|
|
4
|
-
shadow: '
|
|
4
|
+
shadow: 'open',
|
|
5
5
|
props: {
|
|
6
6
|
visible: { type: 'Boolean', attribute: 'visible' },
|
|
7
|
-
toolId: { type: 'String', attribute: 'tool-id' }
|
|
8
|
-
coordinator: { type: 'Object' }
|
|
7
|
+
toolId: { type: 'String', attribute: 'tool-id' }
|
|
9
8
|
}
|
|
10
9
|
}}
|
|
11
10
|
/>
|
|
12
11
|
|
|
13
12
|
<script lang="ts">
|
|
14
|
-
import
|
|
15
|
-
|
|
13
|
+
import {
|
|
14
|
+
connectToolRuntimeContext,
|
|
15
|
+
ZIndexLayer,
|
|
16
|
+
} from '@pie-players/pie-assessment-toolkit';
|
|
17
|
+
import type {
|
|
18
|
+
AssessmentToolkitRuntimeContext,
|
|
19
|
+
IToolCoordinator,
|
|
20
|
+
} from '@pie-players/pie-assessment-toolkit';
|
|
16
21
|
import Moveable from 'moveable';
|
|
17
22
|
import { onMount } from 'svelte';
|
|
18
23
|
import protractorSvg from './protractor.svg';
|
|
19
24
|
|
|
20
25
|
// Props
|
|
21
|
-
let { visible = false, toolId = 'protractor'
|
|
26
|
+
let { visible = false, toolId = 'protractor' }: { visible?: boolean; toolId?: string } = $props();
|
|
22
27
|
|
|
23
28
|
// Check if running in browser
|
|
24
29
|
const isBrowser = typeof window !== 'undefined';
|
|
25
30
|
|
|
26
31
|
// State
|
|
27
32
|
let containerEl = $state<HTMLDivElement | undefined>();
|
|
33
|
+
let runtimeContext = $state<AssessmentToolkitRuntimeContext | null>(null);
|
|
34
|
+
const coordinator = $derived(
|
|
35
|
+
runtimeContext?.toolCoordinator as IToolCoordinator | undefined,
|
|
36
|
+
);
|
|
28
37
|
let announceText = $state('');
|
|
29
38
|
let moveable: Moveable | null = null;
|
|
30
39
|
|
|
@@ -36,6 +45,13 @@
|
|
|
36
45
|
const ROTATE_STEP = 5; // degrees
|
|
37
46
|
const FINE_ROTATE_STEP = 1; // degrees
|
|
38
47
|
|
|
48
|
+
$effect(() => {
|
|
49
|
+
if (!containerEl) return;
|
|
50
|
+
return connectToolRuntimeContext(containerEl, (value: AssessmentToolkitRuntimeContext) => {
|
|
51
|
+
runtimeContext = value;
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
39
55
|
function announce(message: string) {
|
|
40
56
|
announceText = message;
|
|
41
57
|
setTimeout(() => announceText = '', 1000);
|
|
@@ -235,7 +251,7 @@
|
|
|
235
251
|
|
|
236
252
|
{#if visible && isBrowser}
|
|
237
253
|
<!-- Screen reader announcements -->
|
|
238
|
-
<div class="sr-only" role="status" aria-live="polite" aria-atomic="true">
|
|
254
|
+
<div class="pie-sr-only" role="status" aria-live="polite" aria-atomic="true">
|
|
239
255
|
{announceText}
|
|
240
256
|
</div>
|
|
241
257
|
|
|
@@ -243,7 +259,7 @@
|
|
|
243
259
|
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
244
260
|
<div
|
|
245
261
|
bind:this={containerEl}
|
|
246
|
-
class="protractor
|
|
262
|
+
class="pie-tool-protractor"
|
|
247
263
|
data-moveablejs-tool-id={toolId}
|
|
248
264
|
onpointerdown={() => coordinator?.bringToFront(containerEl)}
|
|
249
265
|
onkeydown={handleKeyDown}
|
|
@@ -252,9 +268,9 @@
|
|
|
252
268
|
aria-label="Protractor tool. Use arrow keys to move, Shift+arrows to rotate, PageUp/PageDown for fine rotation. Current rotation displayed via Moveable.js"
|
|
253
269
|
aria-roledescription="Draggable and rotatable protractor measurement tool"
|
|
254
270
|
>
|
|
255
|
-
<div class="
|
|
271
|
+
<div class="pie-tool-protractor__container">
|
|
256
272
|
<img
|
|
257
|
-
class="
|
|
273
|
+
class="pie-tool-protractor__image"
|
|
258
274
|
src={protractorSvg}
|
|
259
275
|
alt="Protractor with 180-degree semicircular scale marked from 0 to 180 degrees in both directions, with degree markings every 10 degrees"
|
|
260
276
|
draggable="false"
|
|
@@ -264,7 +280,7 @@
|
|
|
264
280
|
{/if}
|
|
265
281
|
|
|
266
282
|
<style>
|
|
267
|
-
.sr-only {
|
|
283
|
+
.pie-sr-only {
|
|
268
284
|
position: absolute;
|
|
269
285
|
width: 1px;
|
|
270
286
|
height: 1px;
|
|
@@ -276,7 +292,7 @@
|
|
|
276
292
|
border-width: 0;
|
|
277
293
|
}
|
|
278
294
|
|
|
279
|
-
.protractor
|
|
295
|
+
.pie-tool-protractor {
|
|
280
296
|
border: 0;
|
|
281
297
|
cursor: move;
|
|
282
298
|
left: 50%;
|
|
@@ -289,17 +305,17 @@
|
|
|
289
305
|
touch-action: none;
|
|
290
306
|
}
|
|
291
307
|
|
|
292
|
-
.protractor
|
|
308
|
+
.pie-tool-protractor:focus {
|
|
293
309
|
outline: 3px solid #4A90E2;
|
|
294
310
|
outline-offset: 2px;
|
|
295
311
|
}
|
|
296
312
|
|
|
297
|
-
.protractor
|
|
313
|
+
.pie-tool-protractor:focus-visible {
|
|
298
314
|
outline: 3px solid #4A90E2;
|
|
299
315
|
outline-offset: 2px;
|
|
300
316
|
}
|
|
301
317
|
|
|
302
|
-
.
|
|
318
|
+
.pie-tool-protractor__container {
|
|
303
319
|
border: 0;
|
|
304
320
|
position: relative;
|
|
305
321
|
width: 400px;
|
|
@@ -307,7 +323,7 @@
|
|
|
307
323
|
}
|
|
308
324
|
|
|
309
325
|
/* Semi-transparent white overlay for visibility (matching production implementation) */
|
|
310
|
-
.
|
|
326
|
+
.pie-tool-protractor__container::after {
|
|
311
327
|
background-color: #fff;
|
|
312
328
|
border-radius: 283px 283px 0 0;
|
|
313
329
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* Matching production implementation shadow */
|
|
@@ -322,7 +338,7 @@
|
|
|
322
338
|
pointer-events: none;
|
|
323
339
|
}
|
|
324
340
|
|
|
325
|
-
.
|
|
341
|
+
.pie-tool-protractor__image {
|
|
326
342
|
width: 400px;
|
|
327
343
|
height: 210px;
|
|
328
344
|
position: relative;
|