react-science 20.5.0 → 20.6.1
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/lib/components/accordion/accordion_context_provider.d.ts.map +1 -1
- package/lib/components/accordion/accordion_context_provider.js +1 -1
- package/lib/components/accordion/accordion_context_provider.js.map +1 -1
- package/lib/components/button/Button.d.ts.map +1 -1
- package/lib/components/button/Button.js +6 -5
- package/lib/components/button/Button.js.map +1 -1
- package/lib/components/color-picker/index.d.ts +2 -0
- package/lib/components/color-picker/index.d.ts.map +1 -1
- package/lib/components/color-picker/index.js +1 -0
- package/lib/components/color-picker/index.js.map +1 -1
- package/lib/components/color-picker/preview/ColorPreview.d.ts +1 -8
- package/lib/components/color-picker/preview/ColorPreview.d.ts.map +1 -1
- package/lib/components/color-picker/preview/ColorPreview.js +1 -1
- package/lib/components/color-picker/preview/ColorPreview.js.map +1 -1
- package/lib/components/color-picker/preview/color_config.d.ts +14 -0
- package/lib/components/color-picker/preview/color_config.d.ts.map +1 -0
- package/lib/components/color-picker/preview/color_config.js +11 -0
- package/lib/components/color-picker/preview/color_config.js.map +1 -0
- package/lib/components/draggable/draggable.d.ts +18 -0
- package/lib/components/draggable/draggable.d.ts.map +1 -0
- package/lib/components/draggable/draggable.js +70 -0
- package/lib/components/draggable/draggable.js.map +1 -0
- package/lib/components/form/components/field_groups/svg_line_style.d.ts +2 -0
- package/lib/components/form/components/field_groups/svg_line_style.d.ts.map +1 -1
- package/lib/components/form/components/field_groups/svg_text_style.d.ts +2 -0
- package/lib/components/form/components/field_groups/svg_text_style.d.ts.map +1 -1
- package/lib/components/form/components/input/draggable_numeric_input.d.ts +10 -0
- package/lib/components/form/components/input/draggable_numeric_input.d.ts.map +1 -0
- package/lib/components/form/components/input/draggable_numeric_input.js +29 -0
- package/lib/components/form/components/input/draggable_numeric_input.js.map +1 -0
- package/lib/components/form/components/input/index.d.ts +1 -0
- package/lib/components/form/components/input/index.d.ts.map +1 -1
- package/lib/components/form/components/input/numeric_input.d.ts +1 -2
- package/lib/components/form/components/input/numeric_input.d.ts.map +1 -1
- package/lib/components/form/components/input/numeric_input.js.map +1 -1
- package/lib/components/form/components/input_groups/form_group.d.ts +1 -0
- package/lib/components/form/components/input_groups/form_group.d.ts.map +1 -1
- package/lib/components/form/components/input_groups/form_group.js +4 -4
- package/lib/components/form/components/input_groups/form_group.js.map +1 -1
- package/lib/components/form/components/layout/form.d.ts +1 -0
- package/lib/components/form/components/layout/form.d.ts.map +1 -1
- package/lib/components/form/context/use_ts_form.d.ts +7 -0
- package/lib/components/form/context/use_ts_form.d.ts.map +1 -1
- package/lib/components/form/context/use_ts_form.js +2 -0
- package/lib/components/form/context/use_ts_form.js.map +1 -1
- package/lib/components/table/reorder_rows/draggable_row_tr.js +1 -1
- package/lib/components/table/reorder_rows/draggable_row_tr.js.map +1 -1
- package/lib/components/table/reorder_rows/use_drop_monitor.d.ts.map +1 -1
- package/lib/components/table/reorder_rows/use_drop_monitor.js +1 -1
- package/lib/components/table/reorder_rows/use_drop_monitor.js.map +1 -1
- package/lib/components/utils/assert.d.ts +13 -0
- package/lib/components/utils/assert.d.ts.map +1 -1
- package/lib/components/utils/assert.js +13 -0
- package/lib/components/utils/assert.js.map +1 -1
- package/lib/components/utils/svg.js +1 -1
- package/lib/components/utils/svg.js.map +1 -1
- package/package.json +2 -1
- package/src/components/accordion/accordion_context_provider.tsx +1 -2
- package/src/components/button/Button.tsx +7 -4
- package/src/components/color-picker/index.ts +5 -0
- package/src/components/color-picker/preview/ColorPreview.tsx +2 -6
- package/src/components/color-picker/preview/color_config.ts +29 -0
- package/src/components/draggable/draggable.tsx +127 -0
- package/src/components/form/components/input/draggable_numeric_input.tsx +107 -0
- package/src/components/form/components/input/index.ts +1 -0
- package/src/components/form/components/input/numeric_input.tsx +2 -1
- package/src/components/form/components/input_groups/form_group.tsx +10 -3
- package/src/components/form/context/use_ts_form.ts +2 -0
- package/src/components/table/reorder_rows/draggable_row_tr.tsx +1 -1
- package/src/components/table/reorder_rows/use_drop_monitor.ts +1 -1
- package/src/components/utils/assert.ts +13 -0
- package/src/components/utils/svg.ts +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { attachClosestEdge, combine, draggable, dropTargetForElements, extractClosestEdge, pointerOutsideOfPreview, setCustomNativeDragPreview, } from '@zakodium/pdnd-esm';
|
|
3
|
+
import { assert } from '@zakodium/utils';
|
|
3
4
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
4
5
|
import { createPortal } from 'react-dom';
|
|
5
|
-
import { assert } from '../../utils/index.js';
|
|
6
6
|
import { useFlashRowEffect } from '../flash_row/use_flash_row_effect.js';
|
|
7
7
|
import { PreviewTable } from '../preview_table.js';
|
|
8
8
|
import { useIsPreviewTable } from '../preview_table_context.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draggable_row_tr.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/draggable_row_tr.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"draggable_row_tr.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/draggable_row_tr.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAA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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_drop_monitor.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/use_drop_monitor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use_drop_monitor.d.ts","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/use_drop_monitor.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,EAC3C,OAAO,EAAE,OAAO,QAsDjB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { autoScrollForElements, combine, extractClosestEdge, monitorForElements, } from '@zakodium/pdnd-esm';
|
|
2
|
+
import { assert } from '@zakodium/utils';
|
|
2
3
|
import { useEffect } from 'react';
|
|
3
|
-
import { assert } from '../../utils/index.js';
|
|
4
4
|
import { useFlashedRowContext } from '../flash_row/flashed_row_context.js';
|
|
5
5
|
import { isItemData } from './item_data.js';
|
|
6
6
|
import { useItemOrder } from './item_order_context.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_drop_monitor.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/use_drop_monitor.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"use_drop_monitor.js","sourceRoot":"","sources":["../../../../src/components/table/reorder_rows/use_drop_monitor.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OA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,EAAE,CACpC,CAAC;gBACF,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE,CAAC;oBACzB,OAAO;gBACT,CAAC;gBAED,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;gBAE3D,WAAW,CAAC;oBACV,UAAU,EAAE,UAAU,CAAC,KAAK;oBAC5B,aAAa;oBACb,mBAAmB;iBACpB,CAAC,CAAC;gBACH,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAC/B,CAAC;SACF,CAAC,EACF,qBAAqB,CAAC;YACpB,SAAS,EAAE,UAAU;YACrB,OAAO,EAAE,eAAe;SACzB,CAAC,CACH,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param x
|
|
3
|
+
* @deprecated Use `assertUnreachable` from `@zakodium/utils`
|
|
4
|
+
*/
|
|
1
5
|
export declare function assertUnreachable(x: never): never;
|
|
6
|
+
/**
|
|
7
|
+
* @param x
|
|
8
|
+
* @deprecated Use `assertNotNullish` from `@zakodium/utils`
|
|
9
|
+
*/
|
|
2
10
|
export declare function assertNotNull<T>(value: T | null | undefined): asserts value is Exclude<T, null | undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* @param value
|
|
13
|
+
* @param message
|
|
14
|
+
* @deprecated Use `assert` from `@zakodium/utils`
|
|
15
|
+
*/
|
|
3
16
|
export declare function assert(value: unknown, message?: string): asserts value;
|
|
4
17
|
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/components/utils/assert.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAEjD;AAED,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAC1B,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,CAO/C;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAItE"}
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/components/utils/assert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAEjD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAC1B,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,CAO/C;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAItE"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param x
|
|
3
|
+
* @deprecated Use `assertUnreachable` from `@zakodium/utils`
|
|
4
|
+
*/
|
|
1
5
|
export function assertUnreachable(x) {
|
|
2
6
|
throw new Error(`unreachable: ${String(x)}`);
|
|
3
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* @param x
|
|
10
|
+
* @deprecated Use `assertNotNullish` from `@zakodium/utils`
|
|
11
|
+
*/
|
|
4
12
|
export function assertNotNull(value) {
|
|
5
13
|
if (value === null) {
|
|
6
14
|
throw new Error('unexpected null value');
|
|
@@ -9,6 +17,11 @@ export function assertNotNull(value) {
|
|
|
9
17
|
throw new Error('unexpected undefined value');
|
|
10
18
|
}
|
|
11
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* @param value
|
|
22
|
+
* @param message
|
|
23
|
+
* @deprecated Use `assert` from `@zakodium/utils`
|
|
24
|
+
*/
|
|
12
25
|
export function assert(value, message) {
|
|
13
26
|
if (!value) {
|
|
14
27
|
throw new Error(`unreachable${message ? `: ${message}` : ''}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../src/components/utils/assert.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,CAAQ;IACxC,MAAM,IAAI,KAAK,CAAC,gBAAgB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,KAA2B;IAE3B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAc,EAAE,OAAgB;IACrD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,cAAc,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACjE,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../src/components/utils/assert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAQ;IACxC,MAAM,IAAI,KAAK,CAAC,gBAAgB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,KAA2B;IAE3B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc,EAAE,OAAgB;IACrD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,cAAc,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACjE,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../../../src/components/utils/svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../../../src/components/utils/svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AA+BzC;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,IAAmB,EACnB,UAA4B,EAAE;IAE9B,MAAM,EACJ,kBAAkB,EAClB,aAAa,GAAG,KAAK,EACrB,eAAe,GAAG,OAAO,EACzB,eAAe,GAChB,GAAG,OAAO,CAAC;IAEZ,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAkB,CAAC;IAElD,cAAc;IACd,IAAI,kBAAkB,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,GAAG,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;QACvD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,UAAU,GAAG,QAAQ,CAAC,eAAe;QACzC,2FAA2F;QAC3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,YAAY,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IACxE,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,CAAC,GAAG,CAAC,CAAC;IAEZ,IAAI,aAAa,EAAE,CAAC;QAClB,GAAG,CAAC,SAAS,GAAG,eAAe,CAAC;QAChC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;IAED,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAEzB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IAC9D,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-science",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.6.1",
|
|
4
4
|
"description": "React components to build scientific applications UI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"@tanstack/react-table": "^8.21.3",
|
|
64
64
|
"@tanstack/react-virtual": "^3.14.6",
|
|
65
65
|
"@zakodium/pdnd-esm": "^1.1.0",
|
|
66
|
+
"@zakodium/utils": "^0.4.1",
|
|
66
67
|
"d3-scale-chromatic": "^3.1.0",
|
|
67
68
|
"react-d3-utils": "^3.1.2",
|
|
68
69
|
"react-dropzone": "^17.0.0",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { assert } from '@zakodium/utils';
|
|
1
2
|
import type { ReactNode } from 'react';
|
|
2
3
|
import { useMemo, useRef } from 'react';
|
|
3
4
|
|
|
4
|
-
import { assert } from '../utils/index.js';
|
|
5
|
-
|
|
6
5
|
import type { AccordionContextValue } from './accordion_context.js';
|
|
7
6
|
import { accordionContext } from './accordion_context.js';
|
|
8
7
|
import type { AccordionItemSetIsOpen } from './accordion_context_utils.js';
|
|
@@ -42,25 +42,27 @@ const ButtonTag = styled(Tag)`
|
|
|
42
42
|
|
|
43
43
|
interface InnerButtonProps {
|
|
44
44
|
isIconButton: boolean;
|
|
45
|
+
isTagButton: boolean;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
/*
|
|
48
49
|
Setting the line-height makes sure that when passing regular text in icons instead of an svg, they are vertically centered
|
|
49
50
|
max-width makes sure buttons with tag or hoverability indicator (both implying absolutely positioned elements) keep their intended width
|
|
50
|
-
When a button just has an icon, we override BP styles and remove the margin-right
|
|
51
|
+
When a button just has an icon with a tag, we override BP styles and remove the margin-right to keep the layout correct.
|
|
51
52
|
*/
|
|
52
|
-
const buttonStyles = ({ isIconButton }: InnerButtonProps) => `
|
|
53
|
+
const buttonStyles = ({ isIconButton, isTagButton }: InnerButtonProps) => `
|
|
53
54
|
line-height: 1em;
|
|
54
55
|
position: relative;
|
|
55
56
|
max-width: ${isIconButton ? '30px' : 'none'};
|
|
56
57
|
|
|
57
58
|
& .${Classes.ICON} {
|
|
58
|
-
${isIconButton ? 'margin-right: 0px;' : ''}
|
|
59
|
+
${isIconButton && isTagButton ? 'margin-right: 0px;' : ''}
|
|
59
60
|
}
|
|
60
61
|
`;
|
|
61
62
|
|
|
63
|
+
const propsToIgnore = new Set(['isIconButton', 'isTagButton']);
|
|
62
64
|
function shouldForwardButtonProp(propName: string) {
|
|
63
|
-
return propName
|
|
65
|
+
return !propsToIgnore.has(propName);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
const TooltipAnchorButton = styled(AnchorButton, {
|
|
@@ -99,6 +101,7 @@ export function Button(props: ButtonProps) {
|
|
|
99
101
|
{...targetProps}
|
|
100
102
|
{...buttonProps}
|
|
101
103
|
isIconButton={!children && !buttonProps.text}
|
|
104
|
+
isTagButton={Boolean(tag)}
|
|
102
105
|
>
|
|
103
106
|
{tag && (
|
|
104
107
|
<ButtonTag round intent="success" {...tagProps}>
|
|
@@ -3,3 +3,8 @@ export * from './gradient_select/index.js';
|
|
|
3
3
|
export * from './preview/ColorPreview.js';
|
|
4
4
|
export * from './react-color/ColorPicker.js';
|
|
5
5
|
export * from './palette.js';
|
|
6
|
+
export {
|
|
7
|
+
assertColorFixed,
|
|
8
|
+
assertColorGradient,
|
|
9
|
+
} from './preview/color_config.ts';
|
|
10
|
+
export type { ColorConfig } from './preview/color_config.ts';
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { assertUnreachable } from '
|
|
2
|
-
import type { GradientScaleName } from '../gradient_select/index.js';
|
|
1
|
+
import { assertUnreachable } from '@zakodium/utils';
|
|
3
2
|
|
|
4
3
|
import FixedColorPreview from './FixedColorPreview.js';
|
|
5
4
|
import FixedGradientPreview from './FixedGradientPreview.js';
|
|
6
|
-
|
|
7
|
-
export type ColorConfig =
|
|
8
|
-
| { kind: 'fixed'; color: string }
|
|
9
|
-
| { kind: 'fixedGradient'; gradient: GradientScaleName };
|
|
5
|
+
import type { ColorConfig } from './color_config.ts';
|
|
10
6
|
|
|
11
7
|
export interface ColorPreviewProps {
|
|
12
8
|
color: ColorConfig;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { GradientScaleName } from '../gradient_select/index.ts';
|
|
2
|
+
|
|
3
|
+
interface ColorConfigFixed {
|
|
4
|
+
kind: 'fixed';
|
|
5
|
+
color: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ColorConfigGradient {
|
|
9
|
+
kind: 'fixedGradient';
|
|
10
|
+
gradient: GradientScaleName;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ColorConfig = ColorConfigFixed | ColorConfigGradient;
|
|
14
|
+
|
|
15
|
+
export function assertColorFixed(
|
|
16
|
+
color: ColorConfig,
|
|
17
|
+
): asserts color is ColorConfigFixed {
|
|
18
|
+
if (color.kind !== 'fixed') {
|
|
19
|
+
throw new Error('Only fixed colors are supported');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function assertColorGradient(
|
|
24
|
+
color: ColorConfig,
|
|
25
|
+
): asserts color is ColorConfigGradient {
|
|
26
|
+
if (color.kind !== 'fixedGradient') {
|
|
27
|
+
throw new Error('Only fixed colors are supported');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Intent } from '@blueprintjs/core';
|
|
2
|
+
import { Classes, Utils } from '@blueprintjs/core';
|
|
3
|
+
import styled from '@emotion/styled';
|
|
4
|
+
import { clamp } from '@zakodium/utils';
|
|
5
|
+
import type { MouseEvent as ReactMouseEvent, ReactNode } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
7
|
+
import { match } from 'ts-pattern';
|
|
8
|
+
|
|
9
|
+
interface DraggableProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
value: number;
|
|
12
|
+
onChange: (_: number, value: string) => void;
|
|
13
|
+
onBlur: () => void;
|
|
14
|
+
step?: number;
|
|
15
|
+
min?: number;
|
|
16
|
+
max?: number;
|
|
17
|
+
intent: Intent;
|
|
18
|
+
majorStepSize?: number | null;
|
|
19
|
+
minorStepSize?: number | null;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const DraggableContainer = styled.div`
|
|
24
|
+
width: 100%;
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
user-select: none;
|
|
29
|
+
cursor: ew-resize;
|
|
30
|
+
height: 100%;
|
|
31
|
+
min-height: 30px;
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
const DraggableLabel = styled.span`
|
|
35
|
+
white-space: nowrap;
|
|
36
|
+
text-overflow: ellipsis;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
max-width: 100%;
|
|
39
|
+
padding-left: 5px;
|
|
40
|
+
padding-right: 5px;
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
export function Draggable(props: DraggableProps) {
|
|
44
|
+
const {
|
|
45
|
+
children,
|
|
46
|
+
value,
|
|
47
|
+
onChange,
|
|
48
|
+
onBlur,
|
|
49
|
+
step: stepSize = 1,
|
|
50
|
+
min,
|
|
51
|
+
max,
|
|
52
|
+
intent,
|
|
53
|
+
majorStepSize,
|
|
54
|
+
minorStepSize,
|
|
55
|
+
className,
|
|
56
|
+
} = props;
|
|
57
|
+
|
|
58
|
+
const draggedValueRef = useRef(value);
|
|
59
|
+
const onChangeRef = useRef(onChange);
|
|
60
|
+
const previousPositionRef = useRef<number>(0);
|
|
61
|
+
const isDraggingRef = useRef<boolean>(false);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
function handleMouseMove(event: MouseEvent) {
|
|
65
|
+
if (!isDraggingRef.current) return;
|
|
66
|
+
|
|
67
|
+
const diff = event.clientX - previousPositionRef.current;
|
|
68
|
+
previousPositionRef.current = event.clientX;
|
|
69
|
+
|
|
70
|
+
if (event.buttons === 1) {
|
|
71
|
+
const step = match(event)
|
|
72
|
+
.with({ shiftKey: true }, () => majorStepSize ?? stepSize)
|
|
73
|
+
.with({ altKey: true }, () => minorStepSize ?? stepSize)
|
|
74
|
+
.otherwise(() => stepSize);
|
|
75
|
+
|
|
76
|
+
const precision = Math.max(
|
|
77
|
+
Utils.countDecimalPlaces(draggedValueRef.current),
|
|
78
|
+
Utils.countDecimalPlaces(minorStepSize ?? stepSize),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const nextValue = toMaxPrecision(
|
|
82
|
+
draggedValueRef.current + diff * step,
|
|
83
|
+
precision,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
draggedValueRef.current = clamp(nextValue, min, max);
|
|
87
|
+
onChangeRef.current(0, String(draggedValueRef.current));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function handleMouseUp() {
|
|
92
|
+
isDraggingRef.current = false;
|
|
93
|
+
onBlur();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
window.addEventListener('mousemove', handleMouseMove);
|
|
97
|
+
window.addEventListener('mouseup', handleMouseUp);
|
|
98
|
+
|
|
99
|
+
return () => {
|
|
100
|
+
window.removeEventListener('mousemove', handleMouseMove);
|
|
101
|
+
window.removeEventListener('mouseup', handleMouseUp);
|
|
102
|
+
};
|
|
103
|
+
}, [majorStepSize, max, min, minorStepSize, onBlur, stepSize]);
|
|
104
|
+
|
|
105
|
+
const handleMouseDown = useCallback(
|
|
106
|
+
(event: ReactMouseEvent) => {
|
|
107
|
+
isDraggingRef.current = true;
|
|
108
|
+
previousPositionRef.current = event.clientX;
|
|
109
|
+
draggedValueRef.current = value;
|
|
110
|
+
},
|
|
111
|
+
[value],
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<DraggableContainer
|
|
116
|
+
onMouseDown={handleMouseDown}
|
|
117
|
+
className={`${className} ${Classes.TAG} ${Classes.MINIMAL} ${Classes.intentClass(intent)}`}
|
|
118
|
+
>
|
|
119
|
+
<DraggableLabel>{children}</DraggableLabel>
|
|
120
|
+
</DraggableContainer>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function toMaxPrecision(value: number, maxPrecision: number) {
|
|
125
|
+
const scaleFactor = 10 ** maxPrecision;
|
|
126
|
+
return Math.round(value * scaleFactor) / scaleFactor;
|
|
127
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Intent } from '@blueprintjs/core';
|
|
2
|
+
import { NumericInput as BPNumericInput } from '@blueprintjs/core';
|
|
3
|
+
import styled from '@emotion/styled';
|
|
4
|
+
|
|
5
|
+
import { Draggable as InputDraggable } from '../../../draggable/draggable.tsx';
|
|
6
|
+
import { useFieldContext } from '../../context/use_ts_form.ts';
|
|
7
|
+
import { getIntent } from '../../utils/use_intent.ts';
|
|
8
|
+
import { FormGroup } from '../input_groups/index.ts';
|
|
9
|
+
|
|
10
|
+
import type { NumericInputProps } from './numeric_input.tsx';
|
|
11
|
+
|
|
12
|
+
interface DraggableNumericInputProps extends NumericInputProps {
|
|
13
|
+
draggableLabel: string;
|
|
14
|
+
draggableIntent?: Intent;
|
|
15
|
+
hideInput?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const DraggableNumericInputContainer = styled.div`
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: row;
|
|
21
|
+
gap: 5px;
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
const Draggable = styled(InputDraggable)`
|
|
25
|
+
flex: 1;
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
export function DraggableNumericInput(props: DraggableNumericInputProps) {
|
|
29
|
+
const {
|
|
30
|
+
label,
|
|
31
|
+
required,
|
|
32
|
+
helpText,
|
|
33
|
+
placeholder,
|
|
34
|
+
step,
|
|
35
|
+
min,
|
|
36
|
+
max,
|
|
37
|
+
layout,
|
|
38
|
+
fullWidth,
|
|
39
|
+
draggableLabel,
|
|
40
|
+
draggableIntent = 'success',
|
|
41
|
+
hideInput = false,
|
|
42
|
+
majorStepSize,
|
|
43
|
+
minorStepSize,
|
|
44
|
+
...otherProps
|
|
45
|
+
} = props;
|
|
46
|
+
|
|
47
|
+
const field = useFieldContext<string>();
|
|
48
|
+
const error = field
|
|
49
|
+
.getMeta()
|
|
50
|
+
.errors.map((e) => e.message)
|
|
51
|
+
.at(0);
|
|
52
|
+
|
|
53
|
+
const intent = getIntent(error);
|
|
54
|
+
|
|
55
|
+
function onChange(_: number, valueAsString: string) {
|
|
56
|
+
return field.handleChange(valueAsString);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<FormGroup
|
|
61
|
+
name={field.name}
|
|
62
|
+
label={label}
|
|
63
|
+
intent={intent}
|
|
64
|
+
required={required}
|
|
65
|
+
helpText={helpText}
|
|
66
|
+
layout={layout}
|
|
67
|
+
error={undefined}
|
|
68
|
+
fullWidth={fullWidth}
|
|
69
|
+
contentFullWidth
|
|
70
|
+
>
|
|
71
|
+
<DraggableNumericInputContainer>
|
|
72
|
+
{!hideInput && (
|
|
73
|
+
<BPNumericInput
|
|
74
|
+
{...otherProps}
|
|
75
|
+
id={field.name}
|
|
76
|
+
name={field.name}
|
|
77
|
+
stepSize={step}
|
|
78
|
+
min={min}
|
|
79
|
+
max={max}
|
|
80
|
+
majorStepSize={majorStepSize}
|
|
81
|
+
minorStepSize={minorStepSize}
|
|
82
|
+
value={field.state.value ?? ''}
|
|
83
|
+
onValueChange={onChange}
|
|
84
|
+
onBlur={field.handleBlur}
|
|
85
|
+
intent={intent}
|
|
86
|
+
placeholder={placeholder}
|
|
87
|
+
required={required}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
|
|
91
|
+
<Draggable
|
|
92
|
+
value={Number(field.state.value)}
|
|
93
|
+
onBlur={field.handleBlur}
|
|
94
|
+
onChange={onChange}
|
|
95
|
+
step={step}
|
|
96
|
+
min={min}
|
|
97
|
+
max={max}
|
|
98
|
+
majorStepSize={majorStepSize}
|
|
99
|
+
minorStepSize={minorStepSize}
|
|
100
|
+
intent={draggableIntent}
|
|
101
|
+
>
|
|
102
|
+
{draggableLabel}
|
|
103
|
+
</Draggable>
|
|
104
|
+
</DraggableNumericInputContainer>
|
|
105
|
+
</FormGroup>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
@@ -11,3 +11,4 @@ export type {
|
|
|
11
11
|
} from './select.js';
|
|
12
12
|
export type { SubmitButton as _SubmitButton } from './submit_button.js';
|
|
13
13
|
export type { Switch as _Switch } from './switch.js';
|
|
14
|
+
export type { DraggableNumericInput as _DraggableNumericInput } from './draggable_numeric_input.js';
|
|
@@ -6,7 +6,8 @@ import { getIntent } from '../../utils/use_intent.js';
|
|
|
6
6
|
import type { FormGroupInputProps } from '../input_groups/form_group.js';
|
|
7
7
|
import { FormGroup } from '../input_groups/form_group.js';
|
|
8
8
|
|
|
9
|
-
interface NumericInputProps
|
|
9
|
+
export interface NumericInputProps
|
|
10
|
+
extends FormGroupInputProps, BPNumericInputProps {
|
|
10
11
|
step?: number;
|
|
11
12
|
min?: number;
|
|
12
13
|
max?: number;
|
|
@@ -16,7 +16,7 @@ const FormContainer = styled.div<{
|
|
|
16
16
|
display: grid;
|
|
17
17
|
margin: 0;
|
|
18
18
|
grid-template-columns: ${(props) =>
|
|
19
|
-
props.layout === 'inline' ? '[label]
|
|
19
|
+
props.layout === 'inline' ? '[label] 3fr [input] 7fr' : '1fr'};
|
|
20
20
|
gap: 5px 20px;
|
|
21
21
|
grid-template-rows: ${(props) =>
|
|
22
22
|
props.layout === 'inline' ? 'auto auto' : 'auto'};
|
|
@@ -29,6 +29,7 @@ const RequiredSpan = styled.span`
|
|
|
29
29
|
const ContainerElement = styled.div<{
|
|
30
30
|
height?: number | 'auto';
|
|
31
31
|
fullWidth?: boolean;
|
|
32
|
+
contentFullWidth?: boolean;
|
|
32
33
|
layout?: Layout;
|
|
33
34
|
}>`
|
|
34
35
|
display: inline-block;
|
|
@@ -40,7 +41,7 @@ const ContainerElement = styled.div<{
|
|
|
40
41
|
: '1 / -1'};
|
|
41
42
|
height: ${(props) =>
|
|
42
43
|
props.height === 'auto' ? props.height : `${props.height}px`};
|
|
43
|
-
width: fit-content;
|
|
44
|
+
width: ${(props) => (props.contentFullWidth ? '100%' : 'fit-content')};
|
|
44
45
|
min-width: 180px;
|
|
45
46
|
`;
|
|
46
47
|
|
|
@@ -85,6 +86,7 @@ interface FormGroupProps {
|
|
|
85
86
|
error?: string;
|
|
86
87
|
layout?: Layout;
|
|
87
88
|
fullWidth?: boolean;
|
|
89
|
+
contentFullWidth?: boolean;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
export function FormGroup(props: FormGroupProps) {
|
|
@@ -98,6 +100,7 @@ export function FormGroup(props: FormGroupProps) {
|
|
|
98
100
|
error,
|
|
99
101
|
layout,
|
|
100
102
|
fullWidth = false,
|
|
103
|
+
contentFullWidth = false,
|
|
101
104
|
} = props;
|
|
102
105
|
|
|
103
106
|
const { layout: formLayout } = useFormContext();
|
|
@@ -122,7 +125,11 @@ export function FormGroup(props: FormGroupProps) {
|
|
|
122
125
|
)}
|
|
123
126
|
</Label>
|
|
124
127
|
)}
|
|
125
|
-
<ContainerElement
|
|
128
|
+
<ContainerElement
|
|
129
|
+
fullWidth={fullWidth}
|
|
130
|
+
layout={layout || formLayout}
|
|
131
|
+
contentFullWidth={contentFullWidth}
|
|
132
|
+
>
|
|
126
133
|
{children}
|
|
127
134
|
|
|
128
135
|
<ErrorAndHelpText>
|
|
@@ -2,6 +2,7 @@ import { createFormHook, createFormHookContexts } from '@tanstack/react-form';
|
|
|
2
2
|
|
|
3
3
|
import { Checkbox } from '../components/input/checkbox.js';
|
|
4
4
|
import { ColorPicker } from '../components/input/color_picker.tsx';
|
|
5
|
+
import { DraggableNumericInput } from '../components/input/draggable_numeric_input.js';
|
|
5
6
|
import { Input } from '../components/input/input.js';
|
|
6
7
|
import { NumericInput } from '../components/input/numeric_input.js';
|
|
7
8
|
import { RadioGroup } from '../components/input/radio_group.js';
|
|
@@ -37,6 +38,7 @@ const { useAppForm, withForm, withFieldGroup } = createFormHook({
|
|
|
37
38
|
Switch,
|
|
38
39
|
ColorPicker,
|
|
39
40
|
RadioGroup,
|
|
41
|
+
DraggableNumericInput,
|
|
40
42
|
},
|
|
41
43
|
});
|
|
42
44
|
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
pointerOutsideOfPreview,
|
|
10
10
|
setCustomNativeDragPreview,
|
|
11
11
|
} from '@zakodium/pdnd-esm';
|
|
12
|
+
import { assert } from '@zakodium/utils';
|
|
12
13
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
13
14
|
import { createPortal } from 'react-dom';
|
|
14
15
|
|
|
15
|
-
import { assert } from '../../utils/index.js';
|
|
16
16
|
import { useFlashRowEffect } from '../flash_row/use_flash_row_effect.js';
|
|
17
17
|
import { PreviewTable } from '../preview_table.js';
|
|
18
18
|
import { useIsPreviewTable } from '../preview_table_context.js';
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
extractClosestEdge,
|
|
6
6
|
monitorForElements,
|
|
7
7
|
} from '@zakodium/pdnd-esm';
|
|
8
|
+
import { assert } from '@zakodium/utils';
|
|
8
9
|
import type { RefObject } from 'react';
|
|
9
10
|
import { useEffect } from 'react';
|
|
10
11
|
|
|
11
|
-
import { assert } from '../../utils/index.js';
|
|
12
12
|
import { useFlashedRowContext } from '../flash_row/flashed_row_context.js';
|
|
13
13
|
|
|
14
14
|
import { isItemData } from './item_data.js';
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param x
|
|
3
|
+
* @deprecated Use `assertUnreachable` from `@zakodium/utils`
|
|
4
|
+
*/
|
|
1
5
|
export function assertUnreachable(x: never): never {
|
|
2
6
|
throw new Error(`unreachable: ${String(x)}`);
|
|
3
7
|
}
|
|
4
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @param x
|
|
11
|
+
* @deprecated Use `assertNotNullish` from `@zakodium/utils`
|
|
12
|
+
*/
|
|
5
13
|
export function assertNotNull<T>(
|
|
6
14
|
value: T | null | undefined,
|
|
7
15
|
): asserts value is Exclude<T, null | undefined> {
|
|
@@ -13,6 +21,11 @@ export function assertNotNull<T>(
|
|
|
13
21
|
}
|
|
14
22
|
}
|
|
15
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @param value
|
|
26
|
+
* @param message
|
|
27
|
+
* @deprecated Use `assert` from `@zakodium/utils`
|
|
28
|
+
*/
|
|
16
29
|
export function assert(value: unknown, message?: string): asserts value {
|
|
17
30
|
if (!value) {
|
|
18
31
|
throw new Error(`unreachable${message ? `: ${message}` : ''}`);
|