kiokuko-dsh 0.1.36 → 0.1.37
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/client.cjs +41 -5
- package/dist/client.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -365,6 +365,8 @@ window.__ModuleLoader__.load({
|
|
|
365
365
|
const pending = props.pending;
|
|
366
366
|
const question = pending.questions[0];
|
|
367
367
|
const searchable = isEnnoSearchQuestion(question);
|
|
368
|
+
const mac = /Mac|iPhone|iPad|iPod/u.test(globalThis.navigator?.platform ?? '');
|
|
369
|
+
const shortcutModifier = mac ? 'Cmd' : 'Ctrl';
|
|
368
370
|
const [draft, setDraft] = useState(() => intakeDrafts.get(pending) ?? { selected: null, custom: '' });
|
|
369
371
|
const [busy, setBusy] = useState(false);
|
|
370
372
|
const [error, setError] = useState('');
|
|
@@ -424,7 +426,37 @@ window.__ModuleLoader__.load({
|
|
|
424
426
|
setError(cause instanceof Error ? cause.message : String(cause));
|
|
425
427
|
});
|
|
426
428
|
};
|
|
429
|
+
const selectShortcut = (event) => {
|
|
430
|
+
if (busy || inFlight.current || event.repeat || event.isComposing || event.keyCode === 229
|
|
431
|
+
|| event.nativeEvent?.isComposing || event.nativeEvent?.keyCode === 229 || event.altKey || event.shiftKey
|
|
432
|
+
|| !(mac ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey))
|
|
433
|
+
return false;
|
|
434
|
+
const digit = /^(?:Digit|Numpad)([1-9])$/u.exec(event.code ?? '')?.[1] ?? event.key;
|
|
435
|
+
if (!/^[1-9]$/u.test(digit) || Number(digit) > question.options.length)
|
|
436
|
+
return false;
|
|
437
|
+
event.preventDefault();
|
|
438
|
+
event.stopPropagation();
|
|
439
|
+
update({ selected: Number(digit) - 1, custom: '' });
|
|
440
|
+
card.current?.focus();
|
|
441
|
+
return true;
|
|
442
|
+
};
|
|
443
|
+
useEffect(() => {
|
|
444
|
+
const element = card.current;
|
|
445
|
+
const owner = element?.ownerDocument;
|
|
446
|
+
if (!owner)
|
|
447
|
+
return;
|
|
448
|
+
// Capture before the host's composer handlers, even if it has moved focus.
|
|
449
|
+
// Only the visible, mounted question owns these modified shortcuts.
|
|
450
|
+
const listener = (event) => {
|
|
451
|
+
if (element.isConnected && element.getClientRects().length > 0)
|
|
452
|
+
selectShortcut(event);
|
|
453
|
+
};
|
|
454
|
+
owner.addEventListener('keydown', listener, true);
|
|
455
|
+
return () => owner.removeEventListener('keydown', listener, true);
|
|
456
|
+
}, [pending, busy, mac]);
|
|
427
457
|
const keyDown = (event) => {
|
|
458
|
+
if (selectShortcut(event))
|
|
459
|
+
return;
|
|
428
460
|
if (busy || inFlight.current || event.repeat || event.nativeEvent?.isComposing || event.nativeEvent?.keyCode === 229
|
|
429
461
|
|| event.ctrlKey || event.altKey || event.metaKey || event.shiftKey)
|
|
430
462
|
return;
|
|
@@ -460,12 +492,13 @@ window.__ModuleLoader__.load({
|
|
|
460
492
|
jsxs('div', { className: 'kiokuko-intake-body', children: [
|
|
461
493
|
question.detail ? jsx('p', { children: question.detail }) : null,
|
|
462
494
|
jsx('p', { children: question.options.length > 9
|
|
463
|
-
?
|
|
464
|
-
:
|
|
495
|
+
? `${shortcutModifier}+1〜9で選択、Enterで確定。10以上は番号(1〜${question.options.length})を数字で続けて入力、Backspaceで訂正できます。`
|
|
496
|
+
: `${shortcutModifier}+1〜${question.options.length}で選択、Enterで確定。` }),
|
|
465
497
|
jsx('div', { 'aria-label': '選択肢', children: question.options.map((option, index) => jsxs('button', {
|
|
466
498
|
key: option.label, type: 'button', className: 'kiokuko-intake-option', disabled: busy,
|
|
467
499
|
ref: (element) => { optionElements.current[index] = element; },
|
|
468
|
-
'aria-pressed': draft.selected === index,
|
|
500
|
+
'aria-pressed': draft.selected === index,
|
|
501
|
+
...(index < 9 ? { 'aria-keyshortcuts': `${question.options.length <= 9 ? `${index + 1} ` : ''}${mac ? 'Meta' : 'Control'}+${index + 1}` } : {}),
|
|
469
502
|
onClick: () => update({ selected: index, custom: '' }),
|
|
470
503
|
onKeyDown: (event) => {
|
|
471
504
|
if (event.key !== 'Enter' || event.repeat || event.shiftKey || event.ctrlKey || event.altKey || event.metaKey || event.nativeEvent?.isComposing || event.nativeEvent?.keyCode === 229 || (intakeDrafts.get(pending) ?? draft).selected !== index)
|
|
@@ -474,7 +507,8 @@ window.__ModuleLoader__.load({
|
|
|
474
507
|
event.stopPropagation();
|
|
475
508
|
settle();
|
|
476
509
|
},
|
|
477
|
-
children: [jsx('strong', { children: `${index + 1}. ${option.label}` }), option.description ? jsx('span', { children: option.description }) : null
|
|
510
|
+
children: [jsx('strong', { children: `${index + 1}. ${option.label}` }), option.description ? jsx('span', { children: option.description }) : null,
|
|
511
|
+
jsx('kbd', { className: 'kiokuko-intake-shortcut', 'aria-hidden': true, children: index < 9 ? `${shortcutModifier}+${index + 1}` : `${index + 1} → Enter` })],
|
|
478
512
|
})) }),
|
|
479
513
|
jsx('label', { htmlFor: `${titleId}-custom`, children: searchable ? '検索(Enterで検索・数字も検索語として入力できます)' : '自由入力(任意)' }),
|
|
480
514
|
jsx('textarea', { id: `${titleId}-custom`, rows: 1, disabled: busy, value: draft.custom,
|
|
@@ -500,7 +534,9 @@ window.__ModuleLoader__.load({
|
|
|
500
534
|
.kiokuko-intake p{margin:0;white-space:pre-wrap;line-height:1.4;font-size:12px}
|
|
501
535
|
.kiokuko-intake button{font:inherit;color:inherit;background:transparent;border:1px solid var(--dsw-alias-border-l4,#bbb);border-radius:8px;padding:8px 10px;min-height:40px;cursor:pointer}
|
|
502
536
|
.kiokuko-intake button:disabled{cursor:default;opacity:.6}
|
|
503
|
-
.kiokuko-intake-option{display:
|
|
537
|
+
.kiokuko-intake-option{display:grid;grid-template-columns:minmax(0,1fr) max-content;width:100%;text-align:left;gap:4px 12px;margin-bottom:6px;overflow-wrap:anywhere}
|
|
538
|
+
.kiokuko-intake-option strong,.kiokuko-intake-option span{grid-column:1}
|
|
539
|
+
.kiokuko-intake-shortcut{grid-column:2;grid-row:1 / span 2;align-self:center;font-family:inherit;font-size:11px;line-height:1.4;white-space:nowrap}
|
|
504
540
|
.kiokuko-intake-option:last-child{margin-bottom:0}
|
|
505
541
|
.kiokuko-intake-option[aria-pressed=true]{border-color:var(--dsw-alias-label-primary,CanvasText);box-shadow:inset 0 0 0 1px currentColor;background:var(--dsw-alias-interactive-bg-hover,#eee)}
|
|
506
542
|
.kiokuko-intake-option span{font-size:12px;line-height:1.4}
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,UAAU,wBAAwB;IAChC,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;QAAE,cAAc,IAAI,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAA;KAAE,CAAC,CAAA;IAC7G,QAAQ,EAAE;QAAE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CACxC;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,wBAAwB,CAAA;CAC3C;AAYD,UAAU,gBAAgB;IACxB,QAAQ,CAAC,cAAc,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE;YAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAAA;SAAE,CAAA;KAAE,CAAA;IACxF,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,YAA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