@doenet/doenetml 0.7.0-alpha53 → 0.7.0-alpha55
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/EditorViewer/EditorViewer.d.ts +2 -2
- package/EditorViewer/EditorViewer.d.ts.map +1 -1
- package/Viewer/DocViewer.d.ts +3 -3
- package/Viewer/DocViewer.d.ts.map +1 -1
- package/Viewer/renderers/answer.d.ts.map +1 -1
- package/Viewer/renderers/utils/{AnswerResponseMenu.d.ts → AnswerResponseButton.d.ts} +2 -2
- package/Viewer/renderers/utils/AnswerResponseButton.d.ts.map +1 -0
- package/{_error-GwDTi6rY.js → _error-DacdROUl.js} +2 -2
- package/{alert-BtkPDkoA.js → alert-C8fzteWj.js} +3 -3
- package/{angle-D8QNz00R.js → angle-BUfNJ5pr.js} +3 -3
- package/{answer-ciKskgNk.js → answer-VaRBTsuJ.js} +10 -10
- package/{asList-Cb0lLe-w.js → asList-CI4c1C0S.js} +2 -2
- package/{blockQuote-DiHpuXuU.js → blockQuote-C4OPDdr3.js} +3 -3
- package/{boolean-CAhgqlsZ.js → boolean-Cx8Ap9YX.js} +2 -2
- package/{booleanInput-Dtul5aLp.js → booleanInput-BHSeOXKe.js} +4 -4
- package/{br-CU6brznZ.js → br-zQwnfkFP.js} +2 -2
- package/{button-BlF6I46m.js → button-CJQY5U79.js} +3 -3
- package/{c-CmlalQXF.js → c-VEX0flHS.js} +3 -3
- package/{cell-DKuooRe3.js → cell-B9PlIPCR.js} +3 -3
- package/checkwork-n17Hhm9K.js +841 -0
- package/{choiceInput-DcDJOcx_.js → choiceInput-BRqkeCFl.js} +3 -3
- package/{circle-D-vdk68E.js → circle-CXVHt7c3.js} +3 -3
- package/{cobwebPolyline-H7MNGud_.js → cobwebPolyline-ClgouZGU.js} +3 -3
- package/{codeEditor-BdcQ4cRu.js → codeEditor-Do2mH-YQ.js} +2 -2
- package/{composites-ByHZA6ga.js → composites-TjAu4fHD.js} +1 -1
- package/{containerBlock-Zt0J_8qp.js → containerBlock-BXHNKAeC.js} +3 -3
- package/{containerInline-J0ZA-hAw.js → containerInline-DI_a6AhM.js} +3 -3
- package/{curve-CnVnG-gR.js → curve-B8HrdaaR.js} +3 -3
- package/doenetml-inline-worker.js +2 -2
- package/{doenetml-BxYCfP3q.js → doenetml-sRNYlCqd.js} +21 -53
- package/doenetml.d.ts +4 -4
- package/doenetml.d.ts.map +1 -1
- package/{ellipsis-BbY_75B9.js → ellipsis-D81Tiiuc.js} +2 -2
- package/{em-Bo1_u07q.js → em-DDw9Si3H.js} +3 -3
- package/{embed-BYY0B6YL.js → embed-BEW6CoWr.js} +2 -2
- package/{feedback-BEcqQSUv.js → feedback-DVB2ksCT.js} +4 -4
- package/{figure-9bZNx4iM.js → figure-DjVSSN6M.js} +3 -3
- package/{footnote-CbSZPnS_.js → footnote-CUU3PpfT.js} +2 -2
- package/{graph-BcgGZcap.js → graph-BJc72uU7.js} +2 -2
- package/{hint-DNBGmAUx.js → hint-_mytVHpK.js} +4 -4
- package/{hr-QPW8MOW9.js → hr-CWLmUpy0.js} +2 -2
- package/{image-RdgTJkyJ.js → image-ClTE4iuH.js} +3 -3
- package/{index-BAm6ZYJS.js → index-DP21-YKk.js} +1 -1
- package/{index.es-D22JmNgX.js → index.es-DOHR9mG3.js} +1 -1
- package/index.js +1 -1
- package/{label-Ch4ABCmv.js → label-ttulCvy_.js} +3 -3
- package/{legend-CxBwSOao.js → legend-CGnJ45xO.js} +3 -3
- package/{line-CST9KGTg.js → line-CK-q5MoI.js} +3 -3
- package/{lineSegment-DvuWsavN.js → lineSegment-BURohQkt.js} +3 -3
- package/{list-FfXRWagF.js → list-DFCits_p.js} +3 -3
- package/{lq-CMzJMKYu.js → lq-CnCh2Cek.js} +2 -2
- package/{lsq-CJFVdiGq.js → lsq-Z8YTkngq.js} +2 -2
- package/{math-DLZM_qu3.js → math-DmS2HVnB.js} +3 -3
- package/{mathInput-BRWecq0J.js → mathInput-BK9jtmCy.js} +3 -3
- package/{matrixInput-D9OSOupB.js → matrixInput-B2r-RRoq.js} +3 -3
- package/{mdash-NGpH8PbV.js → mdash-BSnirjtX.js} +2 -2
- package/{nbsp-BkDcEEMd.js → nbsp-DxIPs3C-.js} +2 -2
- package/{ndash-7uwZ0Vtv.js → ndash-BOPV84e3.js} +2 -2
- package/{number-BjW9vouS.js → number-BYuSXu-v.js} +3 -3
- package/{orbitalDiagram-DVfWFW5p.js → orbitalDiagram-eFMJxKTZ.js} +2 -2
- package/{orbitalDiagramInput-TI_kpwe2.js → orbitalDiagramInput-CicG-INc.js} +2 -2
- package/{p-DIRk568L.js → p-DXe2zMsQ.js} +3 -3
- package/package.json +1 -1
- package/{paginatorControls-DtNpYi-3.js → paginatorControls-DBYh7Yws.js} +2 -2
- package/{pegboard-Bd1SmP6c.js → pegboard-DLrRWpOH.js} +3 -3
- package/{point-ajtgi6lk.js → point-BapGaqMw.js} +3 -3
- package/{polygon-DcXyS9Ph.js → polygon-sDXvM8jd.js} +3 -3
- package/{polyline-CRwTNWf5.js → polyline-Cif5rrfX.js} +3 -3
- package/{pre-ISpysPrB.js → pre-zeO-zSVj.js} +3 -3
- package/{pretzel-C-W3KUtT.js → pretzel-BstN2DXP.js} +10 -10
- package/{q-9YAZWbJW.js → q-BUN6d3Fd.js} +3 -3
- package/{ray-DTvHO_-L.js → ray-BS6bApZ0.js} +3 -3
- package/{ref-D633sFJy.js → ref-B15YsZxi.js} +2 -2
- package/{regionBetweenCurveXAxis-DNfFew93.js → regionBetweenCurveXAxis-BFdzcUTg.js} +3 -3
- package/{regionBetweenCurves-CLA-Zsiq.js → regionBetweenCurves-5M_ZSELl.js} +3 -3
- package/{row-CV1QCTA0.js → row-CAjl4Ibp.js} +2 -2
- package/{rq-BRPvlvjn.js → rq-DLZgaomf.js} +2 -2
- package/{rsq-BQMfhXNb.js → rsq-BOdq6ZBb.js} +2 -2
- package/{section-DT_Z-23R.js → section-CqM5HBbU.js} +4 -4
- package/{sideBySide-Dtp5c9BG.js → sideBySide-Dhds4V3W.js} +2 -2
- package/{slider-BFyzacAf.js → slider-CMIx3Y1_.js} +2 -2
- package/{solution-1VBLNvz4.js → solution-DJEdQYGt.js} +4 -4
- package/{spreadsheet-MfSFcH3t.js → spreadsheet-F_qMPeut.js} +2 -2
- package/{sq-n0NGxzEy.js → sq-MhOLnvCm.js} +3 -3
- package/style.css +6 -16
- package/{subsetOfRealsInput-CkL6dCxk.js → subsetOfRealsInput-BIHaW2VJ.js} +2 -2
- package/{summaryStatistics-CWXqxbd3.js → summaryStatistics-DxOXNQ_g.js} +2 -2
- package/{table-CPAT4aYa.js → table-DUxrWqxG.js} +2 -2
- package/{tabular-smi1xfCS.js → tabular-p1MDkcGW.js} +2 -2
- package/{tag-DOduYdqv.js → tag--bKUwRVR.js} +2 -2
- package/{text-Da5gA47C.js → text-D33ED9K_.js} +3 -3
- package/{textInput-Ct1xd6qU.js → textInput-ksnzYkPE.js} +4 -4
- package/useDoenetRenderer-DaxiEBL2.js +109 -0
- package/{vector-D_QrHdix.js → vector-DnhsbMGp.js} +3 -3
- package/{video-eWJTnq9V.js → video-gio1LNIF.js} +2 -2
- package/Viewer/renderers/utils/AnswerResponseMenu.d.ts.map +0 -1
- package/checkwork-Bq0PLxIc.js +0 -1320
- package/useDoenetRenderer-CA8ny0Vp.js +0 -109
|
@@ -0,0 +1,841 @@
|
|
|
1
|
+
import { w as createPopoverStore, x as __spreadProps, y as defaultValue, z as __spreadValues, G as createStore, H as useStoreProps, I as usePopoverStoreProps, J as useStore, K as createStoreContext, P as PopoverScopedContextProvider, L as PopoverContextProvider, N as createHook, O as __objRest, Q as invariant, R as usePortalRef, S as useIsMouseMoving, U as useBooleanEvent, V as chain, W as addGlobalEventListener, X as useLiveRef, Y as useSafeLayoutEffect, Z as useWrapElement, j as jsxRuntimeExports, $ as __spreadProps$1, a0 as useMergeRefs, a1 as __spreadValues$1, a2 as usePopover, a3 as isFalsyBooleanCallback, a4 as contains, a5 as useEvent, a6 as sync, a7 as hasFocusWithin, a8 as createDialogComponent, a9 as forwardRef2, aa as createElement, ab as disabledFromProps, ac as useFocusable, ad as Button$1 } from "./doenetml-sRNYlCqd.js";
|
|
2
|
+
import { useRef, useState, useEffect, useContext, createContext, useCallback } from "react";
|
|
3
|
+
import { F as FontAwesomeIcon } from "./index.es-DOHR9mG3.js";
|
|
4
|
+
import { a as faLevelDownAlt, b as faCheck, c as faTimes, d as faCloud } from "./index-CS9Bi7Fd.js";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
function createHovercardStore(props = {}) {
|
|
7
|
+
var _a;
|
|
8
|
+
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
9
|
+
const popover = createPopoverStore(__spreadProps(__spreadValues({}, props), {
|
|
10
|
+
placement: defaultValue(
|
|
11
|
+
props.placement,
|
|
12
|
+
syncState == null ? void 0 : syncState.placement,
|
|
13
|
+
"bottom"
|
|
14
|
+
)
|
|
15
|
+
}));
|
|
16
|
+
const timeout = defaultValue(props.timeout, syncState == null ? void 0 : syncState.timeout, 500);
|
|
17
|
+
const initialState = __spreadProps(__spreadValues({}, popover.getState()), {
|
|
18
|
+
timeout,
|
|
19
|
+
showTimeout: defaultValue(props.showTimeout, syncState == null ? void 0 : syncState.showTimeout),
|
|
20
|
+
hideTimeout: defaultValue(props.hideTimeout, syncState == null ? void 0 : syncState.hideTimeout),
|
|
21
|
+
autoFocusOnShow: defaultValue(syncState == null ? void 0 : syncState.autoFocusOnShow, false)
|
|
22
|
+
});
|
|
23
|
+
const hovercard = createStore(initialState, popover, props.store);
|
|
24
|
+
return __spreadProps(__spreadValues(__spreadValues({}, popover), hovercard), {
|
|
25
|
+
setAutoFocusOnShow: (value) => hovercard.setState("autoFocusOnShow", value)
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function useHovercardStoreProps(store, update, props) {
|
|
29
|
+
useStoreProps(store, props, "timeout");
|
|
30
|
+
useStoreProps(store, props, "showTimeout");
|
|
31
|
+
useStoreProps(store, props, "hideTimeout");
|
|
32
|
+
return usePopoverStoreProps(store, update, props);
|
|
33
|
+
}
|
|
34
|
+
function createTooltipStore(props = {}) {
|
|
35
|
+
var _a;
|
|
36
|
+
if (process.env.NODE_ENV !== "production") {
|
|
37
|
+
if (props.type === "label") {
|
|
38
|
+
console.warn(
|
|
39
|
+
"The `type` option on the tooltip store is deprecated.",
|
|
40
|
+
"Render a visually hidden label or use the `aria-label` or `aria-labelledby` attributes on the anchor element instead.",
|
|
41
|
+
"See https://ariakit.org/components/tooltip#tooltip-anchors-must-have-accessible-names"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
46
|
+
const hovercard = createHovercardStore(__spreadProps(__spreadValues({}, props), {
|
|
47
|
+
placement: defaultValue(
|
|
48
|
+
props.placement,
|
|
49
|
+
syncState == null ? void 0 : syncState.placement,
|
|
50
|
+
"top"
|
|
51
|
+
),
|
|
52
|
+
hideTimeout: defaultValue(props.hideTimeout, syncState == null ? void 0 : syncState.hideTimeout, 0)
|
|
53
|
+
}));
|
|
54
|
+
const initialState = __spreadProps(__spreadValues({}, hovercard.getState()), {
|
|
55
|
+
type: defaultValue(props.type, syncState == null ? void 0 : syncState.type, "description"),
|
|
56
|
+
skipTimeout: defaultValue(props.skipTimeout, syncState == null ? void 0 : syncState.skipTimeout, 300)
|
|
57
|
+
});
|
|
58
|
+
const tooltip = createStore(initialState, hovercard, props.store);
|
|
59
|
+
return __spreadValues(__spreadValues({}, hovercard), tooltip);
|
|
60
|
+
}
|
|
61
|
+
function useTooltipStoreProps(store, update, props) {
|
|
62
|
+
useStoreProps(store, props, "type");
|
|
63
|
+
useStoreProps(store, props, "skipTimeout");
|
|
64
|
+
return useHovercardStoreProps(store, update, props);
|
|
65
|
+
}
|
|
66
|
+
function useTooltipStore(props = {}) {
|
|
67
|
+
const [store, update] = useStore(createTooltipStore, props);
|
|
68
|
+
return useTooltipStoreProps(store, update, props);
|
|
69
|
+
}
|
|
70
|
+
var ctx$1 = createStoreContext(
|
|
71
|
+
[PopoverContextProvider],
|
|
72
|
+
[PopoverScopedContextProvider]
|
|
73
|
+
);
|
|
74
|
+
ctx$1.useContext;
|
|
75
|
+
ctx$1.useScopedContext;
|
|
76
|
+
var useHovercardProviderContext = ctx$1.useProviderContext;
|
|
77
|
+
var HovercardContextProvider = ctx$1.ContextProvider;
|
|
78
|
+
var HovercardScopedContextProvider = ctx$1.ScopedContextProvider;
|
|
79
|
+
var ctx = createStoreContext(
|
|
80
|
+
[HovercardContextProvider],
|
|
81
|
+
[HovercardScopedContextProvider]
|
|
82
|
+
);
|
|
83
|
+
var useTooltipProviderContext = ctx.useProviderContext;
|
|
84
|
+
var TooltipContextProvider = ctx.ContextProvider;
|
|
85
|
+
var TooltipScopedContextProvider = ctx.ScopedContextProvider;
|
|
86
|
+
function getEventPoint(event) {
|
|
87
|
+
return [event.clientX, event.clientY];
|
|
88
|
+
}
|
|
89
|
+
function isPointInPolygon(point, polygon) {
|
|
90
|
+
const [x, y] = point;
|
|
91
|
+
let inside = false;
|
|
92
|
+
const length = polygon.length;
|
|
93
|
+
for (let l = length, i = 0, j = l - 1; i < l; j = i++) {
|
|
94
|
+
const [xi, yi] = polygon[i];
|
|
95
|
+
const [xj, yj] = polygon[j];
|
|
96
|
+
const [, vy] = polygon[j === 0 ? l - 1 : j - 1] || [0, 0];
|
|
97
|
+
const where = (yi - yj) * (x - xi) - (xi - xj) * (y - yi);
|
|
98
|
+
if (yj < yi) {
|
|
99
|
+
if (y >= yj && y < yi) {
|
|
100
|
+
if (where === 0) return true;
|
|
101
|
+
if (where > 0) {
|
|
102
|
+
if (y === yj) {
|
|
103
|
+
if (y > vy) {
|
|
104
|
+
inside = !inside;
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
inside = !inside;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} else if (yi < yj) {
|
|
112
|
+
if (y > yi && y <= yj) {
|
|
113
|
+
if (where === 0) return true;
|
|
114
|
+
if (where < 0) {
|
|
115
|
+
if (y === yj) {
|
|
116
|
+
if (y < vy) {
|
|
117
|
+
inside = !inside;
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
inside = !inside;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
} else if (y === yi && (x >= xj && x <= xi || x >= xi && x <= xj)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return inside;
|
|
129
|
+
}
|
|
130
|
+
function getEnterPointPlacement(enterPoint, rect) {
|
|
131
|
+
const { top, right, bottom, left } = rect;
|
|
132
|
+
const [x, y] = enterPoint;
|
|
133
|
+
const placementX = x < left ? "left" : x > right ? "right" : null;
|
|
134
|
+
const placementY = y < top ? "top" : y > bottom ? "bottom" : null;
|
|
135
|
+
return [placementX, placementY];
|
|
136
|
+
}
|
|
137
|
+
function getElementPolygon(element, enterPoint) {
|
|
138
|
+
const rect = element.getBoundingClientRect();
|
|
139
|
+
const { top, right, bottom, left } = rect;
|
|
140
|
+
const [x, y] = getEnterPointPlacement(enterPoint, rect);
|
|
141
|
+
const polygon = [enterPoint];
|
|
142
|
+
if (x) {
|
|
143
|
+
if (y !== "top") {
|
|
144
|
+
polygon.push([x === "left" ? left : right, top]);
|
|
145
|
+
}
|
|
146
|
+
polygon.push([x === "left" ? right : left, top]);
|
|
147
|
+
polygon.push([x === "left" ? right : left, bottom]);
|
|
148
|
+
if (y !== "bottom") {
|
|
149
|
+
polygon.push([x === "left" ? left : right, bottom]);
|
|
150
|
+
}
|
|
151
|
+
} else if (y === "top") {
|
|
152
|
+
polygon.push([left, top]);
|
|
153
|
+
polygon.push([left, bottom]);
|
|
154
|
+
polygon.push([right, bottom]);
|
|
155
|
+
polygon.push([right, top]);
|
|
156
|
+
} else {
|
|
157
|
+
polygon.push([left, bottom]);
|
|
158
|
+
polygon.push([left, top]);
|
|
159
|
+
polygon.push([right, top]);
|
|
160
|
+
polygon.push([right, bottom]);
|
|
161
|
+
}
|
|
162
|
+
return polygon;
|
|
163
|
+
}
|
|
164
|
+
var TagName$3 = "div";
|
|
165
|
+
function isMovingOnHovercard(target, card, anchor, nested) {
|
|
166
|
+
if (hasFocusWithin(card)) return true;
|
|
167
|
+
if (!target) return false;
|
|
168
|
+
if (contains(card, target)) return true;
|
|
169
|
+
if (anchor && contains(anchor, target)) return true;
|
|
170
|
+
if (nested == null ? void 0 : nested.some((card2) => isMovingOnHovercard(target, card2, anchor))) {
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
function useAutoFocusOnHide(_a) {
|
|
176
|
+
var _b = _a, {
|
|
177
|
+
store
|
|
178
|
+
} = _b, props = __objRest(_b, [
|
|
179
|
+
"store"
|
|
180
|
+
]);
|
|
181
|
+
const [autoFocusOnHide, setAutoFocusOnHide] = useState(false);
|
|
182
|
+
const mounted = store.useState("mounted");
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
if (!mounted) {
|
|
185
|
+
setAutoFocusOnHide(false);
|
|
186
|
+
}
|
|
187
|
+
}, [mounted]);
|
|
188
|
+
const onFocusProp = props.onFocus;
|
|
189
|
+
const onFocus = useEvent((event) => {
|
|
190
|
+
onFocusProp == null ? void 0 : onFocusProp(event);
|
|
191
|
+
if (event.defaultPrevented) return;
|
|
192
|
+
setAutoFocusOnHide(true);
|
|
193
|
+
});
|
|
194
|
+
const finalFocusRef = useRef(null);
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
return sync(store, ["anchorElement"], (state) => {
|
|
197
|
+
finalFocusRef.current = state.anchorElement;
|
|
198
|
+
});
|
|
199
|
+
}, []);
|
|
200
|
+
props = __spreadProps$1(__spreadValues$1({
|
|
201
|
+
autoFocusOnHide,
|
|
202
|
+
finalFocus: finalFocusRef
|
|
203
|
+
}, props), {
|
|
204
|
+
onFocus
|
|
205
|
+
});
|
|
206
|
+
return props;
|
|
207
|
+
}
|
|
208
|
+
var NestedHovercardContext = createContext(null);
|
|
209
|
+
var useHovercard = createHook(
|
|
210
|
+
function useHovercard2(_a) {
|
|
211
|
+
var _b = _a, {
|
|
212
|
+
store,
|
|
213
|
+
modal = false,
|
|
214
|
+
portal = !!modal,
|
|
215
|
+
hideOnEscape = true,
|
|
216
|
+
hideOnHoverOutside = true,
|
|
217
|
+
disablePointerEventsOnApproach = !!hideOnHoverOutside
|
|
218
|
+
} = _b, props = __objRest(_b, [
|
|
219
|
+
"store",
|
|
220
|
+
"modal",
|
|
221
|
+
"portal",
|
|
222
|
+
"hideOnEscape",
|
|
223
|
+
"hideOnHoverOutside",
|
|
224
|
+
"disablePointerEventsOnApproach"
|
|
225
|
+
]);
|
|
226
|
+
const context = useHovercardProviderContext();
|
|
227
|
+
store = store || context;
|
|
228
|
+
invariant(
|
|
229
|
+
store,
|
|
230
|
+
process.env.NODE_ENV !== "production" && "Hovercard must receive a `store` prop or be wrapped in a HovercardProvider component."
|
|
231
|
+
);
|
|
232
|
+
const ref = useRef(null);
|
|
233
|
+
const [nestedHovercards, setNestedHovercards] = useState([]);
|
|
234
|
+
const hideTimeoutRef = useRef(0);
|
|
235
|
+
const enterPointRef = useRef(null);
|
|
236
|
+
const { portalRef, domReady } = usePortalRef(portal, props.portalRef);
|
|
237
|
+
const isMouseMoving = useIsMouseMoving();
|
|
238
|
+
const mayHideOnHoverOutside = !!hideOnHoverOutside;
|
|
239
|
+
const hideOnHoverOutsideProp = useBooleanEvent(hideOnHoverOutside);
|
|
240
|
+
const mayDisablePointerEvents = !!disablePointerEventsOnApproach;
|
|
241
|
+
const disablePointerEventsProp = useBooleanEvent(
|
|
242
|
+
disablePointerEventsOnApproach
|
|
243
|
+
);
|
|
244
|
+
const open = store.useState("open");
|
|
245
|
+
const mounted = store.useState("mounted");
|
|
246
|
+
useEffect(() => {
|
|
247
|
+
if (!domReady) return;
|
|
248
|
+
if (!mounted) return;
|
|
249
|
+
if (!mayHideOnHoverOutside && !mayDisablePointerEvents) return;
|
|
250
|
+
const element = ref.current;
|
|
251
|
+
if (!element) return;
|
|
252
|
+
const onMouseMove = (event) => {
|
|
253
|
+
if (!store) return;
|
|
254
|
+
if (!isMouseMoving()) return;
|
|
255
|
+
const { anchorElement, hideTimeout, timeout } = store.getState();
|
|
256
|
+
const enterPoint = enterPointRef.current;
|
|
257
|
+
const [target] = event.composedPath();
|
|
258
|
+
const anchor = anchorElement;
|
|
259
|
+
if (isMovingOnHovercard(target, element, anchor, nestedHovercards)) {
|
|
260
|
+
enterPointRef.current = target && anchor && contains(anchor, target) ? getEventPoint(event) : null;
|
|
261
|
+
window.clearTimeout(hideTimeoutRef.current);
|
|
262
|
+
hideTimeoutRef.current = 0;
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (hideTimeoutRef.current) return;
|
|
266
|
+
if (enterPoint) {
|
|
267
|
+
const currentPoint = getEventPoint(event);
|
|
268
|
+
const polygon = getElementPolygon(element, enterPoint);
|
|
269
|
+
if (isPointInPolygon(currentPoint, polygon)) {
|
|
270
|
+
enterPointRef.current = currentPoint;
|
|
271
|
+
if (!disablePointerEventsProp(event)) return;
|
|
272
|
+
event.preventDefault();
|
|
273
|
+
event.stopPropagation();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (!hideOnHoverOutsideProp(event)) return;
|
|
278
|
+
hideTimeoutRef.current = window.setTimeout(() => {
|
|
279
|
+
hideTimeoutRef.current = 0;
|
|
280
|
+
store == null ? void 0 : store.hide();
|
|
281
|
+
}, hideTimeout != null ? hideTimeout : timeout);
|
|
282
|
+
};
|
|
283
|
+
return chain(
|
|
284
|
+
addGlobalEventListener("mousemove", onMouseMove, true),
|
|
285
|
+
() => clearTimeout(hideTimeoutRef.current)
|
|
286
|
+
);
|
|
287
|
+
}, [
|
|
288
|
+
store,
|
|
289
|
+
isMouseMoving,
|
|
290
|
+
domReady,
|
|
291
|
+
mounted,
|
|
292
|
+
mayHideOnHoverOutside,
|
|
293
|
+
mayDisablePointerEvents,
|
|
294
|
+
nestedHovercards,
|
|
295
|
+
disablePointerEventsProp,
|
|
296
|
+
hideOnHoverOutsideProp
|
|
297
|
+
]);
|
|
298
|
+
useEffect(() => {
|
|
299
|
+
if (!domReady) return;
|
|
300
|
+
if (!mounted) return;
|
|
301
|
+
if (!mayDisablePointerEvents) return;
|
|
302
|
+
const disableEvent = (event) => {
|
|
303
|
+
const element = ref.current;
|
|
304
|
+
if (!element) return;
|
|
305
|
+
const enterPoint = enterPointRef.current;
|
|
306
|
+
if (!enterPoint) return;
|
|
307
|
+
const polygon = getElementPolygon(element, enterPoint);
|
|
308
|
+
if (isPointInPolygon(getEventPoint(event), polygon)) {
|
|
309
|
+
if (!disablePointerEventsProp(event)) return;
|
|
310
|
+
event.preventDefault();
|
|
311
|
+
event.stopPropagation();
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
return chain(
|
|
315
|
+
// Note: we may need to add pointer events here in the future.
|
|
316
|
+
addGlobalEventListener("mouseenter", disableEvent, true),
|
|
317
|
+
addGlobalEventListener("mouseover", disableEvent, true),
|
|
318
|
+
addGlobalEventListener("mouseout", disableEvent, true),
|
|
319
|
+
addGlobalEventListener("mouseleave", disableEvent, true)
|
|
320
|
+
);
|
|
321
|
+
}, [domReady, mounted, mayDisablePointerEvents, disablePointerEventsProp]);
|
|
322
|
+
useEffect(() => {
|
|
323
|
+
if (!domReady) return;
|
|
324
|
+
if (open) return;
|
|
325
|
+
store == null ? void 0 : store.setAutoFocusOnShow(false);
|
|
326
|
+
}, [store, domReady, open]);
|
|
327
|
+
const openRef = useLiveRef(open);
|
|
328
|
+
useEffect(() => {
|
|
329
|
+
if (!domReady) return;
|
|
330
|
+
return () => {
|
|
331
|
+
if (!openRef.current) {
|
|
332
|
+
store == null ? void 0 : store.setAutoFocusOnShow(false);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
}, [store, domReady]);
|
|
336
|
+
const registerOnParent = useContext(NestedHovercardContext);
|
|
337
|
+
useSafeLayoutEffect(() => {
|
|
338
|
+
if (modal) return;
|
|
339
|
+
if (!portal) return;
|
|
340
|
+
if (!mounted) return;
|
|
341
|
+
if (!domReady) return;
|
|
342
|
+
const element = ref.current;
|
|
343
|
+
if (!element) return;
|
|
344
|
+
return registerOnParent == null ? void 0 : registerOnParent(element);
|
|
345
|
+
}, [modal, portal, mounted, domReady]);
|
|
346
|
+
const registerNestedHovercard = useCallback(
|
|
347
|
+
(element) => {
|
|
348
|
+
setNestedHovercards((prevElements) => [...prevElements, element]);
|
|
349
|
+
const parentUnregister = registerOnParent == null ? void 0 : registerOnParent(element);
|
|
350
|
+
return () => {
|
|
351
|
+
setNestedHovercards(
|
|
352
|
+
(prevElements) => prevElements.filter((item) => item !== element)
|
|
353
|
+
);
|
|
354
|
+
parentUnregister == null ? void 0 : parentUnregister();
|
|
355
|
+
};
|
|
356
|
+
},
|
|
357
|
+
[registerOnParent]
|
|
358
|
+
);
|
|
359
|
+
props = useWrapElement(
|
|
360
|
+
props,
|
|
361
|
+
(element) => /* @__PURE__ */ jsxRuntimeExports.jsx(HovercardScopedContextProvider, { value: store, children: /* @__PURE__ */ jsxRuntimeExports.jsx(NestedHovercardContext.Provider, { value: registerNestedHovercard, children: element }) }),
|
|
362
|
+
[store, registerNestedHovercard]
|
|
363
|
+
);
|
|
364
|
+
props = __spreadProps$1(__spreadValues$1({}, props), {
|
|
365
|
+
ref: useMergeRefs(ref, props.ref)
|
|
366
|
+
});
|
|
367
|
+
props = useAutoFocusOnHide(__spreadValues$1({ store }, props));
|
|
368
|
+
const autoFocusOnShow = store.useState(
|
|
369
|
+
(state) => modal || state.autoFocusOnShow
|
|
370
|
+
);
|
|
371
|
+
props = usePopover(__spreadProps$1(__spreadValues$1({
|
|
372
|
+
store,
|
|
373
|
+
modal,
|
|
374
|
+
portal,
|
|
375
|
+
autoFocusOnShow
|
|
376
|
+
}, props), {
|
|
377
|
+
portalRef,
|
|
378
|
+
hideOnEscape(event) {
|
|
379
|
+
if (isFalsyBooleanCallback(hideOnEscape, event)) return false;
|
|
380
|
+
requestAnimationFrame(() => {
|
|
381
|
+
requestAnimationFrame(() => {
|
|
382
|
+
store == null ? void 0 : store.hide();
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
return true;
|
|
386
|
+
}
|
|
387
|
+
}));
|
|
388
|
+
return props;
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
createDialogComponent(
|
|
392
|
+
forwardRef2(function Hovercard2(props) {
|
|
393
|
+
const htmlProps = useHovercard(props);
|
|
394
|
+
return createElement(TagName$3, htmlProps);
|
|
395
|
+
}),
|
|
396
|
+
useHovercardProviderContext
|
|
397
|
+
);
|
|
398
|
+
var TagName$2 = "div";
|
|
399
|
+
var useTooltip = createHook(
|
|
400
|
+
function useTooltip2(_a) {
|
|
401
|
+
var _b = _a, {
|
|
402
|
+
store,
|
|
403
|
+
portal = true,
|
|
404
|
+
gutter = 8,
|
|
405
|
+
preserveTabOrder = false,
|
|
406
|
+
hideOnHoverOutside = true,
|
|
407
|
+
hideOnInteractOutside = true
|
|
408
|
+
} = _b, props = __objRest(_b, [
|
|
409
|
+
"store",
|
|
410
|
+
"portal",
|
|
411
|
+
"gutter",
|
|
412
|
+
"preserveTabOrder",
|
|
413
|
+
"hideOnHoverOutside",
|
|
414
|
+
"hideOnInteractOutside"
|
|
415
|
+
]);
|
|
416
|
+
const context = useTooltipProviderContext();
|
|
417
|
+
store = store || context;
|
|
418
|
+
invariant(
|
|
419
|
+
store,
|
|
420
|
+
process.env.NODE_ENV !== "production" && "Tooltip must receive a `store` prop or be wrapped in a TooltipProvider component."
|
|
421
|
+
);
|
|
422
|
+
props = useWrapElement(
|
|
423
|
+
props,
|
|
424
|
+
(element) => /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipScopedContextProvider, { value: store, children: element }),
|
|
425
|
+
[store]
|
|
426
|
+
);
|
|
427
|
+
const role = store.useState(
|
|
428
|
+
(state) => state.type === "description" ? "tooltip" : "none"
|
|
429
|
+
);
|
|
430
|
+
props = __spreadValues$1({ role }, props);
|
|
431
|
+
props = useHovercard(__spreadProps$1(__spreadValues$1({}, props), {
|
|
432
|
+
store,
|
|
433
|
+
portal,
|
|
434
|
+
gutter,
|
|
435
|
+
preserveTabOrder,
|
|
436
|
+
hideOnHoverOutside(event) {
|
|
437
|
+
if (isFalsyBooleanCallback(hideOnHoverOutside, event)) return false;
|
|
438
|
+
const anchorElement = store == null ? void 0 : store.getState().anchorElement;
|
|
439
|
+
if (!anchorElement) return true;
|
|
440
|
+
if ("focusVisible" in anchorElement.dataset) return false;
|
|
441
|
+
return true;
|
|
442
|
+
},
|
|
443
|
+
hideOnInteractOutside: (event) => {
|
|
444
|
+
if (isFalsyBooleanCallback(hideOnInteractOutside, event)) return false;
|
|
445
|
+
const anchorElement = store == null ? void 0 : store.getState().anchorElement;
|
|
446
|
+
if (!anchorElement) return true;
|
|
447
|
+
if (contains(anchorElement, event.target)) return false;
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
}));
|
|
451
|
+
return props;
|
|
452
|
+
}
|
|
453
|
+
);
|
|
454
|
+
var Tooltip = createDialogComponent(
|
|
455
|
+
forwardRef2(function Tooltip2(props) {
|
|
456
|
+
const htmlProps = useTooltip(props);
|
|
457
|
+
return createElement(TagName$2, htmlProps);
|
|
458
|
+
}),
|
|
459
|
+
useTooltipProviderContext
|
|
460
|
+
);
|
|
461
|
+
function TooltipProvider(props = {}) {
|
|
462
|
+
const store = useTooltipStore(props);
|
|
463
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContextProvider, { value: store, children: props.children });
|
|
464
|
+
}
|
|
465
|
+
var TagName$1 = "a";
|
|
466
|
+
var useHovercardAnchor = createHook(
|
|
467
|
+
function useHovercardAnchor2(_a) {
|
|
468
|
+
var _b = _a, { store, showOnHover = true } = _b, props = __objRest(_b, ["store", "showOnHover"]);
|
|
469
|
+
const context = useHovercardProviderContext();
|
|
470
|
+
store = store || context;
|
|
471
|
+
invariant(
|
|
472
|
+
store,
|
|
473
|
+
process.env.NODE_ENV !== "production" && "HovercardAnchor must receive a `store` prop or be wrapped in a HovercardProvider component."
|
|
474
|
+
);
|
|
475
|
+
const disabled = disabledFromProps(props);
|
|
476
|
+
const showTimeoutRef = useRef(0);
|
|
477
|
+
useEffect(() => () => window.clearTimeout(showTimeoutRef.current), []);
|
|
478
|
+
useEffect(() => {
|
|
479
|
+
const onMouseLeave = (event) => {
|
|
480
|
+
if (!store) return;
|
|
481
|
+
const { anchorElement } = store.getState();
|
|
482
|
+
if (!anchorElement) return;
|
|
483
|
+
if (event.target !== anchorElement) return;
|
|
484
|
+
window.clearTimeout(showTimeoutRef.current);
|
|
485
|
+
showTimeoutRef.current = 0;
|
|
486
|
+
};
|
|
487
|
+
return addGlobalEventListener("mouseleave", onMouseLeave, true);
|
|
488
|
+
}, [store]);
|
|
489
|
+
const onMouseMoveProp = props.onMouseMove;
|
|
490
|
+
const showOnHoverProp = useBooleanEvent(showOnHover);
|
|
491
|
+
const isMouseMoving = useIsMouseMoving();
|
|
492
|
+
const onMouseMove = useEvent((event) => {
|
|
493
|
+
onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
|
|
494
|
+
if (disabled) return;
|
|
495
|
+
if (!store) return;
|
|
496
|
+
if (event.defaultPrevented) return;
|
|
497
|
+
if (showTimeoutRef.current) return;
|
|
498
|
+
if (!isMouseMoving()) return;
|
|
499
|
+
if (!showOnHoverProp(event)) return;
|
|
500
|
+
const element = event.currentTarget;
|
|
501
|
+
store.setAnchorElement(element);
|
|
502
|
+
store.setDisclosureElement(element);
|
|
503
|
+
const { showTimeout, timeout } = store.getState();
|
|
504
|
+
const showHovercard = () => {
|
|
505
|
+
showTimeoutRef.current = 0;
|
|
506
|
+
if (!isMouseMoving()) return;
|
|
507
|
+
store == null ? void 0 : store.setAnchorElement(element);
|
|
508
|
+
store == null ? void 0 : store.show();
|
|
509
|
+
queueMicrotask(() => {
|
|
510
|
+
store == null ? void 0 : store.setDisclosureElement(element);
|
|
511
|
+
});
|
|
512
|
+
};
|
|
513
|
+
const timeoutMs = showTimeout != null ? showTimeout : timeout;
|
|
514
|
+
if (timeoutMs === 0) {
|
|
515
|
+
showHovercard();
|
|
516
|
+
} else {
|
|
517
|
+
showTimeoutRef.current = window.setTimeout(showHovercard, timeoutMs);
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
const onClickProp = props.onClick;
|
|
521
|
+
const onClick = useEvent((event) => {
|
|
522
|
+
onClickProp == null ? void 0 : onClickProp(event);
|
|
523
|
+
if (!store) return;
|
|
524
|
+
window.clearTimeout(showTimeoutRef.current);
|
|
525
|
+
showTimeoutRef.current = 0;
|
|
526
|
+
});
|
|
527
|
+
const ref = useCallback(
|
|
528
|
+
(element) => {
|
|
529
|
+
if (!store) return;
|
|
530
|
+
const { anchorElement } = store.getState();
|
|
531
|
+
if (anchorElement == null ? void 0 : anchorElement.isConnected) return;
|
|
532
|
+
store.setAnchorElement(element);
|
|
533
|
+
},
|
|
534
|
+
[store]
|
|
535
|
+
);
|
|
536
|
+
props = __spreadProps$1(__spreadValues$1({}, props), {
|
|
537
|
+
ref: useMergeRefs(ref, props.ref),
|
|
538
|
+
onMouseMove,
|
|
539
|
+
onClick
|
|
540
|
+
});
|
|
541
|
+
props = useFocusable(props);
|
|
542
|
+
return props;
|
|
543
|
+
}
|
|
544
|
+
);
|
|
545
|
+
forwardRef2(function HovercardAnchor2(props) {
|
|
546
|
+
const htmlProps = useHovercardAnchor(props);
|
|
547
|
+
return createElement(TagName$1, htmlProps);
|
|
548
|
+
});
|
|
549
|
+
var TagName = "div";
|
|
550
|
+
var globalStore = createStore({
|
|
551
|
+
activeStore: null
|
|
552
|
+
});
|
|
553
|
+
function createRemoveStoreCallback(store) {
|
|
554
|
+
return () => {
|
|
555
|
+
const { activeStore } = globalStore.getState();
|
|
556
|
+
if (activeStore !== store) return;
|
|
557
|
+
globalStore.setState("activeStore", null);
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
var useTooltipAnchor = createHook(
|
|
561
|
+
function useTooltipAnchor2(_a) {
|
|
562
|
+
var _b = _a, { store, showOnHover = true } = _b, props = __objRest(_b, ["store", "showOnHover"]);
|
|
563
|
+
const context = useTooltipProviderContext();
|
|
564
|
+
store = store || context;
|
|
565
|
+
invariant(
|
|
566
|
+
store,
|
|
567
|
+
process.env.NODE_ENV !== "production" && "TooltipAnchor must receive a `store` prop or be wrapped in a TooltipProvider component."
|
|
568
|
+
);
|
|
569
|
+
const canShowOnHoverRef = useRef(false);
|
|
570
|
+
useEffect(() => {
|
|
571
|
+
return sync(store, ["mounted"], (state) => {
|
|
572
|
+
if (state.mounted) return;
|
|
573
|
+
canShowOnHoverRef.current = false;
|
|
574
|
+
});
|
|
575
|
+
}, [store]);
|
|
576
|
+
useEffect(() => {
|
|
577
|
+
if (!store) return;
|
|
578
|
+
return chain(
|
|
579
|
+
// Immediately remove the current store from the global store when
|
|
580
|
+
// the component unmounts. This is useful, for example, to avoid
|
|
581
|
+
// showing tooltips immediately on serial tests.
|
|
582
|
+
createRemoveStoreCallback(store),
|
|
583
|
+
sync(store, ["mounted", "skipTimeout"], (state) => {
|
|
584
|
+
if (!store) return;
|
|
585
|
+
if (state.mounted) {
|
|
586
|
+
const { activeStore } = globalStore.getState();
|
|
587
|
+
if (activeStore !== store) {
|
|
588
|
+
activeStore == null ? void 0 : activeStore.hide();
|
|
589
|
+
}
|
|
590
|
+
return globalStore.setState("activeStore", store);
|
|
591
|
+
}
|
|
592
|
+
const id = setTimeout(
|
|
593
|
+
createRemoveStoreCallback(store),
|
|
594
|
+
state.skipTimeout
|
|
595
|
+
);
|
|
596
|
+
return () => clearTimeout(id);
|
|
597
|
+
})
|
|
598
|
+
);
|
|
599
|
+
}, [store]);
|
|
600
|
+
const onMouseEnterProp = props.onMouseEnter;
|
|
601
|
+
const onMouseEnter = useEvent((event) => {
|
|
602
|
+
onMouseEnterProp == null ? void 0 : onMouseEnterProp(event);
|
|
603
|
+
canShowOnHoverRef.current = true;
|
|
604
|
+
});
|
|
605
|
+
const onFocusVisibleProp = props.onFocusVisible;
|
|
606
|
+
const onFocusVisible = useEvent((event) => {
|
|
607
|
+
onFocusVisibleProp == null ? void 0 : onFocusVisibleProp(event);
|
|
608
|
+
if (event.defaultPrevented) return;
|
|
609
|
+
store == null ? void 0 : store.setAnchorElement(event.currentTarget);
|
|
610
|
+
store == null ? void 0 : store.show();
|
|
611
|
+
});
|
|
612
|
+
const onBlurProp = props.onBlur;
|
|
613
|
+
const onBlur = useEvent((event) => {
|
|
614
|
+
onBlurProp == null ? void 0 : onBlurProp(event);
|
|
615
|
+
if (event.defaultPrevented) return;
|
|
616
|
+
const { activeStore } = globalStore.getState();
|
|
617
|
+
canShowOnHoverRef.current = false;
|
|
618
|
+
if (activeStore === store) {
|
|
619
|
+
globalStore.setState("activeStore", null);
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
const type = store.useState("type");
|
|
623
|
+
const contentId = store.useState((state) => {
|
|
624
|
+
var _a2;
|
|
625
|
+
return (_a2 = state.contentElement) == null ? void 0 : _a2.id;
|
|
626
|
+
});
|
|
627
|
+
props = __spreadProps$1(__spreadValues$1({
|
|
628
|
+
"aria-labelledby": type === "label" ? contentId : void 0
|
|
629
|
+
}, props), {
|
|
630
|
+
onMouseEnter,
|
|
631
|
+
onFocusVisible,
|
|
632
|
+
onBlur
|
|
633
|
+
});
|
|
634
|
+
props = useHovercardAnchor(__spreadValues$1({
|
|
635
|
+
store,
|
|
636
|
+
showOnHover(event) {
|
|
637
|
+
if (!canShowOnHoverRef.current) return false;
|
|
638
|
+
if (isFalsyBooleanCallback(showOnHover, event)) return false;
|
|
639
|
+
const { activeStore } = globalStore.getState();
|
|
640
|
+
if (!activeStore) return true;
|
|
641
|
+
store == null ? void 0 : store.show();
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
644
|
+
}, props));
|
|
645
|
+
return props;
|
|
646
|
+
}
|
|
647
|
+
);
|
|
648
|
+
var TooltipAnchor = forwardRef2(function TooltipAnchor2(props) {
|
|
649
|
+
const htmlProps = useTooltipAnchor(props);
|
|
650
|
+
return createElement(TagName, htmlProps);
|
|
651
|
+
});
|
|
652
|
+
function AnswerResponseButton({
|
|
653
|
+
answerId,
|
|
654
|
+
answerComponentIdx,
|
|
655
|
+
activityId,
|
|
656
|
+
docId,
|
|
657
|
+
numResponses = 0
|
|
658
|
+
}) {
|
|
659
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(TooltipProvider, { children: [
|
|
660
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipAnchor, { className: "answer-response-tooltip-anchor", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
661
|
+
Button$1,
|
|
662
|
+
{
|
|
663
|
+
className: "doenet-button action-button answer-response-button",
|
|
664
|
+
onClick: () => {
|
|
665
|
+
window.postMessage({
|
|
666
|
+
subject: "requestAnswerResponses",
|
|
667
|
+
answerComponentIdx,
|
|
668
|
+
answerId,
|
|
669
|
+
activityId,
|
|
670
|
+
docId
|
|
671
|
+
});
|
|
672
|
+
},
|
|
673
|
+
children: numResponses
|
|
674
|
+
}
|
|
675
|
+
) }),
|
|
676
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { className: "answer-response-tooltip", children: [
|
|
677
|
+
"Show ",
|
|
678
|
+
numResponses,
|
|
679
|
+
" response",
|
|
680
|
+
numResponses === 1 ? "" : "s",
|
|
681
|
+
" to ",
|
|
682
|
+
answerId
|
|
683
|
+
] })
|
|
684
|
+
] });
|
|
685
|
+
}
|
|
686
|
+
const Button = styled.button`
|
|
687
|
+
position: relative;
|
|
688
|
+
height: 24px;
|
|
689
|
+
display: inline-block;
|
|
690
|
+
color: white;
|
|
691
|
+
background-color: var(--mainBlue);
|
|
692
|
+
padding: 2px;
|
|
693
|
+
/* border: var(--mainBorder); */
|
|
694
|
+
border: none;
|
|
695
|
+
border-radius: var(--mainBorderRadius);
|
|
696
|
+
margin: 0px 4px 4px 0px;
|
|
697
|
+
|
|
698
|
+
&:hover {
|
|
699
|
+
background-color: var(--lightBlue);
|
|
700
|
+
color: black;
|
|
701
|
+
}
|
|
702
|
+
`;
|
|
703
|
+
function createCheckworkComponent(SVs, disabled, id, submitAnswer) {
|
|
704
|
+
let validationState = "unvalidated";
|
|
705
|
+
if (SVs.justSubmitted || SVs.numAttemptsLeft < 1) {
|
|
706
|
+
if (SVs.creditAchieved === 1) {
|
|
707
|
+
validationState = "correct";
|
|
708
|
+
} else if (SVs.creditAchieved === 0) {
|
|
709
|
+
validationState = "incorrect";
|
|
710
|
+
} else {
|
|
711
|
+
validationState = "partialcorrect";
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
let checkWorkStyle = {
|
|
715
|
+
cursor: "pointer",
|
|
716
|
+
padding: "1px 6px 1px 6px"
|
|
717
|
+
};
|
|
718
|
+
let checkWorkTabIndex = "0";
|
|
719
|
+
if (disabled) {
|
|
720
|
+
checkWorkStyle.backgroundColor = getComputedStyle(
|
|
721
|
+
document.documentElement
|
|
722
|
+
).getPropertyValue("--mainGray");
|
|
723
|
+
checkWorkStyle.color = "black";
|
|
724
|
+
checkWorkStyle.cursor = "not-allowed";
|
|
725
|
+
checkWorkTabIndex = "-1";
|
|
726
|
+
}
|
|
727
|
+
let checkWorkText = SVs.submitLabel;
|
|
728
|
+
if (!SVs.showCorrectness) {
|
|
729
|
+
checkWorkText = SVs.submitLabelNoCorrectness;
|
|
730
|
+
}
|
|
731
|
+
let checkworkComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
732
|
+
Button,
|
|
733
|
+
{
|
|
734
|
+
id: id + "_submit",
|
|
735
|
+
tabIndex: +checkWorkTabIndex,
|
|
736
|
+
disabled,
|
|
737
|
+
style: checkWorkStyle,
|
|
738
|
+
onClick: submitAnswer,
|
|
739
|
+
children: [
|
|
740
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
741
|
+
FontAwesomeIcon,
|
|
742
|
+
{
|
|
743
|
+
icon: faLevelDownAlt,
|
|
744
|
+
transform: { rotate: 90 }
|
|
745
|
+
}
|
|
746
|
+
),
|
|
747
|
+
" ",
|
|
748
|
+
checkWorkText
|
|
749
|
+
]
|
|
750
|
+
}
|
|
751
|
+
);
|
|
752
|
+
if (SVs.showCorrectness) {
|
|
753
|
+
if (validationState === "correct") {
|
|
754
|
+
checkWorkStyle.backgroundColor = getComputedStyle(
|
|
755
|
+
document.documentElement
|
|
756
|
+
).getPropertyValue("--mainGreen");
|
|
757
|
+
checkworkComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
758
|
+
Button,
|
|
759
|
+
{
|
|
760
|
+
id: id + "_correct",
|
|
761
|
+
style: checkWorkStyle,
|
|
762
|
+
tabIndex: +checkWorkTabIndex,
|
|
763
|
+
children: [
|
|
764
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FontAwesomeIcon, { icon: faCheck }),
|
|
765
|
+
" Correct"
|
|
766
|
+
]
|
|
767
|
+
}
|
|
768
|
+
);
|
|
769
|
+
} else if (validationState === "incorrect") {
|
|
770
|
+
checkWorkStyle.backgroundColor = getComputedStyle(
|
|
771
|
+
document.documentElement
|
|
772
|
+
).getPropertyValue("--mainRed");
|
|
773
|
+
checkworkComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
774
|
+
Button,
|
|
775
|
+
{
|
|
776
|
+
id: id + "_incorrect",
|
|
777
|
+
style: checkWorkStyle,
|
|
778
|
+
tabIndex: +checkWorkTabIndex,
|
|
779
|
+
children: [
|
|
780
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FontAwesomeIcon, { icon: faTimes }),
|
|
781
|
+
" Incorrect"
|
|
782
|
+
]
|
|
783
|
+
}
|
|
784
|
+
);
|
|
785
|
+
} else if (validationState === "partialcorrect") {
|
|
786
|
+
checkWorkStyle.backgroundColor = "#efab34";
|
|
787
|
+
let percent = Math.round(SVs.creditAchieved * 100);
|
|
788
|
+
let partialCreditContents = `${percent}% Correct`;
|
|
789
|
+
checkworkComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
790
|
+
Button,
|
|
791
|
+
{
|
|
792
|
+
id: id + "_partial",
|
|
793
|
+
style: checkWorkStyle,
|
|
794
|
+
tabIndex: +checkWorkTabIndex,
|
|
795
|
+
children: partialCreditContents
|
|
796
|
+
}
|
|
797
|
+
);
|
|
798
|
+
}
|
|
799
|
+
} else {
|
|
800
|
+
if (validationState !== "unvalidated") {
|
|
801
|
+
checkWorkStyle.backgroundColor = "rgb(74, 3, 217)";
|
|
802
|
+
checkworkComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
803
|
+
Button,
|
|
804
|
+
{
|
|
805
|
+
id: id + "_saved",
|
|
806
|
+
style: checkWorkStyle,
|
|
807
|
+
tabIndex: +checkWorkTabIndex,
|
|
808
|
+
children: [
|
|
809
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FontAwesomeIcon, { icon: faCloud }),
|
|
810
|
+
" Response Saved"
|
|
811
|
+
]
|
|
812
|
+
}
|
|
813
|
+
);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
if (SVs.numAttemptsLeft < 0) {
|
|
817
|
+
checkworkComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
818
|
+
checkworkComponent,
|
|
819
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "(no attempts remaining)" })
|
|
820
|
+
] });
|
|
821
|
+
} else if (SVs.numAttemptsLeft == 1) {
|
|
822
|
+
checkworkComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
823
|
+
checkworkComponent,
|
|
824
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "(1 attempt remaining)" })
|
|
825
|
+
] });
|
|
826
|
+
} else if (Number.isFinite(SVs.numAttemptsLeft)) {
|
|
827
|
+
checkworkComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
828
|
+
checkworkComponent,
|
|
829
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
|
|
830
|
+
"(",
|
|
831
|
+
SVs.numAttemptsLeft,
|
|
832
|
+
" attempts remaining)"
|
|
833
|
+
] })
|
|
834
|
+
] });
|
|
835
|
+
}
|
|
836
|
+
return checkworkComponent;
|
|
837
|
+
}
|
|
838
|
+
export {
|
|
839
|
+
AnswerResponseButton as A,
|
|
840
|
+
createCheckworkComponent as c
|
|
841
|
+
};
|