@cartanova/qgrid-cli 2.12.0 → 2.13.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/README.ko.md +1 -1
- package/README.md +1 -1
- package/bundle/dist/_virtual/{_@oxc-project_runtime@0.140.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/decorate.js +1 -1
- package/bundle/dist/_virtual/{_@oxc-project_runtime@0.140.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/decorateMetadata.js +1 -1
- package/bundle/dist/_virtual/_rolldown/runtime.js +2 -2
- package/bundle/dist/application/monit/monit.frame.js +2 -2
- package/bundle/dist/application/qgrid/qgrid-run-lifecycle.js +3 -3
- package/bundle/dist/application/qgrid/qgrid.dispatcher.js +1 -1
- package/bundle/dist/application/qgrid/qgrid.frame.js +6 -6
- package/bundle/dist/application/qgrid/qgrid.types.js +8 -8
- package/bundle/dist/application/qgrid/token-death.js +3 -2
- package/bundle/dist/application/qgrid/token-subscriber.js +2 -2
- package/bundle/dist/application/qgrid/token-window-keepalive.js +2 -2
- package/bundle/dist/application/qgrid/tool-emulation-schema.js +5 -3
- package/bundle/dist/application/qgrid/tool-emulation.js +2 -2
- package/bundle/dist/application/request-log/request-log.model.js +9 -7
- package/bundle/dist/application/request-log-step/request-log-step.model.js +11 -7
- package/bundle/dist/application/setting/setting.model.js +11 -7
- package/bundle/dist/application/token/token.model.js +15 -11
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +7 -5
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/schema.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +15 -11
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft2020.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/next.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitContains.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +1 -1
- package/bundle/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +1 -1
- package/bundle/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +1 -1
- package/bundle/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js +18 -12
- package/bundle/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js +1 -1
- package/bundle/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js +16 -13
- package/bundle/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +1 -1
- package/bundle/dist/sonamu.config.js +11 -11
- package/bundle/dist/startup-migrations.js +1 -1
- package/bundle/dist/utils/providers/anthropic/anthropic-dispatcher.js +3 -2
- package/bundle/dist/utils/providers/anthropic/anthropic-thinking.js +5 -2
- package/bundle/dist/utils/providers/anthropic/stream-json-adapter.js +9 -7
- package/bundle/dist/utils/providers/common/model-cost.js +7 -5
- package/bundle/dist/utils/providers/common/schema-validation.js +3 -3
- package/bundle/dist/utils/providers/grok/grok-constants.js +1 -1
- package/bundle/dist/utils/providers/grok/grok-dispatcher.js +5 -3
- package/bundle/dist/utils/providers/grok/grok-media-client.js +4 -4
- package/bundle/dist/utils/providers/grok/grok-oauth.js +2 -2
- package/bundle/dist/utils/providers/openai/openai-dispatcher.js +8 -6
- package/bundle/dist/utils/providers/openai/openai-image-generation.js +4 -4
- package/bundle/src/application/qgrid/qgrid.frame.test.ts +3 -2
- package/bundle/src/application/qgrid/qgrid.types.ts +5 -5
- package/bundle/src/application/request-log/request-log.model.ts +1 -1
- package/bundle/src/sonamu.config.ts +14 -14
- package/bundle/src/utils/providers/common/model-cost.ts +8 -6
- package/bundle/src/utils/providers/grok/grok-constants.ts +7 -8
- package/bundle/web-dist/client/assets/clsx-DB0hHKMi.js +1 -0
- package/bundle/web-dist/client/assets/cost-CZzlCFS2.js +1 -0
- package/bundle/web-dist/client/assets/index-DLo1QCw7.css +1 -0
- package/bundle/web-dist/client/assets/index-DplV-wqZ.js +104 -0
- package/bundle/web-dist/client/assets/logs-st46aRba.js +1 -0
- package/bundle/web-dist/client/assets/monit-BMXR2tY2.js +1 -0
- package/bundle/web-dist/client/assets/plus-Bab0ACnC.js +1 -0
- package/bundle/web-dist/client/assets/refresh-cw-BtYoFHVw.js +1 -0
- package/bundle/web-dist/client/assets/request-model-Dl31cZdf.js +1 -0
- package/bundle/web-dist/client/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/bundle/web-dist/client/assets/routes-BWPjgvhg.js +5 -0
- package/bundle/web-dist/client/assets/settings-DTXZjDAw.js +1 -0
- package/bundle/web-dist/client/assets/show-CdWNFPyS.js +2 -0
- package/bundle/web-dist/client/assets/tokens-eA34Gw5f.js +1 -0
- package/bundle/web-dist/client/assets/use-oauth-login-flow-CcUdLsa7.js +1 -0
- package/bundle/web-dist/client/assets/use-update-token-mutation-D2r5K5Bz.js +1 -0
- package/bundle/web-dist/client/assets/vendor-react-8xo7RSum.js +9 -0
- package/bundle/web-dist/client/assets/vendor-tanstack-6B86itGS.js +2 -0
- package/bundle/web-dist/client/index.html +5 -7
- package/bundle/web-dist/server/assets/{logs-B5M5B7pN.js → logs-C0md5rmp.js} +48 -36
- package/bundle/web-dist/server/assets/monit-YVvwJuAF.js +479 -0
- package/bundle/web-dist/server/assets/plus-z5Hy__3C.js +26 -0
- package/bundle/web-dist/server/assets/refresh-cw-CNm0CERy.js +30 -0
- package/bundle/web-dist/server/assets/{request-model-Cp6h5EuP.js → request-model-DIuPZZwu.js} +14 -7
- package/bundle/web-dist/server/assets/{routes-rIXpkI-t.js → routes-CjWxvHAO.js} +1741 -1101
- package/bundle/web-dist/server/assets/{services.generated-CMJ8AHbO.js → services.generated-CqS8DCjT.js} +11973 -6081
- package/bundle/web-dist/server/assets/{settings-_MoaFGxj.js → settings-CXwnKiMG.js} +40 -19
- package/bundle/web-dist/server/assets/{show-Cfm9UeDr.js → show-G1t8dOEh.js} +268 -213
- package/bundle/web-dist/server/assets/{tokens-DMSHDg9D.js → tokens-C4D67FBX.js} +41 -18
- package/bundle/web-dist/server/assets/{use-oauth-login-flow-jkAkT3X6.js → use-oauth-login-flow-CFzShQtp.js} +1569 -38
- package/bundle/web-dist/server/assets/{use-update-token-mutation-Sm6kh02m.js → use-update-token-mutation-oH0O0n-g.js} +1 -1
- package/bundle/web-dist/server/entry-server.generated.js +11595 -5045
- package/dist/cli.js +20 -11
- package/package.json +24 -24
- package/skills/qgrid/references/ai-sdk-provider-contract.md +4 -4
- package/skills/qgrid/references/decision-rationale.md +3 -0
- package/skills/qgrid/references/repo-map.md +1 -1
- package/skills/qgrid/references/request-log-run-lifecycle.md +1 -1
- package/skills/qgrid/references/tool-calling-and-multiturn.md +2 -2
- package/bundle/web-dist/client/assets/clsx-5XM_pHvN.js +0 -1
- package/bundle/web-dist/client/assets/cost-DB3HbU7T.js +0 -1
- package/bundle/web-dist/client/assets/index-Be2qCZmI.css +0 -1
- package/bundle/web-dist/client/assets/index-CK9LwGNV.js +0 -32
- package/bundle/web-dist/client/assets/logs-DjQcEivP.js +0 -1
- package/bundle/web-dist/client/assets/monit-RTxpU7oZ.js +0 -1
- package/bundle/web-dist/client/assets/plus-DDvVTvQP.js +0 -1
- package/bundle/web-dist/client/assets/preload-helper-DWTEM3RW.js +0 -1
- package/bundle/web-dist/client/assets/refresh-cw-CTQsNddA.js +0 -1
- package/bundle/web-dist/client/assets/request-model-DliRuPcw.js +0 -1
- package/bundle/web-dist/client/assets/rolldown-runtime-Dw2cE7zH.js +0 -1
- package/bundle/web-dist/client/assets/routes-DVHoo-YF.js +0 -5
- package/bundle/web-dist/client/assets/services.generated-B5lc3aIC.js +0 -51
- package/bundle/web-dist/client/assets/settings-BQUz6UFr.js +0 -1
- package/bundle/web-dist/client/assets/show-CalQG1Ew.js +0 -2
- package/bundle/web-dist/client/assets/tokens-DU4fWXI9.js +0 -1
- package/bundle/web-dist/client/assets/use-oauth-login-flow-BfxYI4Oh.js +0 -1
- package/bundle/web-dist/client/assets/use-update-token-mutation-qKBC2sn7.js +0 -1
- package/bundle/web-dist/client/assets/vendor-react-DH4kUfK2.js +0 -9
- package/bundle/web-dist/client/assets/vendor-tanstack-DRPs09ai.js +0 -1
- package/bundle/web-dist/server/assets/lazyRouteComponent-AKiHfZWp.js +0 -1983
- package/bundle/web-dist/server/assets/monit-p6JM8MMl.js +0 -1652
- package/bundle/web-dist/server/assets/plus-I0FfLVgU.js +0 -19
- package/bundle/web-dist/server/assets/react-dom-Cv23mm1K.js +0 -335
- package/bundle/web-dist/server/assets/refresh-cw-DYsnffRC.js +0 -23
- /package/bundle/web-dist/server/assets/{clsx-D_N5PN_2.js → clsx-DgIEfj3H.js} +0 -0
- /package/bundle/web-dist/server/assets/{cost-BC9yzyA9.js → cost-oNK0T4Jo.js} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import { i as formatUsd } from "./cost-
|
|
5
|
-
import { t as useUpdateTokenMutation } from "./use-update-token-mutation-
|
|
6
|
-
//#region ../../node_modules/.pnpm/@dnd-kit+utilities@3.2.2_react@19.
|
|
1
|
+
import { J as require_react, K as useQueryClient, Q as __toESM, n as QgridService, o as TokenService, q as require_jsx_runtime } from "./services.generated-CqS8DCjT.js";
|
|
2
|
+
import { i as o, n as useOAuthLoginFlow, r as OAuthCodeEntry, t as isOAuthProvider } from "./use-oauth-login-flow-CFzShQtp.js";
|
|
3
|
+
import { u as require_react_dom } from "../entry-server.generated.js";
|
|
4
|
+
import { i as formatUsd } from "./cost-oNK0T4Jo.js";
|
|
5
|
+
import { t as useUpdateTokenMutation } from "./use-update-token-mutation-oH0O0n-g.js";
|
|
6
|
+
//#region ../../node_modules/.pnpm/@dnd-kit+utilities@3.2.2_react@19.3.1/node_modules/@dnd-kit/utilities/dist/utilities.esm.js
|
|
7
7
|
var import_react_dom = /* @__PURE__ */ __toESM(require_react_dom());
|
|
8
8
|
var import_react = /* @__PURE__ */ __toESM(require_react());
|
|
9
9
|
function useCombinedRefs() {
|
|
@@ -72,6 +72,14 @@ function useInterval() {
|
|
|
72
72
|
}
|
|
73
73
|
}, [])];
|
|
74
74
|
}
|
|
75
|
+
function useLatestValue(value, dependencies) {
|
|
76
|
+
if (dependencies === void 0) dependencies = [value];
|
|
77
|
+
const valueRef = (0, import_react.useRef)(value);
|
|
78
|
+
useIsomorphicLayoutEffect(() => {
|
|
79
|
+
if (valueRef.current !== value) valueRef.current = value;
|
|
80
|
+
}, dependencies);
|
|
81
|
+
return valueRef;
|
|
82
|
+
}
|
|
75
83
|
function useLazyMemo(callback, dependencies) {
|
|
76
84
|
const valueRef = (0, import_react.useRef)();
|
|
77
85
|
return (0, import_react.useMemo)(() => {
|
|
@@ -88,6 +96,13 @@ function useNodeRef(onChange) {
|
|
|
88
96
|
node.current = element;
|
|
89
97
|
}, [])];
|
|
90
98
|
}
|
|
99
|
+
function usePrevious(value) {
|
|
100
|
+
const ref = (0, import_react.useRef)();
|
|
101
|
+
(0, import_react.useEffect)(() => {
|
|
102
|
+
ref.current = value;
|
|
103
|
+
}, [value]);
|
|
104
|
+
return ref.current;
|
|
105
|
+
}
|
|
91
106
|
var ids = {};
|
|
92
107
|
function useUniqueId(prefix, value) {
|
|
93
108
|
return (0, import_react.useMemo)(() => {
|
|
@@ -110,8 +125,8 @@ function createAdjustmentFn(modifier) {
|
|
|
110
125
|
}, { ...object });
|
|
111
126
|
};
|
|
112
127
|
}
|
|
113
|
-
var add =
|
|
114
|
-
var subtract =
|
|
128
|
+
var add = /*#__PURE__*/ createAdjustmentFn(1);
|
|
129
|
+
var subtract = /*#__PURE__*/ createAdjustmentFn(-1);
|
|
115
130
|
function hasViewportRelativeCoordinates(event) {
|
|
116
131
|
return "clientX" in event && "clientY" in event;
|
|
117
132
|
}
|
|
@@ -150,7 +165,7 @@ function getEventCoordinates(event) {
|
|
|
150
165
|
};
|
|
151
166
|
return null;
|
|
152
167
|
}
|
|
153
|
-
var CSS =
|
|
168
|
+
var CSS = /*#__PURE__*/ Object.freeze({
|
|
154
169
|
Translate: { toString(transform) {
|
|
155
170
|
if (!transform) return;
|
|
156
171
|
const { x, y } = transform;
|
|
@@ -170,8 +185,13 @@ var CSS = /* @__PURE__ */ Object.freeze({
|
|
|
170
185
|
return property + " " + duration + "ms " + easing;
|
|
171
186
|
} }
|
|
172
187
|
});
|
|
188
|
+
var SELECTOR = "a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";
|
|
189
|
+
function findFirstFocusableNode(element) {
|
|
190
|
+
if (element.matches(SELECTOR)) return element;
|
|
191
|
+
return element.querySelector(SELECTOR);
|
|
192
|
+
}
|
|
173
193
|
//#endregion
|
|
174
|
-
//#region ../../node_modules/.pnpm/@dnd-kit+accessibility@3.1.1_react@19.
|
|
194
|
+
//#region ../../node_modules/.pnpm/@dnd-kit+accessibility@3.1.1_react@19.3.1/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js
|
|
175
195
|
var hiddenStyles = { display: "none" };
|
|
176
196
|
function HiddenText(_ref) {
|
|
177
197
|
let { id, value } = _ref;
|
|
@@ -213,254 +233,125 @@ function useAnnouncement() {
|
|
|
213
233
|
};
|
|
214
234
|
}
|
|
215
235
|
//#endregion
|
|
216
|
-
//#region ../../node_modules/.pnpm/@dnd-kit+core@
|
|
217
|
-
var
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
236
|
+
//#region ../../node_modules/.pnpm/@dnd-kit+core@6.3.1_react-dom@19.3.1_react@19.3.1__react@19.3.1/node_modules/@dnd-kit/core/dist/core.esm.js
|
|
237
|
+
var DndMonitorContext = /*#__PURE__*/ (0, import_react.createContext)(null);
|
|
238
|
+
function useDndMonitor(listener) {
|
|
239
|
+
const registerListener = (0, import_react.useContext)(DndMonitorContext);
|
|
240
|
+
(0, import_react.useEffect)(() => {
|
|
241
|
+
if (!registerListener) throw new Error("useDndMonitor must be used within a children of <DndContext>");
|
|
242
|
+
return registerListener(listener);
|
|
243
|
+
}, [listener, registerListener]);
|
|
244
|
+
}
|
|
245
|
+
function useDndMonitorProvider() {
|
|
246
|
+
const [listeners] = (0, import_react.useState)(() => /* @__PURE__ */ new Set());
|
|
247
|
+
const registerListener = (0, import_react.useCallback)((listener) => {
|
|
248
|
+
listeners.add(listener);
|
|
249
|
+
return () => listeners.delete(listener);
|
|
250
|
+
}, [listeners]);
|
|
251
|
+
return [(0, import_react.useCallback)((_ref) => {
|
|
252
|
+
let { type, event } = _ref;
|
|
253
|
+
listeners.forEach((listener) => {
|
|
254
|
+
var _listener$type;
|
|
255
|
+
return (_listener$type = listener[type]) == null ? void 0 : _listener$type.call(listener, event);
|
|
256
|
+
});
|
|
257
|
+
}, [listeners]), registerListener];
|
|
258
|
+
}
|
|
259
|
+
var defaultScreenReaderInstructions = { draggable: "\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n " };
|
|
222
260
|
var defaultAnnouncements = {
|
|
223
|
-
onDragStart(
|
|
224
|
-
|
|
261
|
+
onDragStart(_ref) {
|
|
262
|
+
let { active } = _ref;
|
|
263
|
+
return "Picked up draggable item " + active.id + ".";
|
|
225
264
|
},
|
|
226
|
-
onDragOver(
|
|
227
|
-
|
|
228
|
-
return
|
|
265
|
+
onDragOver(_ref2) {
|
|
266
|
+
let { active, over } = _ref2;
|
|
267
|
+
if (over) return "Draggable item " + active.id + " was moved over droppable area " + over.id + ".";
|
|
268
|
+
return "Draggable item " + active.id + " is no longer over a droppable area.";
|
|
229
269
|
},
|
|
230
|
-
onDragEnd(
|
|
231
|
-
|
|
232
|
-
return
|
|
270
|
+
onDragEnd(_ref3) {
|
|
271
|
+
let { active, over } = _ref3;
|
|
272
|
+
if (over) return "Draggable item " + active.id + " was dropped over droppable area " + over.id;
|
|
273
|
+
return "Draggable item " + active.id + " was dropped.";
|
|
233
274
|
},
|
|
234
|
-
onDragCancel(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
};
|
|
238
|
-
var Action;
|
|
239
|
-
(function(Action) {
|
|
240
|
-
Action["DragStart"] = "dragStart";
|
|
241
|
-
Action["DragMove"] = "dragMove";
|
|
242
|
-
Action["DragEnd"] = "dragEnd";
|
|
243
|
-
Action["DragCancel"] = "dragCancel";
|
|
244
|
-
Action["DragOver"] = "dragOver";
|
|
245
|
-
Action["RegisterDroppable"] = "registerDroppable";
|
|
246
|
-
Action["SetDroppableDisabled"] = "setDroppableDisabled";
|
|
247
|
-
Action["UnregisterDroppable"] = "unregisterDroppable";
|
|
248
|
-
})(Action || (Action = {}));
|
|
249
|
-
function noop(..._args) {}
|
|
250
|
-
var DroppableContainersMap = class extends Map {
|
|
251
|
-
get(id) {
|
|
252
|
-
var _super$get;
|
|
253
|
-
return id != null ? (_super$get = super.get(id)) != null ? _super$get : void 0 : void 0;
|
|
254
|
-
}
|
|
255
|
-
toArray() {
|
|
256
|
-
return Array.from(this.values());
|
|
257
|
-
}
|
|
258
|
-
getEnabled() {
|
|
259
|
-
return this.toArray().filter(({ disabled }) => !disabled);
|
|
260
|
-
}
|
|
261
|
-
getNodeFor(id) {
|
|
262
|
-
var _this$get$node$curren, _this$get;
|
|
263
|
-
return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : void 0;
|
|
275
|
+
onDragCancel(_ref4) {
|
|
276
|
+
let { active } = _ref4;
|
|
277
|
+
return "Dragging was cancelled. Draggable item " + active.id + " was dropped.";
|
|
264
278
|
}
|
|
265
279
|
};
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
active: null,
|
|
269
|
-
activeNode: null,
|
|
270
|
-
activeNodeRect: null,
|
|
271
|
-
activeNodeClientRect: null,
|
|
272
|
-
activators: [],
|
|
273
|
-
ariaDescribedById: { draggable: "" },
|
|
274
|
-
containerNodeRect: null,
|
|
275
|
-
dispatch: noop,
|
|
276
|
-
draggableNodes: {},
|
|
277
|
-
droppableRects: /* @__PURE__ */ new Map(),
|
|
278
|
-
droppableContainers: /* @__PURE__ */ new DroppableContainersMap(),
|
|
279
|
-
over: null,
|
|
280
|
-
dragOverlay: {
|
|
281
|
-
nodeRef: { current: null },
|
|
282
|
-
rect: null,
|
|
283
|
-
setRef: noop
|
|
284
|
-
},
|
|
285
|
-
scrollableAncestors: [],
|
|
286
|
-
scrollableAncestorRects: [],
|
|
287
|
-
recomputeLayouts: noop,
|
|
288
|
-
windowRect: null,
|
|
289
|
-
willRecomputeLayouts: false
|
|
290
|
-
});
|
|
291
|
-
function getInitialState() {
|
|
292
|
-
return {
|
|
293
|
-
draggable: {
|
|
294
|
-
active: null,
|
|
295
|
-
initialCoordinates: {
|
|
296
|
-
x: 0,
|
|
297
|
-
y: 0
|
|
298
|
-
},
|
|
299
|
-
nodes: {},
|
|
300
|
-
translate: {
|
|
301
|
-
x: 0,
|
|
302
|
-
y: 0
|
|
303
|
-
}
|
|
304
|
-
},
|
|
305
|
-
droppable: { containers: new DroppableContainersMap() }
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
function reducer(state, action) {
|
|
309
|
-
switch (action.type) {
|
|
310
|
-
case Action.DragStart: return {
|
|
311
|
-
...state,
|
|
312
|
-
draggable: {
|
|
313
|
-
...state.draggable,
|
|
314
|
-
initialCoordinates: action.initialCoordinates,
|
|
315
|
-
active: action.active
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
case Action.DragMove:
|
|
319
|
-
if (!state.draggable.active) return state;
|
|
320
|
-
return {
|
|
321
|
-
...state,
|
|
322
|
-
draggable: {
|
|
323
|
-
...state.draggable,
|
|
324
|
-
translate: {
|
|
325
|
-
x: action.coordinates.x - state.draggable.initialCoordinates.x,
|
|
326
|
-
y: action.coordinates.y - state.draggable.initialCoordinates.y
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
case Action.DragEnd:
|
|
331
|
-
case Action.DragCancel: return {
|
|
332
|
-
...state,
|
|
333
|
-
draggable: {
|
|
334
|
-
...state.draggable,
|
|
335
|
-
active: null,
|
|
336
|
-
initialCoordinates: {
|
|
337
|
-
x: 0,
|
|
338
|
-
y: 0
|
|
339
|
-
},
|
|
340
|
-
translate: {
|
|
341
|
-
x: 0,
|
|
342
|
-
y: 0
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
case Action.RegisterDroppable: {
|
|
347
|
-
const { element } = action;
|
|
348
|
-
const { id } = element;
|
|
349
|
-
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
350
|
-
containers.set(id, element);
|
|
351
|
-
return {
|
|
352
|
-
...state,
|
|
353
|
-
droppable: {
|
|
354
|
-
...state.droppable,
|
|
355
|
-
containers
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
case Action.SetDroppableDisabled: {
|
|
360
|
-
const { id, key, disabled } = action;
|
|
361
|
-
const element = state.droppable.containers.get(id);
|
|
362
|
-
if (!element || key !== element.key) return state;
|
|
363
|
-
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
364
|
-
containers.set(id, {
|
|
365
|
-
...element,
|
|
366
|
-
disabled
|
|
367
|
-
});
|
|
368
|
-
return {
|
|
369
|
-
...state,
|
|
370
|
-
droppable: {
|
|
371
|
-
...state.droppable,
|
|
372
|
-
containers
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
case Action.UnregisterDroppable: {
|
|
377
|
-
const { id, key } = action;
|
|
378
|
-
const element = state.droppable.containers.get(id);
|
|
379
|
-
if (!element || key !== element.key) return state;
|
|
380
|
-
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
381
|
-
containers.delete(id);
|
|
382
|
-
return {
|
|
383
|
-
...state,
|
|
384
|
-
droppable: {
|
|
385
|
-
...state.droppable,
|
|
386
|
-
containers
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
default: return state;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
var DndMonitorContext = /* @__PURE__ */ (0, import_react.createContext)({
|
|
394
|
-
type: null,
|
|
395
|
-
event: null
|
|
396
|
-
});
|
|
397
|
-
function useDndMonitor({ onDragStart, onDragMove, onDragOver, onDragEnd, onDragCancel }) {
|
|
398
|
-
const monitorState = (0, import_react.useContext)(DndMonitorContext);
|
|
399
|
-
const previousMonitorState = (0, import_react.useRef)(monitorState);
|
|
400
|
-
(0, import_react.useEffect)(() => {
|
|
401
|
-
if (monitorState !== previousMonitorState.current) {
|
|
402
|
-
const { type, event } = monitorState;
|
|
403
|
-
switch (type) {
|
|
404
|
-
case Action.DragStart:
|
|
405
|
-
onDragStart?.(event);
|
|
406
|
-
break;
|
|
407
|
-
case Action.DragMove:
|
|
408
|
-
onDragMove?.(event);
|
|
409
|
-
break;
|
|
410
|
-
case Action.DragOver:
|
|
411
|
-
onDragOver?.(event);
|
|
412
|
-
break;
|
|
413
|
-
case Action.DragCancel:
|
|
414
|
-
onDragCancel?.(event);
|
|
415
|
-
break;
|
|
416
|
-
case Action.DragEnd:
|
|
417
|
-
onDragEnd?.(event);
|
|
418
|
-
break;
|
|
419
|
-
}
|
|
420
|
-
previousMonitorState.current = monitorState;
|
|
421
|
-
}
|
|
422
|
-
}, [
|
|
423
|
-
monitorState,
|
|
424
|
-
onDragStart,
|
|
425
|
-
onDragMove,
|
|
426
|
-
onDragOver,
|
|
427
|
-
onDragEnd,
|
|
428
|
-
onDragCancel
|
|
429
|
-
]);
|
|
430
|
-
}
|
|
431
|
-
function Accessibility({ announcements = defaultAnnouncements, hiddenTextDescribedById, screenReaderInstructions }) {
|
|
280
|
+
function Accessibility(_ref) {
|
|
281
|
+
let { announcements = defaultAnnouncements, container, hiddenTextDescribedById, screenReaderInstructions = defaultScreenReaderInstructions } = _ref;
|
|
432
282
|
const { announce, announcement } = useAnnouncement();
|
|
433
|
-
const liveRegionId = useUniqueId(
|
|
283
|
+
const liveRegionId = useUniqueId("DndLiveRegion");
|
|
434
284
|
const [mounted, setMounted] = (0, import_react.useState)(false);
|
|
435
285
|
(0, import_react.useEffect)(() => {
|
|
436
286
|
setMounted(true);
|
|
437
287
|
}, []);
|
|
438
288
|
useDndMonitor((0, import_react.useMemo)(() => ({
|
|
439
|
-
onDragStart(
|
|
440
|
-
|
|
289
|
+
onDragStart(_ref2) {
|
|
290
|
+
let { active } = _ref2;
|
|
291
|
+
announce(announcements.onDragStart({ active }));
|
|
441
292
|
},
|
|
442
|
-
onDragMove(
|
|
443
|
-
|
|
293
|
+
onDragMove(_ref3) {
|
|
294
|
+
let { active, over } = _ref3;
|
|
295
|
+
if (announcements.onDragMove) announce(announcements.onDragMove({
|
|
296
|
+
active,
|
|
297
|
+
over
|
|
298
|
+
}));
|
|
444
299
|
},
|
|
445
|
-
onDragOver(
|
|
446
|
-
|
|
300
|
+
onDragOver(_ref4) {
|
|
301
|
+
let { active, over } = _ref4;
|
|
302
|
+
announce(announcements.onDragOver({
|
|
303
|
+
active,
|
|
304
|
+
over
|
|
305
|
+
}));
|
|
447
306
|
},
|
|
448
|
-
onDragEnd(
|
|
449
|
-
|
|
307
|
+
onDragEnd(_ref5) {
|
|
308
|
+
let { active, over } = _ref5;
|
|
309
|
+
announce(announcements.onDragEnd({
|
|
310
|
+
active,
|
|
311
|
+
over
|
|
312
|
+
}));
|
|
450
313
|
},
|
|
451
|
-
onDragCancel(
|
|
452
|
-
|
|
314
|
+
onDragCancel(_ref6) {
|
|
315
|
+
let { active, over } = _ref6;
|
|
316
|
+
announce(announcements.onDragCancel({
|
|
317
|
+
active,
|
|
318
|
+
over
|
|
319
|
+
}));
|
|
453
320
|
}
|
|
454
321
|
}), [announce, announcements]));
|
|
455
|
-
|
|
322
|
+
if (!mounted) return null;
|
|
323
|
+
const markup = import_react.createElement(import_react.Fragment, null, import_react.createElement(HiddenText, {
|
|
456
324
|
id: hiddenTextDescribedById,
|
|
457
325
|
value: screenReaderInstructions.draggable
|
|
458
326
|
}), import_react.createElement(LiveRegion, {
|
|
459
327
|
id: liveRegionId,
|
|
460
328
|
announcement
|
|
461
|
-
}))
|
|
329
|
+
}));
|
|
330
|
+
return container ? (0, import_react_dom.createPortal)(markup, container) : markup;
|
|
331
|
+
}
|
|
332
|
+
var Action;
|
|
333
|
+
(function(Action) {
|
|
334
|
+
Action["DragStart"] = "dragStart";
|
|
335
|
+
Action["DragMove"] = "dragMove";
|
|
336
|
+
Action["DragEnd"] = "dragEnd";
|
|
337
|
+
Action["DragCancel"] = "dragCancel";
|
|
338
|
+
Action["DragOver"] = "dragOver";
|
|
339
|
+
Action["RegisterDroppable"] = "registerDroppable";
|
|
340
|
+
Action["SetDroppableDisabled"] = "setDroppableDisabled";
|
|
341
|
+
Action["UnregisterDroppable"] = "unregisterDroppable";
|
|
342
|
+
})(Action || (Action = {}));
|
|
343
|
+
function noop() {}
|
|
344
|
+
function useSensor(sensor, options) {
|
|
345
|
+
return (0, import_react.useMemo)(() => ({
|
|
346
|
+
sensor,
|
|
347
|
+
options: options != null ? options : {}
|
|
348
|
+
}), [sensor, options]);
|
|
349
|
+
}
|
|
350
|
+
function useSensors() {
|
|
351
|
+
for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) sensors[_key] = arguments[_key];
|
|
352
|
+
return (0, import_react.useMemo)(() => [...sensors].filter((sensor) => sensor != null), [...sensors]);
|
|
462
353
|
}
|
|
463
|
-
var defaultCoordinates =
|
|
354
|
+
var defaultCoordinates = /*#__PURE__*/ Object.freeze({
|
|
464
355
|
x: 0,
|
|
465
356
|
y: 0
|
|
466
357
|
});
|
|
@@ -471,33 +362,102 @@ function distanceBetween(p1, p2) {
|
|
|
471
362
|
return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
|
|
472
363
|
}
|
|
473
364
|
/**
|
|
365
|
+
* Sort collisions from smallest to greatest value
|
|
366
|
+
*/
|
|
367
|
+
function sortCollisionsAsc(_ref, _ref2) {
|
|
368
|
+
let { data: { value: a } } = _ref;
|
|
369
|
+
let { data: { value: b } } = _ref2;
|
|
370
|
+
return a - b;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Sort collisions from greatest to smallest value
|
|
374
|
+
*/
|
|
375
|
+
function sortCollisionsDesc(_ref3, _ref4) {
|
|
376
|
+
let { data: { value: a } } = _ref3;
|
|
377
|
+
let { data: { value: b } } = _ref4;
|
|
378
|
+
return b - a;
|
|
379
|
+
}
|
|
380
|
+
function getFirstCollision(collisions, property) {
|
|
381
|
+
if (!collisions || collisions.length === 0) return null;
|
|
382
|
+
const [firstCollision] = collisions;
|
|
383
|
+
return property ? firstCollision[property] : firstCollision;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
474
386
|
* Returns the coordinates of the center of a given ClientRect
|
|
475
387
|
*/
|
|
476
|
-
function centerOfRectangle(rect, left
|
|
388
|
+
function centerOfRectangle(rect, left, top) {
|
|
389
|
+
if (left === void 0) left = rect.left;
|
|
390
|
+
if (top === void 0) top = rect.top;
|
|
477
391
|
return {
|
|
478
392
|
x: left + rect.width * .5,
|
|
479
393
|
y: top + rect.height * .5
|
|
480
394
|
};
|
|
481
395
|
}
|
|
482
396
|
/**
|
|
483
|
-
* Returns the closest
|
|
397
|
+
* Returns the closest rectangles from an array of rectangles to the center of a given
|
|
484
398
|
* rectangle.
|
|
485
399
|
*/
|
|
486
|
-
var closestCenter = (
|
|
400
|
+
var closestCenter = (_ref) => {
|
|
401
|
+
let { collisionRect, droppableRects, droppableContainers } = _ref;
|
|
487
402
|
const centerRect = centerOfRectangle(collisionRect, collisionRect.left, collisionRect.top);
|
|
488
|
-
|
|
489
|
-
let minDroppableContainer = null;
|
|
403
|
+
const collisions = [];
|
|
490
404
|
for (const droppableContainer of droppableContainers) {
|
|
491
|
-
const {
|
|
405
|
+
const { id } = droppableContainer;
|
|
406
|
+
const rect = droppableRects.get(id);
|
|
492
407
|
if (rect) {
|
|
493
408
|
const distBetween = distanceBetween(centerOfRectangle(rect), centerRect);
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
409
|
+
collisions.push({
|
|
410
|
+
id,
|
|
411
|
+
data: {
|
|
412
|
+
droppableContainer,
|
|
413
|
+
value: distBetween
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return collisions.sort(sortCollisionsAsc);
|
|
419
|
+
};
|
|
420
|
+
/**
|
|
421
|
+
* Returns the intersecting rectangle area between two rectangles
|
|
422
|
+
*/
|
|
423
|
+
function getIntersectionRatio(entry, target) {
|
|
424
|
+
const top = Math.max(target.top, entry.top);
|
|
425
|
+
const left = Math.max(target.left, entry.left);
|
|
426
|
+
const right = Math.min(target.left + target.width, entry.left + entry.width);
|
|
427
|
+
const bottom = Math.min(target.top + target.height, entry.top + entry.height);
|
|
428
|
+
const width = right - left;
|
|
429
|
+
const height = bottom - top;
|
|
430
|
+
if (left < right && top < bottom) {
|
|
431
|
+
const targetArea = target.width * target.height;
|
|
432
|
+
const entryArea = entry.width * entry.height;
|
|
433
|
+
const intersectionArea = width * height;
|
|
434
|
+
const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
|
|
435
|
+
return Number(intersectionRatio.toFixed(4));
|
|
436
|
+
}
|
|
437
|
+
return 0;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Returns the rectangles that has the greatest intersection area with a given
|
|
441
|
+
* rectangle in an array of rectangles.
|
|
442
|
+
*/
|
|
443
|
+
var rectIntersection = (_ref) => {
|
|
444
|
+
let { collisionRect, droppableRects, droppableContainers } = _ref;
|
|
445
|
+
const collisions = [];
|
|
446
|
+
for (const droppableContainer of droppableContainers) {
|
|
447
|
+
const { id } = droppableContainer;
|
|
448
|
+
const rect = droppableRects.get(id);
|
|
449
|
+
if (rect) {
|
|
450
|
+
const intersectionRatio = getIntersectionRatio(rect, collisionRect);
|
|
451
|
+
if (intersectionRatio > 0) collisions.push({
|
|
452
|
+
id,
|
|
453
|
+
data: {
|
|
454
|
+
droppableContainer,
|
|
455
|
+
value: intersectionRatio
|
|
456
|
+
}
|
|
457
|
+
});
|
|
498
458
|
}
|
|
499
459
|
}
|
|
500
|
-
return
|
|
460
|
+
return collisions.sort(sortCollisionsDesc);
|
|
501
461
|
};
|
|
502
462
|
function adjustScale(transform, rect1, rect2) {
|
|
503
463
|
return {
|
|
@@ -513,36 +473,119 @@ function getRectDelta(rect1, rect2) {
|
|
|
513
473
|
} : defaultCoordinates;
|
|
514
474
|
}
|
|
515
475
|
function createRectAdjustmentFn(modifier) {
|
|
516
|
-
return function
|
|
476
|
+
return function adjustClientRect(rect) {
|
|
477
|
+
for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) adjustments[_key - 1] = arguments[_key];
|
|
517
478
|
return adjustments.reduce((acc, adjustment) => ({
|
|
518
479
|
...acc,
|
|
519
480
|
top: acc.top + modifier * adjustment.y,
|
|
520
481
|
bottom: acc.bottom + modifier * adjustment.y,
|
|
521
482
|
left: acc.left + modifier * adjustment.x,
|
|
522
|
-
right: acc.right + modifier * adjustment.x
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
483
|
+
right: acc.right + modifier * adjustment.x
|
|
484
|
+
}), { ...rect });
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
var getAdjustedRect = /*#__PURE__*/ createRectAdjustmentFn(1);
|
|
488
|
+
function parseTransform(transform) {
|
|
489
|
+
if (transform.startsWith("matrix3d(")) {
|
|
490
|
+
const transformArray = transform.slice(9, -1).split(/, /);
|
|
491
|
+
return {
|
|
492
|
+
x: +transformArray[12],
|
|
493
|
+
y: +transformArray[13],
|
|
494
|
+
scaleX: +transformArray[0],
|
|
495
|
+
scaleY: +transformArray[5]
|
|
496
|
+
};
|
|
497
|
+
} else if (transform.startsWith("matrix(")) {
|
|
498
|
+
const transformArray = transform.slice(7, -1).split(/, /);
|
|
499
|
+
return {
|
|
500
|
+
x: +transformArray[4],
|
|
501
|
+
y: +transformArray[5],
|
|
502
|
+
scaleX: +transformArray[0],
|
|
503
|
+
scaleY: +transformArray[3]
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
return null;
|
|
507
|
+
}
|
|
508
|
+
function inverseTransform(rect, transform, transformOrigin) {
|
|
509
|
+
const parsedTransform = parseTransform(transform);
|
|
510
|
+
if (!parsedTransform) return rect;
|
|
511
|
+
const { scaleX, scaleY, x: translateX, y: translateY } = parsedTransform;
|
|
512
|
+
const x = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin);
|
|
513
|
+
const y = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(" ") + 1));
|
|
514
|
+
const w = scaleX ? rect.width / scaleX : rect.width;
|
|
515
|
+
const h = scaleY ? rect.height / scaleY : rect.height;
|
|
516
|
+
return {
|
|
517
|
+
width: w,
|
|
518
|
+
height: h,
|
|
519
|
+
top: y,
|
|
520
|
+
right: x + w,
|
|
521
|
+
bottom: y + h,
|
|
522
|
+
left: x
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
var defaultOptions = { ignoreTransform: false };
|
|
526
|
+
/**
|
|
527
|
+
* Returns the bounding client rect of an element relative to the viewport.
|
|
528
|
+
*/
|
|
529
|
+
function getClientRect(element, options) {
|
|
530
|
+
if (options === void 0) options = defaultOptions;
|
|
531
|
+
let rect = element.getBoundingClientRect();
|
|
532
|
+
if (options.ignoreTransform) {
|
|
533
|
+
const { transform, transformOrigin } = getWindow(element).getComputedStyle(element);
|
|
534
|
+
if (transform) rect = inverseTransform(rect, transform, transformOrigin);
|
|
535
|
+
}
|
|
536
|
+
const { top, left, width, height, bottom, right } = rect;
|
|
537
|
+
return {
|
|
538
|
+
top,
|
|
539
|
+
left,
|
|
540
|
+
width,
|
|
541
|
+
height,
|
|
542
|
+
bottom,
|
|
543
|
+
right
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Returns the bounding client rect of an element relative to the viewport.
|
|
548
|
+
*
|
|
549
|
+
* @remarks
|
|
550
|
+
* The ClientRect returned by this method does not take into account transforms
|
|
551
|
+
* applied to the element it measures.
|
|
552
|
+
*
|
|
553
|
+
*/
|
|
554
|
+
function getTransformAgnosticClientRect(element) {
|
|
555
|
+
return getClientRect(element, { ignoreTransform: true });
|
|
556
|
+
}
|
|
557
|
+
function getWindowClientRect(element) {
|
|
558
|
+
const width = element.innerWidth;
|
|
559
|
+
const height = element.innerHeight;
|
|
560
|
+
return {
|
|
561
|
+
top: 0,
|
|
562
|
+
left: 0,
|
|
563
|
+
right: width,
|
|
564
|
+
bottom: height,
|
|
565
|
+
width,
|
|
566
|
+
height
|
|
526
567
|
};
|
|
527
568
|
}
|
|
528
|
-
|
|
529
|
-
|
|
569
|
+
function isFixed(node, computedStyle) {
|
|
570
|
+
if (computedStyle === void 0) computedStyle = getWindow(node).getComputedStyle(node);
|
|
530
571
|
return computedStyle.position === "fixed";
|
|
531
572
|
}
|
|
532
|
-
function isScrollable(
|
|
573
|
+
function isScrollable(element, computedStyle) {
|
|
574
|
+
if (computedStyle === void 0) computedStyle = getWindow(element).getComputedStyle(element);
|
|
533
575
|
const overflowRegex = /(auto|scroll|overlay)/;
|
|
534
576
|
return [
|
|
535
577
|
"overflow",
|
|
536
578
|
"overflowX",
|
|
537
579
|
"overflowY"
|
|
538
|
-
].
|
|
580
|
+
].some((property) => {
|
|
539
581
|
const value = computedStyle[property];
|
|
540
582
|
return typeof value === "string" ? overflowRegex.test(value) : false;
|
|
541
|
-
})
|
|
583
|
+
});
|
|
542
584
|
}
|
|
543
|
-
function getScrollableAncestors(element) {
|
|
585
|
+
function getScrollableAncestors(element, limit) {
|
|
544
586
|
const scrollParents = [];
|
|
545
587
|
function findScrollableAncestors(node) {
|
|
588
|
+
if (limit != null && scrollParents.length >= limit) return scrollParents;
|
|
546
589
|
if (!node) return scrollParents;
|
|
547
590
|
if (isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
|
|
548
591
|
scrollParents.push(node.scrollingElement);
|
|
@@ -550,12 +593,19 @@ function getScrollableAncestors(element) {
|
|
|
550
593
|
}
|
|
551
594
|
if (!isHTMLElement(node) || isSVGElement(node)) return scrollParents;
|
|
552
595
|
if (scrollParents.includes(node)) return scrollParents;
|
|
553
|
-
const computedStyle =
|
|
554
|
-
if (
|
|
596
|
+
const computedStyle = getWindow(element).getComputedStyle(node);
|
|
597
|
+
if (node !== element) {
|
|
598
|
+
if (isScrollable(node, computedStyle)) scrollParents.push(node);
|
|
599
|
+
}
|
|
555
600
|
if (isFixed(node, computedStyle)) return scrollParents;
|
|
556
601
|
return findScrollableAncestors(node.parentNode);
|
|
557
602
|
}
|
|
558
|
-
|
|
603
|
+
if (!element) return scrollParents;
|
|
604
|
+
return findScrollableAncestors(element);
|
|
605
|
+
}
|
|
606
|
+
function getFirstScrollableAncestor(node) {
|
|
607
|
+
const [firstScrollableAncestor] = getScrollableAncestors(node, 1);
|
|
608
|
+
return firstScrollableAncestor != null ? firstScrollableAncestor : null;
|
|
559
609
|
}
|
|
560
610
|
function getScrollableElement(element) {
|
|
561
611
|
if (!canUseDOM || !element) return null;
|
|
@@ -565,14 +615,18 @@ function getScrollableElement(element) {
|
|
|
565
615
|
if (isHTMLElement(element)) return element;
|
|
566
616
|
return null;
|
|
567
617
|
}
|
|
618
|
+
function getScrollXCoordinate(element) {
|
|
619
|
+
if (isWindow(element)) return element.scrollX;
|
|
620
|
+
return element.scrollLeft;
|
|
621
|
+
}
|
|
622
|
+
function getScrollYCoordinate(element) {
|
|
623
|
+
if (isWindow(element)) return element.scrollY;
|
|
624
|
+
return element.scrollTop;
|
|
625
|
+
}
|
|
568
626
|
function getScrollCoordinates(element) {
|
|
569
|
-
if (isWindow(element)) return {
|
|
570
|
-
x: element.scrollX,
|
|
571
|
-
y: element.scrollY
|
|
572
|
-
};
|
|
573
627
|
return {
|
|
574
|
-
x: element
|
|
575
|
-
y: element
|
|
628
|
+
x: getScrollXCoordinate(element),
|
|
629
|
+
y: getScrollYCoordinate(element)
|
|
576
630
|
};
|
|
577
631
|
}
|
|
578
632
|
var Direction;
|
|
@@ -580,14 +634,25 @@ var Direction;
|
|
|
580
634
|
Direction[Direction["Forward"] = 1] = "Forward";
|
|
581
635
|
Direction[Direction["Backward"] = -1] = "Backward";
|
|
582
636
|
})(Direction || (Direction = {}));
|
|
637
|
+
function isDocumentScrollingElement(element) {
|
|
638
|
+
if (!canUseDOM || !element) return false;
|
|
639
|
+
return element === document.scrollingElement;
|
|
640
|
+
}
|
|
583
641
|
function getScrollPosition(scrollingContainer) {
|
|
584
642
|
const minScroll = {
|
|
585
643
|
x: 0,
|
|
586
644
|
y: 0
|
|
587
645
|
};
|
|
646
|
+
const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
|
|
647
|
+
height: window.innerHeight,
|
|
648
|
+
width: window.innerWidth
|
|
649
|
+
} : {
|
|
650
|
+
height: scrollingContainer.clientHeight,
|
|
651
|
+
width: scrollingContainer.clientWidth
|
|
652
|
+
};
|
|
588
653
|
const maxScroll = {
|
|
589
|
-
x: scrollingContainer.scrollWidth -
|
|
590
|
-
y: scrollingContainer.scrollHeight -
|
|
654
|
+
x: scrollingContainer.scrollWidth - dimensions.width,
|
|
655
|
+
y: scrollingContainer.scrollHeight - dimensions.height
|
|
591
656
|
};
|
|
592
657
|
return {
|
|
593
658
|
isTop: scrollingContainer.scrollTop <= minScroll.y,
|
|
@@ -598,24 +663,14 @@ function getScrollPosition(scrollingContainer) {
|
|
|
598
663
|
minScroll
|
|
599
664
|
};
|
|
600
665
|
}
|
|
601
|
-
function isDocumentScrollingElement(element) {
|
|
602
|
-
if (!canUseDOM || !element) return false;
|
|
603
|
-
return element === document.scrollingElement;
|
|
604
|
-
}
|
|
605
666
|
var defaultThreshold = {
|
|
606
667
|
x: .2,
|
|
607
668
|
y: .2
|
|
608
669
|
};
|
|
609
|
-
function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect,
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
left: 0,
|
|
614
|
-
right: clientWidth,
|
|
615
|
-
bottom: clientHeight,
|
|
616
|
-
width: clientWidth,
|
|
617
|
-
height: clientHeight
|
|
618
|
-
} : scrollContainerRect;
|
|
670
|
+
function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) {
|
|
671
|
+
let { top, left, right, bottom } = _ref;
|
|
672
|
+
if (acceleration === void 0) acceleration = 10;
|
|
673
|
+
if (thresholdPercentage === void 0) thresholdPercentage = defaultThreshold;
|
|
619
674
|
const { isTop, isBottom, isLeft, isRight } = getScrollPosition(scrollContainer);
|
|
620
675
|
const direction = {
|
|
621
676
|
x: 0,
|
|
@@ -626,22 +681,22 @@ function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, { top,
|
|
|
626
681
|
y: 0
|
|
627
682
|
};
|
|
628
683
|
const threshold = {
|
|
629
|
-
height:
|
|
630
|
-
width:
|
|
684
|
+
height: scrollContainerRect.height * thresholdPercentage.y,
|
|
685
|
+
width: scrollContainerRect.width * thresholdPercentage.x
|
|
631
686
|
};
|
|
632
|
-
if (!isTop && top <=
|
|
687
|
+
if (!isTop && top <= scrollContainerRect.top + threshold.height) {
|
|
633
688
|
direction.y = Direction.Backward;
|
|
634
|
-
speed.y = acceleration * Math.abs((
|
|
635
|
-
} else if (!isBottom && bottom >=
|
|
689
|
+
speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height);
|
|
690
|
+
} else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) {
|
|
636
691
|
direction.y = Direction.Forward;
|
|
637
|
-
speed.y = acceleration * Math.abs((
|
|
692
|
+
speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
|
|
638
693
|
}
|
|
639
|
-
if (!isRight && right >=
|
|
694
|
+
if (!isRight && right >= scrollContainerRect.right - threshold.width) {
|
|
640
695
|
direction.x = Direction.Forward;
|
|
641
|
-
speed.x = acceleration * Math.abs((
|
|
642
|
-
} else if (!isLeft && left <=
|
|
696
|
+
speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width);
|
|
697
|
+
} else if (!isLeft && left <= scrollContainerRect.left + threshold.width) {
|
|
643
698
|
direction.x = Direction.Backward;
|
|
644
|
-
speed.x = acceleration * Math.abs((
|
|
699
|
+
speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
|
|
645
700
|
}
|
|
646
701
|
return {
|
|
647
702
|
direction,
|
|
@@ -675,519 +730,133 @@ function getScrollOffsets(scrollableAncestors) {
|
|
|
675
730
|
return add(acc, getScrollCoordinates(node));
|
|
676
731
|
}, defaultCoordinates);
|
|
677
732
|
}
|
|
678
|
-
function
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
y: offset.y + node.offsetTop
|
|
683
|
-
};
|
|
684
|
-
if (node.offsetParent === parent) return nodeOffset;
|
|
685
|
-
return getEdgeOffset(node.offsetParent, parent, nodeOffset);
|
|
733
|
+
function getScrollXOffset(scrollableAncestors) {
|
|
734
|
+
return scrollableAncestors.reduce((acc, node) => {
|
|
735
|
+
return acc + getScrollXCoordinate(node);
|
|
736
|
+
}, 0);
|
|
686
737
|
}
|
|
687
|
-
function
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
};
|
|
738
|
+
function getScrollYOffset(scrollableAncestors) {
|
|
739
|
+
return scrollableAncestors.reduce((acc, node) => {
|
|
740
|
+
return acc + getScrollYCoordinate(node);
|
|
741
|
+
}, 0);
|
|
742
|
+
}
|
|
743
|
+
function scrollIntoViewIfNeeded(element, measure) {
|
|
744
|
+
if (measure === void 0) measure = getClientRect;
|
|
745
|
+
if (!element) return;
|
|
746
|
+
const { top, left, bottom, right } = measure(element);
|
|
747
|
+
if (!getFirstScrollableAncestor(element)) return;
|
|
748
|
+
if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) element.scrollIntoView({
|
|
749
|
+
block: "center",
|
|
750
|
+
inline: "center"
|
|
751
|
+
});
|
|
696
752
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
753
|
+
var properties = [[
|
|
754
|
+
"x",
|
|
755
|
+
["left", "right"],
|
|
756
|
+
getScrollXOffset
|
|
757
|
+
], [
|
|
758
|
+
"y",
|
|
759
|
+
["top", "bottom"],
|
|
760
|
+
getScrollYOffset
|
|
761
|
+
]];
|
|
762
|
+
var Rect = class {
|
|
763
|
+
constructor(rect, element) {
|
|
764
|
+
this.rect = void 0;
|
|
765
|
+
this.width = void 0;
|
|
766
|
+
this.height = void 0;
|
|
767
|
+
this.top = void 0;
|
|
768
|
+
this.bottom = void 0;
|
|
769
|
+
this.right = void 0;
|
|
770
|
+
this.left = void 0;
|
|
771
|
+
const scrollableAncestors = getScrollableAncestors(element);
|
|
772
|
+
const scrollOffsets = getScrollOffsets(scrollableAncestors);
|
|
773
|
+
this.rect = { ...rect };
|
|
774
|
+
this.width = rect.width;
|
|
775
|
+
this.height = rect.height;
|
|
776
|
+
for (const [axis, keys, getScrollOffset] of properties) for (const key of keys) Object.defineProperty(this, key, {
|
|
777
|
+
get: () => {
|
|
778
|
+
const currentOffsets = getScrollOffset(scrollableAncestors);
|
|
779
|
+
const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets;
|
|
780
|
+
return this.rect[key] + scrollOffsetsDeltla;
|
|
781
|
+
},
|
|
782
|
+
enumerable: true
|
|
783
|
+
});
|
|
784
|
+
Object.defineProperty(this, "rect", { enumerable: false });
|
|
711
785
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
}
|
|
725
|
-
function getViewRect(element) {
|
|
726
|
-
const { width, height, offsetTop, offsetLeft } = getLayoutRect(element);
|
|
727
|
-
const scrollOffsets = getScrollOffsets(getScrollableAncestors(element));
|
|
728
|
-
const top = offsetTop - scrollOffsets.y;
|
|
729
|
-
const left = offsetLeft - scrollOffsets.x;
|
|
730
|
-
return {
|
|
731
|
-
width,
|
|
732
|
-
height,
|
|
733
|
-
top,
|
|
734
|
-
bottom: top + height,
|
|
735
|
-
right: left + width,
|
|
736
|
-
left,
|
|
737
|
-
offsetTop,
|
|
738
|
-
offsetLeft
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* Returns the intersecting rectangle area between two rectangles
|
|
743
|
-
*/
|
|
744
|
-
function getIntersectionRatio(entry, target) {
|
|
745
|
-
const top = Math.max(target.top, entry.offsetTop);
|
|
746
|
-
const left = Math.max(target.left, entry.offsetLeft);
|
|
747
|
-
const right = Math.min(target.left + target.width, entry.offsetLeft + entry.width);
|
|
748
|
-
const bottom = Math.min(target.top + target.height, entry.offsetTop + entry.height);
|
|
749
|
-
const width = right - left;
|
|
750
|
-
const height = bottom - top;
|
|
751
|
-
if (left < right && top < bottom) {
|
|
752
|
-
const targetArea = target.width * target.height;
|
|
753
|
-
const entryArea = entry.width * entry.height;
|
|
754
|
-
const intersectionArea = width * height;
|
|
755
|
-
const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
|
|
756
|
-
return Number(intersectionRatio.toFixed(4));
|
|
786
|
+
};
|
|
787
|
+
var Listeners = class {
|
|
788
|
+
constructor(target) {
|
|
789
|
+
this.target = void 0;
|
|
790
|
+
this.listeners = [];
|
|
791
|
+
this.removeAll = () => {
|
|
792
|
+
this.listeners.forEach((listener) => {
|
|
793
|
+
var _this$target;
|
|
794
|
+
return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
|
|
795
|
+
});
|
|
796
|
+
};
|
|
797
|
+
this.target = target;
|
|
757
798
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
let maxIntersectingDroppableContainer = null;
|
|
767
|
-
for (const droppableContainer of droppableContainers) {
|
|
768
|
-
const { rect: { current: rect } } = droppableContainer;
|
|
769
|
-
if (rect) {
|
|
770
|
-
const intersectionRatio = getIntersectionRatio(rect, collisionRect);
|
|
771
|
-
if (intersectionRatio > maxIntersectionRatio) {
|
|
772
|
-
maxIntersectionRatio = intersectionRatio;
|
|
773
|
-
maxIntersectingDroppableContainer = droppableContainer.id;
|
|
774
|
-
}
|
|
775
|
-
}
|
|
799
|
+
add(eventName, handler, options) {
|
|
800
|
+
var _this$target2;
|
|
801
|
+
(_this$target2 = this.target) == null || _this$target2.addEventListener(eventName, handler, options);
|
|
802
|
+
this.listeners.push([
|
|
803
|
+
eventName,
|
|
804
|
+
handler,
|
|
805
|
+
options
|
|
806
|
+
]);
|
|
776
807
|
}
|
|
777
|
-
return maxIntersectingDroppableContainer;
|
|
778
808
|
};
|
|
779
|
-
|
|
780
|
-
(
|
|
781
|
-
|
|
782
|
-
AutoScrollActivator[AutoScrollActivator["DraggableRect"] = 1] = "DraggableRect";
|
|
783
|
-
})(AutoScrollActivator || (AutoScrollActivator = {}));
|
|
784
|
-
var TraversalOrder;
|
|
785
|
-
(function(TraversalOrder) {
|
|
786
|
-
TraversalOrder[TraversalOrder["TreeOrder"] = 0] = "TreeOrder";
|
|
787
|
-
TraversalOrder[TraversalOrder["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
|
|
788
|
-
})(TraversalOrder || (TraversalOrder = {}));
|
|
789
|
-
function useAutoScroller({ acceleration, activator = AutoScrollActivator.Pointer, canScroll, draggingRect, enabled, interval = 5, order = TraversalOrder.TreeOrder, pointerCoordinates, scrollableAncestors, scrollableAncestorRects, threshold }) {
|
|
790
|
-
const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
|
|
791
|
-
const scrollSpeed = (0, import_react.useRef)({
|
|
792
|
-
x: 1,
|
|
793
|
-
y: 1
|
|
794
|
-
});
|
|
795
|
-
const rect = (0, import_react.useMemo)(() => {
|
|
796
|
-
switch (activator) {
|
|
797
|
-
case AutoScrollActivator.Pointer: return pointerCoordinates ? {
|
|
798
|
-
top: pointerCoordinates.y,
|
|
799
|
-
bottom: pointerCoordinates.y,
|
|
800
|
-
left: pointerCoordinates.x,
|
|
801
|
-
right: pointerCoordinates.x
|
|
802
|
-
} : null;
|
|
803
|
-
case AutoScrollActivator.DraggableRect: return draggingRect;
|
|
804
|
-
}
|
|
805
|
-
return null;
|
|
806
|
-
}, [
|
|
807
|
-
activator,
|
|
808
|
-
draggingRect,
|
|
809
|
-
pointerCoordinates
|
|
810
|
-
]);
|
|
811
|
-
const scrollDirection = (0, import_react.useRef)(defaultCoordinates);
|
|
812
|
-
const scrollContainerRef = (0, import_react.useRef)(null);
|
|
813
|
-
const autoScroll = (0, import_react.useCallback)(() => {
|
|
814
|
-
const scrollContainer = scrollContainerRef.current;
|
|
815
|
-
if (!scrollContainer) return;
|
|
816
|
-
const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
|
|
817
|
-
const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
|
|
818
|
-
scrollContainer.scrollBy(scrollLeft, scrollTop);
|
|
819
|
-
}, []);
|
|
820
|
-
const sortedScrollableAncestors = (0, import_react.useMemo)(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
|
|
821
|
-
(0, import_react.useEffect)(() => {
|
|
822
|
-
if (!enabled || !scrollableAncestors.length || !rect) {
|
|
823
|
-
clearAutoScrollInterval();
|
|
824
|
-
return;
|
|
825
|
-
}
|
|
826
|
-
for (const scrollContainer of sortedScrollableAncestors) {
|
|
827
|
-
if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) continue;
|
|
828
|
-
const scrolllContainerRect = scrollableAncestorRects[scrollableAncestors.indexOf(scrollContainer)];
|
|
829
|
-
if (!scrolllContainerRect) continue;
|
|
830
|
-
const { direction, speed } = getScrollDirectionAndSpeed(scrollContainer, scrolllContainerRect, rect, acceleration, threshold);
|
|
831
|
-
if (speed.x > 0 || speed.y > 0) {
|
|
832
|
-
clearAutoScrollInterval();
|
|
833
|
-
scrollContainerRef.current = scrollContainer;
|
|
834
|
-
setAutoScrollInterval(autoScroll, interval);
|
|
835
|
-
scrollSpeed.current = speed;
|
|
836
|
-
scrollDirection.current = direction;
|
|
837
|
-
return;
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
scrollSpeed.current = {
|
|
841
|
-
x: 0,
|
|
842
|
-
y: 0
|
|
843
|
-
};
|
|
844
|
-
scrollDirection.current = {
|
|
845
|
-
x: 0,
|
|
846
|
-
y: 0
|
|
847
|
-
};
|
|
848
|
-
clearAutoScrollInterval();
|
|
849
|
-
}, [
|
|
850
|
-
acceleration,
|
|
851
|
-
autoScroll,
|
|
852
|
-
canScroll,
|
|
853
|
-
clearAutoScrollInterval,
|
|
854
|
-
enabled,
|
|
855
|
-
interval,
|
|
856
|
-
JSON.stringify(rect),
|
|
857
|
-
setAutoScrollInterval,
|
|
858
|
-
scrollableAncestors,
|
|
859
|
-
sortedScrollableAncestors,
|
|
860
|
-
scrollableAncestorRects,
|
|
861
|
-
JSON.stringify(threshold)
|
|
862
|
-
]);
|
|
809
|
+
function getEventListenerTarget(target) {
|
|
810
|
+
const { EventTarget } = getWindow(target);
|
|
811
|
+
return target instanceof EventTarget ? target : getOwnerDocument(target);
|
|
863
812
|
}
|
|
864
|
-
function
|
|
865
|
-
const
|
|
866
|
-
const
|
|
867
|
-
return
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
813
|
+
function hasExceededDistance(delta, measurement) {
|
|
814
|
+
const dx = Math.abs(delta.x);
|
|
815
|
+
const dy = Math.abs(delta.y);
|
|
816
|
+
if (typeof measurement === "number") return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
|
|
817
|
+
if ("x" in measurement && "y" in measurement) return dx > measurement.x && dy > measurement.y;
|
|
818
|
+
if ("x" in measurement) return dx > measurement.x;
|
|
819
|
+
if ("y" in measurement) return dy > measurement.y;
|
|
820
|
+
return false;
|
|
872
821
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
822
|
+
var EventName;
|
|
823
|
+
(function(EventName) {
|
|
824
|
+
EventName["Click"] = "click";
|
|
825
|
+
EventName["DragStart"] = "dragstart";
|
|
826
|
+
EventName["Keydown"] = "keydown";
|
|
827
|
+
EventName["ContextMenu"] = "contextmenu";
|
|
828
|
+
EventName["Resize"] = "resize";
|
|
829
|
+
EventName["SelectionChange"] = "selectionchange";
|
|
830
|
+
EventName["VisibilityChange"] = "visibilitychange";
|
|
831
|
+
})(EventName || (EventName = {}));
|
|
832
|
+
function preventDefault(event) {
|
|
833
|
+
event.preventDefault();
|
|
882
834
|
}
|
|
883
|
-
function
|
|
884
|
-
|
|
885
|
-
useIsomorphicLayoutEffect(() => {
|
|
886
|
-
if (dataRef.current !== data) dataRef.current = data;
|
|
887
|
-
}, [data]);
|
|
888
|
-
return dataRef;
|
|
835
|
+
function stopPropagation(event) {
|
|
836
|
+
event.stopPropagation();
|
|
889
837
|
}
|
|
890
|
-
var
|
|
891
|
-
(function(
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
var
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
838
|
+
var KeyboardCode;
|
|
839
|
+
(function(KeyboardCode) {
|
|
840
|
+
KeyboardCode["Space"] = "Space";
|
|
841
|
+
KeyboardCode["Down"] = "ArrowDown";
|
|
842
|
+
KeyboardCode["Right"] = "ArrowRight";
|
|
843
|
+
KeyboardCode["Left"] = "ArrowLeft";
|
|
844
|
+
KeyboardCode["Up"] = "ArrowUp";
|
|
845
|
+
KeyboardCode["Esc"] = "Escape";
|
|
846
|
+
KeyboardCode["Enter"] = "Enter";
|
|
847
|
+
KeyboardCode["Tab"] = "Tab";
|
|
848
|
+
})(KeyboardCode || (KeyboardCode = {}));
|
|
849
|
+
var defaultKeyboardCodes = {
|
|
850
|
+
start: [KeyboardCode.Space, KeyboardCode.Enter],
|
|
851
|
+
cancel: [KeyboardCode.Esc],
|
|
852
|
+
end: [
|
|
853
|
+
KeyboardCode.Space,
|
|
854
|
+
KeyboardCode.Enter,
|
|
855
|
+
KeyboardCode.Tab
|
|
856
|
+
]
|
|
905
857
|
};
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
const { frequency, measure, strategy } = {
|
|
909
|
-
...defaultConfig,
|
|
910
|
-
...config
|
|
911
|
-
};
|
|
912
|
-
const containersRef = (0, import_react.useRef)(containers);
|
|
913
|
-
const recomputeLayouts = (0, import_react.useCallback)(() => setWillRecomputeLayouts(true), []);
|
|
914
|
-
const recomputeLayoutsTimeoutId = (0, import_react.useRef)(null);
|
|
915
|
-
const disabled = isDisabled();
|
|
916
|
-
const layoutRectMap = useLazyMemo((previousValue) => {
|
|
917
|
-
if (disabled && !dragging) return defaultValue;
|
|
918
|
-
if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || willRecomputeLayouts) {
|
|
919
|
-
for (let container of containers) {
|
|
920
|
-
if (!container) continue;
|
|
921
|
-
container.rect.current = container.node.current ? measure(container.node.current) : null;
|
|
922
|
-
}
|
|
923
|
-
return createLayoutRectMap(containers);
|
|
924
|
-
}
|
|
925
|
-
return previousValue;
|
|
926
|
-
}, [
|
|
927
|
-
containers,
|
|
928
|
-
dragging,
|
|
929
|
-
disabled,
|
|
930
|
-
measure,
|
|
931
|
-
willRecomputeLayouts
|
|
932
|
-
]);
|
|
933
|
-
(0, import_react.useEffect)(() => {
|
|
934
|
-
containersRef.current = containers;
|
|
935
|
-
}, [containers]);
|
|
936
|
-
(0, import_react.useEffect)(() => {
|
|
937
|
-
if (willRecomputeLayouts) setWillRecomputeLayouts(false);
|
|
938
|
-
}, [willRecomputeLayouts]);
|
|
939
|
-
(0, import_react.useEffect)(function recompute() {
|
|
940
|
-
if (disabled) return;
|
|
941
|
-
requestAnimationFrame(recomputeLayouts);
|
|
942
|
-
}, [dragging, disabled]);
|
|
943
|
-
(0, import_react.useEffect)(function forceRecomputeLayouts() {
|
|
944
|
-
if (disabled || typeof frequency !== "number" || recomputeLayoutsTimeoutId.current !== null) return;
|
|
945
|
-
recomputeLayoutsTimeoutId.current = setTimeout(() => {
|
|
946
|
-
recomputeLayouts();
|
|
947
|
-
recomputeLayoutsTimeoutId.current = null;
|
|
948
|
-
}, frequency);
|
|
949
|
-
}, [
|
|
950
|
-
frequency,
|
|
951
|
-
disabled,
|
|
952
|
-
recomputeLayouts,
|
|
953
|
-
...dependencies
|
|
954
|
-
]);
|
|
955
|
-
return {
|
|
956
|
-
layoutRectMap,
|
|
957
|
-
recomputeLayouts,
|
|
958
|
-
willRecomputeLayouts
|
|
959
|
-
};
|
|
960
|
-
function isDisabled() {
|
|
961
|
-
switch (strategy) {
|
|
962
|
-
case MeasuringStrategy.Always: return false;
|
|
963
|
-
case MeasuringStrategy.BeforeDragging: return dragging;
|
|
964
|
-
default: return !dragging;
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
function createLayoutRectMap(containers) {
|
|
969
|
-
const layoutRectMap = /* @__PURE__ */ new Map();
|
|
970
|
-
if (containers) for (const container of containers) {
|
|
971
|
-
if (!container) continue;
|
|
972
|
-
const { id, rect } = container;
|
|
973
|
-
if (rect.current == null) continue;
|
|
974
|
-
layoutRectMap.set(id, rect.current);
|
|
975
|
-
}
|
|
976
|
-
return layoutRectMap;
|
|
977
|
-
}
|
|
978
|
-
function useScrollOffsets(elements) {
|
|
979
|
-
const [scrollCoordinates, setScrollCoordinates] = (0, import_react.useState)(null);
|
|
980
|
-
const prevElements = (0, import_react.useRef)(elements);
|
|
981
|
-
const handleScroll = (0, import_react.useCallback)((event) => {
|
|
982
|
-
const scrollingElement = getScrollableElement(event.target);
|
|
983
|
-
if (!scrollingElement) return;
|
|
984
|
-
setScrollCoordinates((scrollCoordinates) => {
|
|
985
|
-
if (!scrollCoordinates) return null;
|
|
986
|
-
scrollCoordinates.set(scrollingElement, getScrollCoordinates(scrollingElement));
|
|
987
|
-
return new Map(scrollCoordinates);
|
|
988
|
-
});
|
|
989
|
-
}, []);
|
|
990
|
-
(0, import_react.useEffect)(() => {
|
|
991
|
-
const previousElements = prevElements.current;
|
|
992
|
-
if (elements !== previousElements) {
|
|
993
|
-
cleanup(previousElements);
|
|
994
|
-
const entries = elements.map((element) => {
|
|
995
|
-
const scrollableElement = getScrollableElement(element);
|
|
996
|
-
if (scrollableElement) {
|
|
997
|
-
scrollableElement.addEventListener("scroll", handleScroll, { passive: true });
|
|
998
|
-
return [scrollableElement, getScrollCoordinates(scrollableElement)];
|
|
999
|
-
}
|
|
1000
|
-
return null;
|
|
1001
|
-
}).filter((entry) => entry != null);
|
|
1002
|
-
setScrollCoordinates(entries.length ? new Map(entries) : null);
|
|
1003
|
-
prevElements.current = elements;
|
|
1004
|
-
}
|
|
1005
|
-
return () => {
|
|
1006
|
-
cleanup(elements);
|
|
1007
|
-
cleanup(previousElements);
|
|
1008
|
-
};
|
|
1009
|
-
function cleanup(elements) {
|
|
1010
|
-
elements.forEach((element) => {
|
|
1011
|
-
getScrollableElement(element)?.removeEventListener("scroll", handleScroll);
|
|
1012
|
-
});
|
|
1013
|
-
}
|
|
1014
|
-
}, [handleScroll, elements]);
|
|
1015
|
-
return (0, import_react.useMemo)(() => {
|
|
1016
|
-
if (elements.length) return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
|
|
1017
|
-
return defaultCoordinates;
|
|
1018
|
-
}, [elements, scrollCoordinates]);
|
|
1019
|
-
}
|
|
1020
|
-
var defaultValue$1 = [];
|
|
1021
|
-
function useScrollableAncestors(node) {
|
|
1022
|
-
const previousNode = (0, import_react.useRef)(node);
|
|
1023
|
-
const ancestors = useLazyMemo((previousValue) => {
|
|
1024
|
-
if (!node) return defaultValue$1;
|
|
1025
|
-
if (previousValue && node && previousNode.current && node.parentNode === previousNode.current.parentNode) return previousValue;
|
|
1026
|
-
return getScrollableAncestors(node);
|
|
1027
|
-
}, [node]);
|
|
1028
|
-
(0, import_react.useEffect)(() => {
|
|
1029
|
-
previousNode.current = node;
|
|
1030
|
-
}, [node]);
|
|
1031
|
-
return ancestors;
|
|
1032
|
-
}
|
|
1033
|
-
function useSensorSetup(sensors) {
|
|
1034
|
-
(0, import_react.useEffect)(() => {
|
|
1035
|
-
if (!canUseDOM) return;
|
|
1036
|
-
const teardownFns = sensors.map(({ sensor }) => sensor.setup == null ? void 0 : sensor.setup());
|
|
1037
|
-
return () => {
|
|
1038
|
-
for (const teardown of teardownFns) teardown?.();
|
|
1039
|
-
};
|
|
1040
|
-
}, sensors.map(({ sensor }) => sensor));
|
|
1041
|
-
}
|
|
1042
|
-
function useSyntheticListeners(listeners, id) {
|
|
1043
|
-
return (0, import_react.useMemo)(() => {
|
|
1044
|
-
return listeners.reduce((acc, { eventName, handler }) => {
|
|
1045
|
-
acc[eventName] = (event) => {
|
|
1046
|
-
handler(event, id);
|
|
1047
|
-
};
|
|
1048
|
-
return acc;
|
|
1049
|
-
}, {});
|
|
1050
|
-
}, [listeners, id]);
|
|
1051
|
-
}
|
|
1052
|
-
var useClientRect = /* @__PURE__ */ createUseRectFn(getBoundingClientRect);
|
|
1053
|
-
var useClientRects = /* @__PURE__ */ createUseRectsFn(getBoundingClientRect);
|
|
1054
|
-
function useRect(element, getRect, forceRecompute) {
|
|
1055
|
-
const previousElement = (0, import_react.useRef)(element);
|
|
1056
|
-
return useLazyMemo((previousValue) => {
|
|
1057
|
-
if (!element) return null;
|
|
1058
|
-
if (forceRecompute || !previousValue && element || element !== previousElement.current) {
|
|
1059
|
-
if (isHTMLElement(element) && element.parentNode == null) return null;
|
|
1060
|
-
return getRect(element);
|
|
1061
|
-
}
|
|
1062
|
-
return previousValue != null ? previousValue : null;
|
|
1063
|
-
}, [
|
|
1064
|
-
element,
|
|
1065
|
-
forceRecompute,
|
|
1066
|
-
getRect
|
|
1067
|
-
]);
|
|
1068
|
-
}
|
|
1069
|
-
function createUseRectFn(getRect) {
|
|
1070
|
-
return (element, forceRecompute) => useRect(element, getRect, forceRecompute);
|
|
1071
|
-
}
|
|
1072
|
-
function createUseRectsFn(getRect) {
|
|
1073
|
-
const defaultValue = [];
|
|
1074
|
-
return function useRects(elements, forceRecompute) {
|
|
1075
|
-
const previousElements = (0, import_react.useRef)(elements);
|
|
1076
|
-
return useLazyMemo((previousValue) => {
|
|
1077
|
-
if (!elements.length) return defaultValue;
|
|
1078
|
-
if (forceRecompute || !previousValue && elements.length || elements !== previousElements.current) return elements.map((element) => getRect(element));
|
|
1079
|
-
return previousValue != null ? previousValue : defaultValue;
|
|
1080
|
-
}, [elements, forceRecompute]);
|
|
1081
|
-
};
|
|
1082
|
-
}
|
|
1083
|
-
function getMeasurableNode(node) {
|
|
1084
|
-
if (!node) return null;
|
|
1085
|
-
if (node.children.length > 1) return node;
|
|
1086
|
-
const firstChild = node.children[0];
|
|
1087
|
-
return isHTMLElement(firstChild) ? firstChild : node;
|
|
1088
|
-
}
|
|
1089
|
-
function getDragOverlayRect(element) {
|
|
1090
|
-
const { width, height, offsetLeft, offsetTop } = getLayoutRect(element);
|
|
1091
|
-
return {
|
|
1092
|
-
top: offsetTop,
|
|
1093
|
-
bottom: offsetTop + height,
|
|
1094
|
-
left: offsetLeft,
|
|
1095
|
-
right: offsetLeft + width,
|
|
1096
|
-
width,
|
|
1097
|
-
height,
|
|
1098
|
-
offsetTop,
|
|
1099
|
-
offsetLeft
|
|
1100
|
-
};
|
|
1101
|
-
}
|
|
1102
|
-
var useDragOverlayRect = /* @__PURE__ */ createUseRectFn(getDragOverlayRect);
|
|
1103
|
-
function useDragOverlayMeasuring({ disabled, forceRecompute }) {
|
|
1104
|
-
const [nodeRef, setRef] = useNodeRef();
|
|
1105
|
-
const rect = useDragOverlayRect(disabled ? null : getMeasurableNode(nodeRef.current), forceRecompute);
|
|
1106
|
-
return (0, import_react.useMemo)(() => ({
|
|
1107
|
-
nodeRef,
|
|
1108
|
-
rect,
|
|
1109
|
-
setRef
|
|
1110
|
-
}), [
|
|
1111
|
-
rect,
|
|
1112
|
-
nodeRef,
|
|
1113
|
-
setRef
|
|
1114
|
-
]);
|
|
1115
|
-
}
|
|
1116
|
-
function useSensor(sensor, options) {
|
|
1117
|
-
return (0, import_react.useMemo)(() => ({
|
|
1118
|
-
sensor,
|
|
1119
|
-
options: options != null ? options : {}
|
|
1120
|
-
}), [sensor, options]);
|
|
1121
|
-
}
|
|
1122
|
-
function useSensors(...sensors) {
|
|
1123
|
-
return (0, import_react.useMemo)(() => [...sensors].filter((sensor) => sensor != null), [...sensors]);
|
|
1124
|
-
}
|
|
1125
|
-
var Listeners = class {
|
|
1126
|
-
constructor(target) {
|
|
1127
|
-
this.target = target;
|
|
1128
|
-
this.listeners = [];
|
|
1129
|
-
this.removeAll = () => {
|
|
1130
|
-
this.listeners.forEach((listener) => {
|
|
1131
|
-
var _this$target;
|
|
1132
|
-
return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
|
|
1133
|
-
});
|
|
1134
|
-
};
|
|
1135
|
-
}
|
|
1136
|
-
add(eventName, handler, options) {
|
|
1137
|
-
var _this$target2;
|
|
1138
|
-
(_this$target2 = this.target) == null || _this$target2.addEventListener(eventName, handler, options);
|
|
1139
|
-
this.listeners.push([
|
|
1140
|
-
eventName,
|
|
1141
|
-
handler,
|
|
1142
|
-
options
|
|
1143
|
-
]);
|
|
1144
|
-
}
|
|
1145
|
-
};
|
|
1146
|
-
function getEventListenerTarget(target) {
|
|
1147
|
-
const { EventTarget } = getWindow(target);
|
|
1148
|
-
return target instanceof EventTarget ? target : getOwnerDocument(target);
|
|
1149
|
-
}
|
|
1150
|
-
function hasExceededDistance(delta, measurement) {
|
|
1151
|
-
const dx = Math.abs(delta.x);
|
|
1152
|
-
const dy = Math.abs(delta.y);
|
|
1153
|
-
if (typeof measurement === "number") return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
|
|
1154
|
-
if ("x" in measurement && "y" in measurement) return dx > measurement.x && dy > measurement.y;
|
|
1155
|
-
if ("x" in measurement) return dx > measurement.x;
|
|
1156
|
-
if ("y" in measurement) return dy > measurement.y;
|
|
1157
|
-
return false;
|
|
1158
|
-
}
|
|
1159
|
-
var EventName;
|
|
1160
|
-
(function(EventName) {
|
|
1161
|
-
EventName["Click"] = "click";
|
|
1162
|
-
EventName["DragStart"] = "dragstart";
|
|
1163
|
-
EventName["Keydown"] = "keydown";
|
|
1164
|
-
EventName["ContextMenu"] = "contextmenu";
|
|
1165
|
-
EventName["Resize"] = "resize";
|
|
1166
|
-
EventName["SelectionChange"] = "selectionchange";
|
|
1167
|
-
EventName["VisibilityChange"] = "visibilitychange";
|
|
1168
|
-
})(EventName || (EventName = {}));
|
|
1169
|
-
function preventDefault(event) {
|
|
1170
|
-
event.preventDefault();
|
|
1171
|
-
}
|
|
1172
|
-
function stopPropagation(event) {
|
|
1173
|
-
event.stopPropagation();
|
|
1174
|
-
}
|
|
1175
|
-
var KeyboardCode;
|
|
1176
|
-
(function(KeyboardCode) {
|
|
1177
|
-
KeyboardCode["Space"] = "Space";
|
|
1178
|
-
KeyboardCode["Down"] = "ArrowDown";
|
|
1179
|
-
KeyboardCode["Right"] = "ArrowRight";
|
|
1180
|
-
KeyboardCode["Left"] = "ArrowLeft";
|
|
1181
|
-
KeyboardCode["Up"] = "ArrowUp";
|
|
1182
|
-
KeyboardCode["Esc"] = "Escape";
|
|
1183
|
-
KeyboardCode["Enter"] = "Enter";
|
|
1184
|
-
})(KeyboardCode || (KeyboardCode = {}));
|
|
1185
|
-
var defaultKeyboardCodes = {
|
|
1186
|
-
start: [KeyboardCode.Space, KeyboardCode.Enter],
|
|
1187
|
-
cancel: [KeyboardCode.Esc],
|
|
1188
|
-
end: [KeyboardCode.Space, KeyboardCode.Enter]
|
|
1189
|
-
};
|
|
1190
|
-
var defaultKeyboardCoordinateGetter = (event, { currentCoordinates }) => {
|
|
858
|
+
var defaultKeyboardCoordinateGetter = (event, _ref) => {
|
|
859
|
+
let { currentCoordinates } = _ref;
|
|
1191
860
|
switch (event.code) {
|
|
1192
861
|
case KeyboardCode.Right: return {
|
|
1193
862
|
...currentCoordinates,
|
|
@@ -1209,9 +878,12 @@ var defaultKeyboardCoordinateGetter = (event, { currentCoordinates }) => {
|
|
|
1209
878
|
};
|
|
1210
879
|
var KeyboardSensor = class {
|
|
1211
880
|
constructor(props) {
|
|
1212
|
-
this.props =
|
|
881
|
+
this.props = void 0;
|
|
1213
882
|
this.autoScrollEnabled = false;
|
|
1214
|
-
this.
|
|
883
|
+
this.referenceCoordinates = void 0;
|
|
884
|
+
this.listeners = void 0;
|
|
885
|
+
this.windowListeners = void 0;
|
|
886
|
+
this.props = props;
|
|
1215
887
|
const { event: { target } } = props;
|
|
1216
888
|
this.props = props;
|
|
1217
889
|
this.listeners = new Listeners(getOwnerDocument(target));
|
|
@@ -1228,18 +900,12 @@ var KeyboardSensor = class {
|
|
|
1228
900
|
}
|
|
1229
901
|
handleStart() {
|
|
1230
902
|
const { activeNode, onStart } = this.props;
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
x: activeNodeRect.left,
|
|
1235
|
-
y: activeNodeRect.top
|
|
1236
|
-
};
|
|
1237
|
-
this.coordinates = coordinates;
|
|
1238
|
-
onStart(coordinates);
|
|
903
|
+
const node = activeNode.node.current;
|
|
904
|
+
if (node) scrollIntoViewIfNeeded(node);
|
|
905
|
+
onStart(defaultCoordinates);
|
|
1239
906
|
}
|
|
1240
907
|
handleKeyDown(event) {
|
|
1241
908
|
if (isKeyboardEvent(event)) {
|
|
1242
|
-
const { coordinates } = this;
|
|
1243
909
|
const { active, context, options } = this.props;
|
|
1244
910
|
const { keyboardCodes = defaultKeyboardCodes, coordinateGetter = defaultKeyboardCoordinateGetter, scrollBehavior = "smooth" } = options;
|
|
1245
911
|
const { code } = event;
|
|
@@ -1251,12 +917,19 @@ var KeyboardSensor = class {
|
|
|
1251
917
|
this.handleCancel(event);
|
|
1252
918
|
return;
|
|
1253
919
|
}
|
|
920
|
+
const { collisionRect } = context.current;
|
|
921
|
+
const currentCoordinates = collisionRect ? {
|
|
922
|
+
x: collisionRect.left,
|
|
923
|
+
y: collisionRect.top
|
|
924
|
+
} : defaultCoordinates;
|
|
925
|
+
if (!this.referenceCoordinates) this.referenceCoordinates = currentCoordinates;
|
|
1254
926
|
const newCoordinates = coordinateGetter(event, {
|
|
1255
927
|
active,
|
|
1256
928
|
context: context.current,
|
|
1257
|
-
currentCoordinates
|
|
929
|
+
currentCoordinates
|
|
1258
930
|
});
|
|
1259
931
|
if (newCoordinates) {
|
|
932
|
+
const coordinatesDelta = subtract(newCoordinates, currentCoordinates);
|
|
1260
933
|
const scrollDelta = {
|
|
1261
934
|
x: 0,
|
|
1262
935
|
y: 0
|
|
@@ -1264,7 +937,6 @@ var KeyboardSensor = class {
|
|
|
1264
937
|
const { scrollableAncestors } = context.current;
|
|
1265
938
|
for (const scrollContainer of scrollableAncestors) {
|
|
1266
939
|
const direction = event.code;
|
|
1267
|
-
const coordinatesDelta = subtract(newCoordinates, coordinates);
|
|
1268
940
|
const { isTop, isRight, isLeft, isBottom, maxScroll, minScroll } = getScrollPosition(scrollContainer);
|
|
1269
941
|
const scrollElementRect = getScrollElementRect(scrollContainer);
|
|
1270
942
|
const clampedCoordinates = {
|
|
@@ -1274,36 +946,42 @@ var KeyboardSensor = class {
|
|
|
1274
946
|
const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft;
|
|
1275
947
|
const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop;
|
|
1276
948
|
if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
949
|
+
const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x;
|
|
950
|
+
const canScrollToNewCoordinates = direction === KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === KeyboardCode.Left && newScrollCoordinates >= minScroll.x;
|
|
951
|
+
if (canScrollToNewCoordinates && !coordinatesDelta.y) {
|
|
952
|
+
scrollContainer.scrollTo({
|
|
953
|
+
left: newScrollCoordinates,
|
|
1280
954
|
behavior: scrollBehavior
|
|
1281
955
|
});
|
|
1282
956
|
return;
|
|
1283
957
|
}
|
|
1284
|
-
scrollDelta.x =
|
|
1285
|
-
scrollContainer.
|
|
958
|
+
if (canScrollToNewCoordinates) scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates;
|
|
959
|
+
else scrollDelta.x = direction === KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x;
|
|
960
|
+
if (scrollDelta.x) scrollContainer.scrollBy({
|
|
1286
961
|
left: -scrollDelta.x,
|
|
1287
962
|
behavior: scrollBehavior
|
|
1288
963
|
});
|
|
1289
964
|
break;
|
|
1290
965
|
} else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
966
|
+
const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;
|
|
967
|
+
const canScrollToNewCoordinates = direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y;
|
|
968
|
+
if (canScrollToNewCoordinates && !coordinatesDelta.x) {
|
|
969
|
+
scrollContainer.scrollTo({
|
|
970
|
+
top: newScrollCoordinates,
|
|
1294
971
|
behavior: scrollBehavior
|
|
1295
972
|
});
|
|
1296
973
|
return;
|
|
1297
974
|
}
|
|
1298
|
-
scrollDelta.y =
|
|
1299
|
-
scrollContainer.
|
|
975
|
+
if (canScrollToNewCoordinates) scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates;
|
|
976
|
+
else scrollDelta.y = direction === KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y;
|
|
977
|
+
if (scrollDelta.y) scrollContainer.scrollBy({
|
|
1300
978
|
top: -scrollDelta.y,
|
|
1301
979
|
behavior: scrollBehavior
|
|
1302
980
|
});
|
|
1303
981
|
break;
|
|
1304
982
|
}
|
|
1305
983
|
}
|
|
1306
|
-
this.handleMove(event, add(newCoordinates, scrollDelta));
|
|
984
|
+
this.handleMove(event, add(subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
|
|
1307
985
|
}
|
|
1308
986
|
}
|
|
1309
987
|
}
|
|
@@ -1311,7 +989,6 @@ var KeyboardSensor = class {
|
|
|
1311
989
|
const { onMove } = this.props;
|
|
1312
990
|
event.preventDefault();
|
|
1313
991
|
onMove(coordinates);
|
|
1314
|
-
this.coordinates = coordinates;
|
|
1315
992
|
}
|
|
1316
993
|
handleEnd(event) {
|
|
1317
994
|
const { onEnd } = this.props;
|
|
@@ -1332,9 +1009,13 @@ var KeyboardSensor = class {
|
|
|
1332
1009
|
};
|
|
1333
1010
|
KeyboardSensor.activators = [{
|
|
1334
1011
|
eventName: "onKeyDown",
|
|
1335
|
-
handler: (event,
|
|
1012
|
+
handler: (event, _ref, _ref2) => {
|
|
1013
|
+
let { keyboardCodes = defaultKeyboardCodes, onActivation } = _ref;
|
|
1014
|
+
let { active } = _ref2;
|
|
1336
1015
|
const { code } = event.nativeEvent;
|
|
1337
1016
|
if (keyboardCodes.start.includes(code)) {
|
|
1017
|
+
const activator = active.activatorNode.current;
|
|
1018
|
+
if (activator && event.target !== activator) return false;
|
|
1338
1019
|
event.preventDefault();
|
|
1339
1020
|
onActivation?.({ event: event.nativeEvent });
|
|
1340
1021
|
return true;
|
|
@@ -1349,12 +1030,21 @@ function isDelayConstraint(constraint) {
|
|
|
1349
1030
|
return Boolean(constraint && "delay" in constraint);
|
|
1350
1031
|
}
|
|
1351
1032
|
var AbstractPointerSensor = class {
|
|
1352
|
-
constructor(props, events, listenerTarget
|
|
1353
|
-
|
|
1354
|
-
|
|
1033
|
+
constructor(props, events, listenerTarget) {
|
|
1034
|
+
var _getEventCoordinates;
|
|
1035
|
+
if (listenerTarget === void 0) listenerTarget = getEventListenerTarget(props.event.target);
|
|
1036
|
+
this.props = void 0;
|
|
1037
|
+
this.events = void 0;
|
|
1355
1038
|
this.autoScrollEnabled = true;
|
|
1039
|
+
this.document = void 0;
|
|
1356
1040
|
this.activated = false;
|
|
1041
|
+
this.initialCoordinates = void 0;
|
|
1357
1042
|
this.timeoutId = null;
|
|
1043
|
+
this.listeners = void 0;
|
|
1044
|
+
this.documentListeners = void 0;
|
|
1045
|
+
this.windowListeners = void 0;
|
|
1046
|
+
this.props = props;
|
|
1047
|
+
this.events = events;
|
|
1358
1048
|
const { event } = props;
|
|
1359
1049
|
const { target } = event;
|
|
1360
1050
|
this.props = props;
|
|
@@ -1363,7 +1053,7 @@ var AbstractPointerSensor = class {
|
|
|
1363
1053
|
this.documentListeners = new Listeners(this.document);
|
|
1364
1054
|
this.listeners = new Listeners(listenerTarget);
|
|
1365
1055
|
this.windowListeners = new Listeners(getWindow(target));
|
|
1366
|
-
this.initialCoordinates = getEventCoordinates(event);
|
|
1056
|
+
this.initialCoordinates = (_getEventCoordinates = getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
|
|
1367
1057
|
this.handleStart = this.handleStart.bind(this);
|
|
1368
1058
|
this.handleMove = this.handleMove.bind(this);
|
|
1369
1059
|
this.handleEnd = this.handleEnd.bind(this);
|
|
@@ -1373,18 +1063,28 @@ var AbstractPointerSensor = class {
|
|
|
1373
1063
|
this.attach();
|
|
1374
1064
|
}
|
|
1375
1065
|
attach() {
|
|
1376
|
-
const { events, props: { options: { activationConstraint } } } = this;
|
|
1066
|
+
const { events, props: { options: { activationConstraint, bypassActivationConstraint } } } = this;
|
|
1377
1067
|
this.listeners.add(events.move.name, this.handleMove, { passive: false });
|
|
1378
1068
|
this.listeners.add(events.end.name, this.handleEnd);
|
|
1069
|
+
if (events.cancel) this.listeners.add(events.cancel.name, this.handleCancel);
|
|
1379
1070
|
this.windowListeners.add(EventName.Resize, this.handleCancel);
|
|
1380
1071
|
this.windowListeners.add(EventName.DragStart, preventDefault);
|
|
1381
1072
|
this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
|
|
1382
1073
|
this.windowListeners.add(EventName.ContextMenu, preventDefault);
|
|
1383
1074
|
this.documentListeners.add(EventName.Keydown, this.handleKeydown);
|
|
1384
1075
|
if (activationConstraint) {
|
|
1385
|
-
if (
|
|
1076
|
+
if (bypassActivationConstraint != null && bypassActivationConstraint({
|
|
1077
|
+
event: this.props.event,
|
|
1078
|
+
activeNode: this.props.activeNode,
|
|
1079
|
+
options: this.props.options
|
|
1080
|
+
})) return this.handleStart();
|
|
1386
1081
|
if (isDelayConstraint(activationConstraint)) {
|
|
1387
1082
|
this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
|
|
1083
|
+
this.handlePending(activationConstraint);
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
if (isDistanceConstraint(activationConstraint)) {
|
|
1087
|
+
this.handlePending(activationConstraint);
|
|
1388
1088
|
return;
|
|
1389
1089
|
}
|
|
1390
1090
|
}
|
|
@@ -1399,6 +1099,10 @@ var AbstractPointerSensor = class {
|
|
|
1399
1099
|
this.timeoutId = null;
|
|
1400
1100
|
}
|
|
1401
1101
|
}
|
|
1102
|
+
handlePending(constraint, offset) {
|
|
1103
|
+
const { active, onPending } = this.props;
|
|
1104
|
+
onPending(active, constraint, this.initialCoordinates, offset);
|
|
1105
|
+
}
|
|
1402
1106
|
handleStart() {
|
|
1403
1107
|
const { initialCoordinates } = this;
|
|
1404
1108
|
const { onStart } = this.props;
|
|
@@ -1411,33 +1115,36 @@ var AbstractPointerSensor = class {
|
|
|
1411
1115
|
}
|
|
1412
1116
|
}
|
|
1413
1117
|
handleMove(event) {
|
|
1118
|
+
var _getEventCoordinates2;
|
|
1414
1119
|
const { activated, initialCoordinates, props } = this;
|
|
1415
1120
|
const { onMove, options: { activationConstraint } } = props;
|
|
1416
1121
|
if (!initialCoordinates) return;
|
|
1417
|
-
const coordinates = getEventCoordinates(event);
|
|
1122
|
+
const coordinates = (_getEventCoordinates2 = getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
|
|
1418
1123
|
const delta = subtract(initialCoordinates, coordinates);
|
|
1419
1124
|
if (!activated && activationConstraint) {
|
|
1420
|
-
if (isDelayConstraint(activationConstraint)) {
|
|
1421
|
-
if (hasExceededDistance(delta, activationConstraint.tolerance)) return this.handleCancel();
|
|
1422
|
-
return;
|
|
1423
|
-
}
|
|
1424
1125
|
if (isDistanceConstraint(activationConstraint)) {
|
|
1425
1126
|
if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) return this.handleCancel();
|
|
1426
1127
|
if (hasExceededDistance(delta, activationConstraint.distance)) return this.handleStart();
|
|
1427
|
-
return;
|
|
1428
1128
|
}
|
|
1129
|
+
if (isDelayConstraint(activationConstraint)) {
|
|
1130
|
+
if (hasExceededDistance(delta, activationConstraint.tolerance)) return this.handleCancel();
|
|
1131
|
+
}
|
|
1132
|
+
this.handlePending(activationConstraint, delta);
|
|
1133
|
+
return;
|
|
1429
1134
|
}
|
|
1430
1135
|
if (event.cancelable) event.preventDefault();
|
|
1431
1136
|
onMove(coordinates);
|
|
1432
1137
|
}
|
|
1433
1138
|
handleEnd() {
|
|
1434
|
-
const { onEnd } = this.props;
|
|
1139
|
+
const { onAbort, onEnd } = this.props;
|
|
1435
1140
|
this.detach();
|
|
1141
|
+
if (!this.activated) onAbort(this.props.active);
|
|
1436
1142
|
onEnd();
|
|
1437
1143
|
}
|
|
1438
1144
|
handleCancel() {
|
|
1439
|
-
const { onCancel } = this.props;
|
|
1145
|
+
const { onAbort, onCancel } = this.props;
|
|
1440
1146
|
this.detach();
|
|
1147
|
+
if (!this.activated) onAbort(this.props.active);
|
|
1441
1148
|
onCancel();
|
|
1442
1149
|
}
|
|
1443
1150
|
handleKeydown(event) {
|
|
@@ -1449,6 +1156,7 @@ var AbstractPointerSensor = class {
|
|
|
1449
1156
|
}
|
|
1450
1157
|
};
|
|
1451
1158
|
var events = {
|
|
1159
|
+
cancel: { name: "pointercancel" },
|
|
1452
1160
|
move: { name: "pointermove" },
|
|
1453
1161
|
end: { name: "pointerup" }
|
|
1454
1162
|
};
|
|
@@ -1461,7 +1169,9 @@ var PointerSensor = class extends AbstractPointerSensor {
|
|
|
1461
1169
|
};
|
|
1462
1170
|
PointerSensor.activators = [{
|
|
1463
1171
|
eventName: "onPointerDown",
|
|
1464
|
-
handler: (
|
|
1172
|
+
handler: (_ref, _ref2) => {
|
|
1173
|
+
let { nativeEvent: event } = _ref;
|
|
1174
|
+
let { onActivation } = _ref2;
|
|
1465
1175
|
if (!event.isPrimary || event.button !== 0) return false;
|
|
1466
1176
|
onActivation?.({ event });
|
|
1467
1177
|
return true;
|
|
@@ -1482,13 +1192,16 @@ var MouseSensor = class extends AbstractPointerSensor {
|
|
|
1482
1192
|
};
|
|
1483
1193
|
MouseSensor.activators = [{
|
|
1484
1194
|
eventName: "onMouseDown",
|
|
1485
|
-
handler: (
|
|
1195
|
+
handler: (_ref, _ref2) => {
|
|
1196
|
+
let { nativeEvent: event } = _ref;
|
|
1197
|
+
let { onActivation } = _ref2;
|
|
1486
1198
|
if (event.button === MouseButton.RightClick) return false;
|
|
1487
1199
|
onActivation?.({ event });
|
|
1488
1200
|
return true;
|
|
1489
1201
|
}
|
|
1490
1202
|
}];
|
|
1491
1203
|
var events$2 = {
|
|
1204
|
+
cancel: { name: "touchcancel" },
|
|
1492
1205
|
move: { name: "touchmove" },
|
|
1493
1206
|
end: { name: "touchend" }
|
|
1494
1207
|
};
|
|
@@ -1504,49 +1217,796 @@ var TouchSensor = class extends AbstractPointerSensor {
|
|
|
1504
1217
|
return function teardown() {
|
|
1505
1218
|
window.removeEventListener(events$2.move.name, noop);
|
|
1506
1219
|
};
|
|
1507
|
-
function noop() {}
|
|
1508
|
-
}
|
|
1509
|
-
};
|
|
1510
|
-
TouchSensor.activators = [{
|
|
1511
|
-
eventName: "onTouchStart",
|
|
1512
|
-
handler: (
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
return
|
|
1220
|
+
function noop() {}
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
TouchSensor.activators = [{
|
|
1224
|
+
eventName: "onTouchStart",
|
|
1225
|
+
handler: (_ref, _ref2) => {
|
|
1226
|
+
let { nativeEvent: event } = _ref;
|
|
1227
|
+
let { onActivation } = _ref2;
|
|
1228
|
+
const { touches } = event;
|
|
1229
|
+
if (touches.length > 1) return false;
|
|
1230
|
+
onActivation?.({ event });
|
|
1231
|
+
return true;
|
|
1232
|
+
}
|
|
1233
|
+
}];
|
|
1234
|
+
var AutoScrollActivator;
|
|
1235
|
+
(function(AutoScrollActivator) {
|
|
1236
|
+
AutoScrollActivator[AutoScrollActivator["Pointer"] = 0] = "Pointer";
|
|
1237
|
+
AutoScrollActivator[AutoScrollActivator["DraggableRect"] = 1] = "DraggableRect";
|
|
1238
|
+
})(AutoScrollActivator || (AutoScrollActivator = {}));
|
|
1239
|
+
var TraversalOrder;
|
|
1240
|
+
(function(TraversalOrder) {
|
|
1241
|
+
TraversalOrder[TraversalOrder["TreeOrder"] = 0] = "TreeOrder";
|
|
1242
|
+
TraversalOrder[TraversalOrder["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
|
|
1243
|
+
})(TraversalOrder || (TraversalOrder = {}));
|
|
1244
|
+
function useAutoScroller(_ref) {
|
|
1245
|
+
let { acceleration, activator = AutoScrollActivator.Pointer, canScroll, draggingRect, enabled, interval = 5, order = TraversalOrder.TreeOrder, pointerCoordinates, scrollableAncestors, scrollableAncestorRects, delta, threshold } = _ref;
|
|
1246
|
+
const scrollIntent = useScrollIntent({
|
|
1247
|
+
delta,
|
|
1248
|
+
disabled: !enabled
|
|
1249
|
+
});
|
|
1250
|
+
const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
|
|
1251
|
+
const scrollSpeed = (0, import_react.useRef)({
|
|
1252
|
+
x: 0,
|
|
1253
|
+
y: 0
|
|
1254
|
+
});
|
|
1255
|
+
const scrollDirection = (0, import_react.useRef)({
|
|
1256
|
+
x: 0,
|
|
1257
|
+
y: 0
|
|
1258
|
+
});
|
|
1259
|
+
const rect = (0, import_react.useMemo)(() => {
|
|
1260
|
+
switch (activator) {
|
|
1261
|
+
case AutoScrollActivator.Pointer: return pointerCoordinates ? {
|
|
1262
|
+
top: pointerCoordinates.y,
|
|
1263
|
+
bottom: pointerCoordinates.y,
|
|
1264
|
+
left: pointerCoordinates.x,
|
|
1265
|
+
right: pointerCoordinates.x
|
|
1266
|
+
} : null;
|
|
1267
|
+
case AutoScrollActivator.DraggableRect: return draggingRect;
|
|
1268
|
+
}
|
|
1269
|
+
}, [
|
|
1270
|
+
activator,
|
|
1271
|
+
draggingRect,
|
|
1272
|
+
pointerCoordinates
|
|
1273
|
+
]);
|
|
1274
|
+
const scrollContainerRef = (0, import_react.useRef)(null);
|
|
1275
|
+
const autoScroll = (0, import_react.useCallback)(() => {
|
|
1276
|
+
const scrollContainer = scrollContainerRef.current;
|
|
1277
|
+
if (!scrollContainer) return;
|
|
1278
|
+
const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
|
|
1279
|
+
const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
|
|
1280
|
+
scrollContainer.scrollBy(scrollLeft, scrollTop);
|
|
1281
|
+
}, []);
|
|
1282
|
+
const sortedScrollableAncestors = (0, import_react.useMemo)(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
|
|
1283
|
+
(0, import_react.useEffect)(() => {
|
|
1284
|
+
if (!enabled || !scrollableAncestors.length || !rect) {
|
|
1285
|
+
clearAutoScrollInterval();
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
for (const scrollContainer of sortedScrollableAncestors) {
|
|
1289
|
+
if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) continue;
|
|
1290
|
+
const index = scrollableAncestors.indexOf(scrollContainer);
|
|
1291
|
+
const scrollContainerRect = scrollableAncestorRects[index];
|
|
1292
|
+
if (!scrollContainerRect) continue;
|
|
1293
|
+
const { direction, speed } = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold);
|
|
1294
|
+
for (const axis of ["x", "y"]) if (!scrollIntent[axis][direction[axis]]) {
|
|
1295
|
+
speed[axis] = 0;
|
|
1296
|
+
direction[axis] = 0;
|
|
1297
|
+
}
|
|
1298
|
+
if (speed.x > 0 || speed.y > 0) {
|
|
1299
|
+
clearAutoScrollInterval();
|
|
1300
|
+
scrollContainerRef.current = scrollContainer;
|
|
1301
|
+
setAutoScrollInterval(autoScroll, interval);
|
|
1302
|
+
scrollSpeed.current = speed;
|
|
1303
|
+
scrollDirection.current = direction;
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
scrollSpeed.current = {
|
|
1308
|
+
x: 0,
|
|
1309
|
+
y: 0
|
|
1310
|
+
};
|
|
1311
|
+
scrollDirection.current = {
|
|
1312
|
+
x: 0,
|
|
1313
|
+
y: 0
|
|
1314
|
+
};
|
|
1315
|
+
clearAutoScrollInterval();
|
|
1316
|
+
}, [
|
|
1317
|
+
acceleration,
|
|
1318
|
+
autoScroll,
|
|
1319
|
+
canScroll,
|
|
1320
|
+
clearAutoScrollInterval,
|
|
1321
|
+
enabled,
|
|
1322
|
+
interval,
|
|
1323
|
+
JSON.stringify(rect),
|
|
1324
|
+
JSON.stringify(scrollIntent),
|
|
1325
|
+
setAutoScrollInterval,
|
|
1326
|
+
scrollableAncestors,
|
|
1327
|
+
sortedScrollableAncestors,
|
|
1328
|
+
scrollableAncestorRects,
|
|
1329
|
+
JSON.stringify(threshold)
|
|
1330
|
+
]);
|
|
1331
|
+
}
|
|
1332
|
+
var defaultScrollIntent = {
|
|
1333
|
+
x: {
|
|
1334
|
+
[Direction.Backward]: false,
|
|
1335
|
+
[Direction.Forward]: false
|
|
1336
|
+
},
|
|
1337
|
+
y: {
|
|
1338
|
+
[Direction.Backward]: false,
|
|
1339
|
+
[Direction.Forward]: false
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
function useScrollIntent(_ref2) {
|
|
1343
|
+
let { delta, disabled } = _ref2;
|
|
1344
|
+
const previousDelta = usePrevious(delta);
|
|
1345
|
+
return useLazyMemo((previousIntent) => {
|
|
1346
|
+
if (disabled || !previousDelta || !previousIntent) return defaultScrollIntent;
|
|
1347
|
+
const direction = {
|
|
1348
|
+
x: Math.sign(delta.x - previousDelta.x),
|
|
1349
|
+
y: Math.sign(delta.y - previousDelta.y)
|
|
1350
|
+
};
|
|
1351
|
+
return {
|
|
1352
|
+
x: {
|
|
1353
|
+
[Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1,
|
|
1354
|
+
[Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1
|
|
1355
|
+
},
|
|
1356
|
+
y: {
|
|
1357
|
+
[Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1,
|
|
1358
|
+
[Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
}, [
|
|
1362
|
+
disabled,
|
|
1363
|
+
delta,
|
|
1364
|
+
previousDelta
|
|
1365
|
+
]);
|
|
1366
|
+
}
|
|
1367
|
+
function useCachedNode(draggableNodes, id) {
|
|
1368
|
+
const draggableNode = id != null ? draggableNodes.get(id) : void 0;
|
|
1369
|
+
const node = draggableNode ? draggableNode.node.current : null;
|
|
1370
|
+
return useLazyMemo((cachedNode) => {
|
|
1371
|
+
var _ref;
|
|
1372
|
+
if (id == null) return null;
|
|
1373
|
+
return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
|
|
1374
|
+
}, [node, id]);
|
|
1375
|
+
}
|
|
1376
|
+
function useCombineActivators(sensors, getSyntheticHandler) {
|
|
1377
|
+
return (0, import_react.useMemo)(() => sensors.reduce((accumulator, sensor) => {
|
|
1378
|
+
const { sensor: Sensor } = sensor;
|
|
1379
|
+
const sensorActivators = Sensor.activators.map((activator) => ({
|
|
1380
|
+
eventName: activator.eventName,
|
|
1381
|
+
handler: getSyntheticHandler(activator.handler, sensor)
|
|
1382
|
+
}));
|
|
1383
|
+
return [...accumulator, ...sensorActivators];
|
|
1384
|
+
}, []), [sensors, getSyntheticHandler]);
|
|
1385
|
+
}
|
|
1386
|
+
var MeasuringStrategy;
|
|
1387
|
+
(function(MeasuringStrategy) {
|
|
1388
|
+
MeasuringStrategy[MeasuringStrategy["Always"] = 0] = "Always";
|
|
1389
|
+
MeasuringStrategy[MeasuringStrategy["BeforeDragging"] = 1] = "BeforeDragging";
|
|
1390
|
+
MeasuringStrategy[MeasuringStrategy["WhileDragging"] = 2] = "WhileDragging";
|
|
1391
|
+
})(MeasuringStrategy || (MeasuringStrategy = {}));
|
|
1392
|
+
var MeasuringFrequency;
|
|
1393
|
+
(function(MeasuringFrequency) {
|
|
1394
|
+
MeasuringFrequency["Optimized"] = "optimized";
|
|
1395
|
+
})(MeasuringFrequency || (MeasuringFrequency = {}));
|
|
1396
|
+
var defaultValue = /*#__PURE__*/ new Map();
|
|
1397
|
+
function useDroppableMeasuring(containers, _ref) {
|
|
1398
|
+
let { dragging, dependencies, config } = _ref;
|
|
1399
|
+
const [queue, setQueue] = (0, import_react.useState)(null);
|
|
1400
|
+
const { frequency, measure, strategy } = config;
|
|
1401
|
+
const containersRef = (0, import_react.useRef)(containers);
|
|
1402
|
+
const disabled = isDisabled();
|
|
1403
|
+
const disabledRef = useLatestValue(disabled);
|
|
1404
|
+
const measureDroppableContainers = (0, import_react.useCallback)(function(ids) {
|
|
1405
|
+
if (ids === void 0) ids = [];
|
|
1406
|
+
if (disabledRef.current) return;
|
|
1407
|
+
setQueue((value) => {
|
|
1408
|
+
if (value === null) return ids;
|
|
1409
|
+
return value.concat(ids.filter((id) => !value.includes(id)));
|
|
1410
|
+
});
|
|
1411
|
+
}, [disabledRef]);
|
|
1412
|
+
const timeoutId = (0, import_react.useRef)(null);
|
|
1413
|
+
const droppableRects = useLazyMemo((previousValue) => {
|
|
1414
|
+
if (disabled && !dragging) return defaultValue;
|
|
1415
|
+
if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || queue != null) {
|
|
1416
|
+
const map = /* @__PURE__ */ new Map();
|
|
1417
|
+
for (let container of containers) {
|
|
1418
|
+
if (!container) continue;
|
|
1419
|
+
if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) {
|
|
1420
|
+
map.set(container.id, container.rect.current);
|
|
1421
|
+
continue;
|
|
1422
|
+
}
|
|
1423
|
+
const node = container.node.current;
|
|
1424
|
+
const rect = node ? new Rect(measure(node), node) : null;
|
|
1425
|
+
container.rect.current = rect;
|
|
1426
|
+
if (rect) map.set(container.id, rect);
|
|
1427
|
+
}
|
|
1428
|
+
return map;
|
|
1429
|
+
}
|
|
1430
|
+
return previousValue;
|
|
1431
|
+
}, [
|
|
1432
|
+
containers,
|
|
1433
|
+
queue,
|
|
1434
|
+
dragging,
|
|
1435
|
+
disabled,
|
|
1436
|
+
measure
|
|
1437
|
+
]);
|
|
1438
|
+
(0, import_react.useEffect)(() => {
|
|
1439
|
+
containersRef.current = containers;
|
|
1440
|
+
}, [containers]);
|
|
1441
|
+
(0, import_react.useEffect)(() => {
|
|
1442
|
+
if (disabled) return;
|
|
1443
|
+
measureDroppableContainers();
|
|
1444
|
+
}, [dragging, disabled]);
|
|
1445
|
+
(0, import_react.useEffect)(() => {
|
|
1446
|
+
if (queue && queue.length > 0) setQueue(null);
|
|
1447
|
+
}, [JSON.stringify(queue)]);
|
|
1448
|
+
(0, import_react.useEffect)(() => {
|
|
1449
|
+
if (disabled || typeof frequency !== "number" || timeoutId.current !== null) return;
|
|
1450
|
+
timeoutId.current = setTimeout(() => {
|
|
1451
|
+
measureDroppableContainers();
|
|
1452
|
+
timeoutId.current = null;
|
|
1453
|
+
}, frequency);
|
|
1454
|
+
}, [
|
|
1455
|
+
frequency,
|
|
1456
|
+
disabled,
|
|
1457
|
+
measureDroppableContainers,
|
|
1458
|
+
...dependencies
|
|
1459
|
+
]);
|
|
1460
|
+
return {
|
|
1461
|
+
droppableRects,
|
|
1462
|
+
measureDroppableContainers,
|
|
1463
|
+
measuringScheduled: queue != null
|
|
1464
|
+
};
|
|
1465
|
+
function isDisabled() {
|
|
1466
|
+
switch (strategy) {
|
|
1467
|
+
case MeasuringStrategy.Always: return false;
|
|
1468
|
+
case MeasuringStrategy.BeforeDragging: return dragging;
|
|
1469
|
+
default: return !dragging;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
function useInitialValue(value, computeFn) {
|
|
1474
|
+
return useLazyMemo((previousValue) => {
|
|
1475
|
+
if (!value) return null;
|
|
1476
|
+
if (previousValue) return previousValue;
|
|
1477
|
+
return typeof computeFn === "function" ? computeFn(value) : value;
|
|
1478
|
+
}, [computeFn, value]);
|
|
1479
|
+
}
|
|
1480
|
+
function useInitialRect(node, measure) {
|
|
1481
|
+
return useInitialValue(node, measure);
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Returns a new MutationObserver instance.
|
|
1485
|
+
* If `MutationObserver` is undefined in the execution environment, returns `undefined`.
|
|
1486
|
+
*/
|
|
1487
|
+
function useMutationObserver(_ref) {
|
|
1488
|
+
let { callback, disabled } = _ref;
|
|
1489
|
+
const handleMutations = useEvent(callback);
|
|
1490
|
+
const mutationObserver = (0, import_react.useMemo)(() => {
|
|
1491
|
+
if (disabled || typeof window === "undefined" || typeof window.MutationObserver === "undefined") return;
|
|
1492
|
+
const { MutationObserver } = window;
|
|
1493
|
+
return new MutationObserver(handleMutations);
|
|
1494
|
+
}, [handleMutations, disabled]);
|
|
1495
|
+
(0, import_react.useEffect)(() => {
|
|
1496
|
+
return () => mutationObserver == null ? void 0 : mutationObserver.disconnect();
|
|
1497
|
+
}, [mutationObserver]);
|
|
1498
|
+
return mutationObserver;
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Returns a new ResizeObserver instance bound to the `onResize` callback.
|
|
1502
|
+
* If `ResizeObserver` is undefined in the execution environment, returns `undefined`.
|
|
1503
|
+
*/
|
|
1504
|
+
function useResizeObserver(_ref) {
|
|
1505
|
+
let { callback, disabled } = _ref;
|
|
1506
|
+
const handleResize = useEvent(callback);
|
|
1507
|
+
const resizeObserver = (0, import_react.useMemo)(() => {
|
|
1508
|
+
if (disabled || typeof window === "undefined" || typeof window.ResizeObserver === "undefined") return;
|
|
1509
|
+
const { ResizeObserver } = window;
|
|
1510
|
+
return new ResizeObserver(handleResize);
|
|
1511
|
+
}, [disabled]);
|
|
1512
|
+
(0, import_react.useEffect)(() => {
|
|
1513
|
+
return () => resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
1514
|
+
}, [resizeObserver]);
|
|
1515
|
+
return resizeObserver;
|
|
1516
|
+
}
|
|
1517
|
+
function defaultMeasure(element) {
|
|
1518
|
+
return new Rect(getClientRect(element), element);
|
|
1519
|
+
}
|
|
1520
|
+
function useRect(element, measure, fallbackRect) {
|
|
1521
|
+
if (measure === void 0) measure = defaultMeasure;
|
|
1522
|
+
const [rect, setRect] = (0, import_react.useState)(null);
|
|
1523
|
+
function measureRect() {
|
|
1524
|
+
setRect((currentRect) => {
|
|
1525
|
+
if (!element) return null;
|
|
1526
|
+
if (element.isConnected === false) {
|
|
1527
|
+
var _ref;
|
|
1528
|
+
return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null;
|
|
1529
|
+
}
|
|
1530
|
+
const newRect = measure(element);
|
|
1531
|
+
if (JSON.stringify(currentRect) === JSON.stringify(newRect)) return currentRect;
|
|
1532
|
+
return newRect;
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
const mutationObserver = useMutationObserver({ callback(records) {
|
|
1536
|
+
if (!element) return;
|
|
1537
|
+
for (const record of records) {
|
|
1538
|
+
const { type, target } = record;
|
|
1539
|
+
if (type === "childList" && target instanceof HTMLElement && target.contains(element)) {
|
|
1540
|
+
measureRect();
|
|
1541
|
+
break;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
} });
|
|
1545
|
+
const resizeObserver = useResizeObserver({ callback: measureRect });
|
|
1546
|
+
useIsomorphicLayoutEffect(() => {
|
|
1547
|
+
measureRect();
|
|
1548
|
+
if (element) {
|
|
1549
|
+
resizeObserver?.observe(element);
|
|
1550
|
+
mutationObserver?.observe(document.body, {
|
|
1551
|
+
childList: true,
|
|
1552
|
+
subtree: true
|
|
1553
|
+
});
|
|
1554
|
+
} else {
|
|
1555
|
+
resizeObserver?.disconnect();
|
|
1556
|
+
mutationObserver?.disconnect();
|
|
1557
|
+
}
|
|
1558
|
+
}, [element]);
|
|
1559
|
+
return rect;
|
|
1560
|
+
}
|
|
1561
|
+
function useRectDelta(rect) {
|
|
1562
|
+
return getRectDelta(rect, useInitialValue(rect));
|
|
1563
|
+
}
|
|
1564
|
+
var defaultValue$1 = [];
|
|
1565
|
+
function useScrollableAncestors(node) {
|
|
1566
|
+
const previousNode = (0, import_react.useRef)(node);
|
|
1567
|
+
const ancestors = useLazyMemo((previousValue) => {
|
|
1568
|
+
if (!node) return defaultValue$1;
|
|
1569
|
+
if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) return previousValue;
|
|
1570
|
+
return getScrollableAncestors(node);
|
|
1571
|
+
}, [node]);
|
|
1572
|
+
(0, import_react.useEffect)(() => {
|
|
1573
|
+
previousNode.current = node;
|
|
1574
|
+
}, [node]);
|
|
1575
|
+
return ancestors;
|
|
1576
|
+
}
|
|
1577
|
+
function useScrollOffsets(elements) {
|
|
1578
|
+
const [scrollCoordinates, setScrollCoordinates] = (0, import_react.useState)(null);
|
|
1579
|
+
const prevElements = (0, import_react.useRef)(elements);
|
|
1580
|
+
const handleScroll = (0, import_react.useCallback)((event) => {
|
|
1581
|
+
const scrollingElement = getScrollableElement(event.target);
|
|
1582
|
+
if (!scrollingElement) return;
|
|
1583
|
+
setScrollCoordinates((scrollCoordinates) => {
|
|
1584
|
+
if (!scrollCoordinates) return null;
|
|
1585
|
+
scrollCoordinates.set(scrollingElement, getScrollCoordinates(scrollingElement));
|
|
1586
|
+
return new Map(scrollCoordinates);
|
|
1587
|
+
});
|
|
1588
|
+
}, []);
|
|
1589
|
+
(0, import_react.useEffect)(() => {
|
|
1590
|
+
const previousElements = prevElements.current;
|
|
1591
|
+
if (elements !== previousElements) {
|
|
1592
|
+
cleanup(previousElements);
|
|
1593
|
+
const entries = elements.map((element) => {
|
|
1594
|
+
const scrollableElement = getScrollableElement(element);
|
|
1595
|
+
if (scrollableElement) {
|
|
1596
|
+
scrollableElement.addEventListener("scroll", handleScroll, { passive: true });
|
|
1597
|
+
return [scrollableElement, getScrollCoordinates(scrollableElement)];
|
|
1598
|
+
}
|
|
1599
|
+
return null;
|
|
1600
|
+
}).filter((entry) => entry != null);
|
|
1601
|
+
setScrollCoordinates(entries.length ? new Map(entries) : null);
|
|
1602
|
+
prevElements.current = elements;
|
|
1603
|
+
}
|
|
1604
|
+
return () => {
|
|
1605
|
+
cleanup(elements);
|
|
1606
|
+
cleanup(previousElements);
|
|
1607
|
+
};
|
|
1608
|
+
function cleanup(elements) {
|
|
1609
|
+
elements.forEach((element) => {
|
|
1610
|
+
getScrollableElement(element)?.removeEventListener("scroll", handleScroll);
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
}, [handleScroll, elements]);
|
|
1614
|
+
return (0, import_react.useMemo)(() => {
|
|
1615
|
+
if (elements.length) return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
|
|
1616
|
+
return defaultCoordinates;
|
|
1617
|
+
}, [elements, scrollCoordinates]);
|
|
1618
|
+
}
|
|
1619
|
+
function useScrollOffsetsDelta(scrollOffsets, dependencies) {
|
|
1620
|
+
if (dependencies === void 0) dependencies = [];
|
|
1621
|
+
const initialScrollOffsets = (0, import_react.useRef)(null);
|
|
1622
|
+
(0, import_react.useEffect)(() => {
|
|
1623
|
+
initialScrollOffsets.current = null;
|
|
1624
|
+
}, dependencies);
|
|
1625
|
+
(0, import_react.useEffect)(() => {
|
|
1626
|
+
const hasScrollOffsets = scrollOffsets !== defaultCoordinates;
|
|
1627
|
+
if (hasScrollOffsets && !initialScrollOffsets.current) initialScrollOffsets.current = scrollOffsets;
|
|
1628
|
+
if (!hasScrollOffsets && initialScrollOffsets.current) initialScrollOffsets.current = null;
|
|
1629
|
+
}, [scrollOffsets]);
|
|
1630
|
+
return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;
|
|
1631
|
+
}
|
|
1632
|
+
function useSensorSetup(sensors) {
|
|
1633
|
+
(0, import_react.useEffect)(() => {
|
|
1634
|
+
if (!canUseDOM) return;
|
|
1635
|
+
const teardownFns = sensors.map((_ref) => {
|
|
1636
|
+
let { sensor } = _ref;
|
|
1637
|
+
return sensor.setup == null ? void 0 : sensor.setup();
|
|
1638
|
+
});
|
|
1639
|
+
return () => {
|
|
1640
|
+
for (const teardown of teardownFns) teardown?.();
|
|
1641
|
+
};
|
|
1642
|
+
}, sensors.map((_ref2) => {
|
|
1643
|
+
let { sensor } = _ref2;
|
|
1644
|
+
return sensor;
|
|
1645
|
+
}));
|
|
1646
|
+
}
|
|
1647
|
+
function useSyntheticListeners(listeners, id) {
|
|
1648
|
+
return (0, import_react.useMemo)(() => {
|
|
1649
|
+
return listeners.reduce((acc, _ref) => {
|
|
1650
|
+
let { eventName, handler } = _ref;
|
|
1651
|
+
acc[eventName] = (event) => {
|
|
1652
|
+
handler(event, id);
|
|
1653
|
+
};
|
|
1654
|
+
return acc;
|
|
1655
|
+
}, {});
|
|
1656
|
+
}, [listeners, id]);
|
|
1657
|
+
}
|
|
1658
|
+
function useWindowRect(element) {
|
|
1659
|
+
return (0, import_react.useMemo)(() => element ? getWindowClientRect(element) : null, [element]);
|
|
1660
|
+
}
|
|
1661
|
+
var defaultValue$2 = [];
|
|
1662
|
+
function useRects(elements, measure) {
|
|
1663
|
+
if (measure === void 0) measure = getClientRect;
|
|
1664
|
+
const [firstElement] = elements;
|
|
1665
|
+
const windowRect = useWindowRect(firstElement ? getWindow(firstElement) : null);
|
|
1666
|
+
const [rects, setRects] = (0, import_react.useState)(defaultValue$2);
|
|
1667
|
+
function measureRects() {
|
|
1668
|
+
setRects(() => {
|
|
1669
|
+
if (!elements.length) return defaultValue$2;
|
|
1670
|
+
return elements.map((element) => isDocumentScrollingElement(element) ? windowRect : new Rect(measure(element), element));
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
const resizeObserver = useResizeObserver({ callback: measureRects });
|
|
1674
|
+
useIsomorphicLayoutEffect(() => {
|
|
1675
|
+
resizeObserver?.disconnect();
|
|
1676
|
+
measureRects();
|
|
1677
|
+
elements.forEach((element) => resizeObserver == null ? void 0 : resizeObserver.observe(element));
|
|
1678
|
+
}, [elements]);
|
|
1679
|
+
return rects;
|
|
1680
|
+
}
|
|
1681
|
+
function getMeasurableNode(node) {
|
|
1682
|
+
if (!node) return null;
|
|
1683
|
+
if (node.children.length > 1) return node;
|
|
1684
|
+
const firstChild = node.children[0];
|
|
1685
|
+
return isHTMLElement(firstChild) ? firstChild : node;
|
|
1686
|
+
}
|
|
1687
|
+
function useDragOverlayMeasuring(_ref) {
|
|
1688
|
+
let { measure } = _ref;
|
|
1689
|
+
const [rect, setRect] = (0, import_react.useState)(null);
|
|
1690
|
+
const resizeObserver = useResizeObserver({ callback: (0, import_react.useCallback)((entries) => {
|
|
1691
|
+
for (const { target } of entries) if (isHTMLElement(target)) {
|
|
1692
|
+
setRect((rect) => {
|
|
1693
|
+
const newRect = measure(target);
|
|
1694
|
+
return rect ? {
|
|
1695
|
+
...rect,
|
|
1696
|
+
width: newRect.width,
|
|
1697
|
+
height: newRect.height
|
|
1698
|
+
} : newRect;
|
|
1699
|
+
});
|
|
1700
|
+
break;
|
|
1701
|
+
}
|
|
1702
|
+
}, [measure]) });
|
|
1703
|
+
const [nodeRef, setRef] = useNodeRef((0, import_react.useCallback)((element) => {
|
|
1704
|
+
const node = getMeasurableNode(element);
|
|
1705
|
+
resizeObserver?.disconnect();
|
|
1706
|
+
if (node) resizeObserver?.observe(node);
|
|
1707
|
+
setRect(node ? measure(node) : null);
|
|
1708
|
+
}, [measure, resizeObserver]));
|
|
1709
|
+
return (0, import_react.useMemo)(() => ({
|
|
1710
|
+
nodeRef,
|
|
1711
|
+
rect,
|
|
1712
|
+
setRef
|
|
1713
|
+
}), [
|
|
1714
|
+
rect,
|
|
1715
|
+
nodeRef,
|
|
1716
|
+
setRef
|
|
1717
|
+
]);
|
|
1718
|
+
}
|
|
1719
|
+
var defaultSensors = [{
|
|
1720
|
+
sensor: PointerSensor,
|
|
1721
|
+
options: {}
|
|
1722
|
+
}, {
|
|
1723
|
+
sensor: KeyboardSensor,
|
|
1724
|
+
options: {}
|
|
1725
|
+
}];
|
|
1726
|
+
var defaultData = { current: {} };
|
|
1727
|
+
var defaultMeasuringConfiguration = {
|
|
1728
|
+
draggable: { measure: getTransformAgnosticClientRect },
|
|
1729
|
+
droppable: {
|
|
1730
|
+
measure: getTransformAgnosticClientRect,
|
|
1731
|
+
strategy: MeasuringStrategy.WhileDragging,
|
|
1732
|
+
frequency: MeasuringFrequency.Optimized
|
|
1733
|
+
},
|
|
1734
|
+
dragOverlay: { measure: getClientRect }
|
|
1735
|
+
};
|
|
1736
|
+
var DroppableContainersMap = class extends Map {
|
|
1737
|
+
get(id) {
|
|
1738
|
+
var _super$get;
|
|
1739
|
+
return id != null ? (_super$get = super.get(id)) != null ? _super$get : void 0 : void 0;
|
|
1740
|
+
}
|
|
1741
|
+
toArray() {
|
|
1742
|
+
return Array.from(this.values());
|
|
1743
|
+
}
|
|
1744
|
+
getEnabled() {
|
|
1745
|
+
return this.toArray().filter((_ref) => {
|
|
1746
|
+
let { disabled } = _ref;
|
|
1747
|
+
return !disabled;
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
getNodeFor(id) {
|
|
1751
|
+
var _this$get$node$curren, _this$get;
|
|
1752
|
+
return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : void 0;
|
|
1753
|
+
}
|
|
1754
|
+
};
|
|
1755
|
+
var defaultPublicContext = {
|
|
1756
|
+
activatorEvent: null,
|
|
1757
|
+
active: null,
|
|
1758
|
+
activeNode: null,
|
|
1759
|
+
activeNodeRect: null,
|
|
1760
|
+
collisions: null,
|
|
1761
|
+
containerNodeRect: null,
|
|
1762
|
+
draggableNodes: /*#__PURE__*/ new Map(),
|
|
1763
|
+
droppableRects: /*#__PURE__*/ new Map(),
|
|
1764
|
+
droppableContainers: /*#__PURE__*/ new DroppableContainersMap(),
|
|
1765
|
+
over: null,
|
|
1766
|
+
dragOverlay: {
|
|
1767
|
+
nodeRef: { current: null },
|
|
1768
|
+
rect: null,
|
|
1769
|
+
setRef: noop
|
|
1770
|
+
},
|
|
1771
|
+
scrollableAncestors: [],
|
|
1772
|
+
scrollableAncestorRects: [],
|
|
1773
|
+
measuringConfiguration: defaultMeasuringConfiguration,
|
|
1774
|
+
measureDroppableContainers: noop,
|
|
1775
|
+
windowRect: null,
|
|
1776
|
+
measuringScheduled: false
|
|
1777
|
+
};
|
|
1778
|
+
var defaultInternalContext = {
|
|
1779
|
+
activatorEvent: null,
|
|
1780
|
+
activators: [],
|
|
1781
|
+
active: null,
|
|
1782
|
+
activeNodeRect: null,
|
|
1783
|
+
ariaDescribedById: { draggable: "" },
|
|
1784
|
+
dispatch: noop,
|
|
1785
|
+
draggableNodes: /*#__PURE__*/ new Map(),
|
|
1786
|
+
over: null,
|
|
1787
|
+
measureDroppableContainers: noop
|
|
1788
|
+
};
|
|
1789
|
+
var InternalContext = /*#__PURE__*/ (0, import_react.createContext)(defaultInternalContext);
|
|
1790
|
+
var PublicContext = /*#__PURE__*/ (0, import_react.createContext)(defaultPublicContext);
|
|
1791
|
+
function getInitialState() {
|
|
1792
|
+
return {
|
|
1793
|
+
draggable: {
|
|
1794
|
+
active: null,
|
|
1795
|
+
initialCoordinates: {
|
|
1796
|
+
x: 0,
|
|
1797
|
+
y: 0
|
|
1798
|
+
},
|
|
1799
|
+
nodes: /* @__PURE__ */ new Map(),
|
|
1800
|
+
translate: {
|
|
1801
|
+
x: 0,
|
|
1802
|
+
y: 0
|
|
1803
|
+
}
|
|
1804
|
+
},
|
|
1805
|
+
droppable: { containers: new DroppableContainersMap() }
|
|
1806
|
+
};
|
|
1807
|
+
}
|
|
1808
|
+
function reducer(state, action) {
|
|
1809
|
+
switch (action.type) {
|
|
1810
|
+
case Action.DragStart: return {
|
|
1811
|
+
...state,
|
|
1812
|
+
draggable: {
|
|
1813
|
+
...state.draggable,
|
|
1814
|
+
initialCoordinates: action.initialCoordinates,
|
|
1815
|
+
active: action.active
|
|
1816
|
+
}
|
|
1817
|
+
};
|
|
1818
|
+
case Action.DragMove:
|
|
1819
|
+
if (state.draggable.active == null) return state;
|
|
1820
|
+
return {
|
|
1821
|
+
...state,
|
|
1822
|
+
draggable: {
|
|
1823
|
+
...state.draggable,
|
|
1824
|
+
translate: {
|
|
1825
|
+
x: action.coordinates.x - state.draggable.initialCoordinates.x,
|
|
1826
|
+
y: action.coordinates.y - state.draggable.initialCoordinates.y
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
case Action.DragEnd:
|
|
1831
|
+
case Action.DragCancel: return {
|
|
1832
|
+
...state,
|
|
1833
|
+
draggable: {
|
|
1834
|
+
...state.draggable,
|
|
1835
|
+
active: null,
|
|
1836
|
+
initialCoordinates: {
|
|
1837
|
+
x: 0,
|
|
1838
|
+
y: 0
|
|
1839
|
+
},
|
|
1840
|
+
translate: {
|
|
1841
|
+
x: 0,
|
|
1842
|
+
y: 0
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
};
|
|
1846
|
+
case Action.RegisterDroppable: {
|
|
1847
|
+
const { element } = action;
|
|
1848
|
+
const { id } = element;
|
|
1849
|
+
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
1850
|
+
containers.set(id, element);
|
|
1851
|
+
return {
|
|
1852
|
+
...state,
|
|
1853
|
+
droppable: {
|
|
1854
|
+
...state.droppable,
|
|
1855
|
+
containers
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1859
|
+
case Action.SetDroppableDisabled: {
|
|
1860
|
+
const { id, key, disabled } = action;
|
|
1861
|
+
const element = state.droppable.containers.get(id);
|
|
1862
|
+
if (!element || key !== element.key) return state;
|
|
1863
|
+
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
1864
|
+
containers.set(id, {
|
|
1865
|
+
...element,
|
|
1866
|
+
disabled
|
|
1867
|
+
});
|
|
1868
|
+
return {
|
|
1869
|
+
...state,
|
|
1870
|
+
droppable: {
|
|
1871
|
+
...state.droppable,
|
|
1872
|
+
containers
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
}
|
|
1876
|
+
case Action.UnregisterDroppable: {
|
|
1877
|
+
const { id, key } = action;
|
|
1878
|
+
const element = state.droppable.containers.get(id);
|
|
1879
|
+
if (!element || key !== element.key) return state;
|
|
1880
|
+
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
1881
|
+
containers.delete(id);
|
|
1882
|
+
return {
|
|
1883
|
+
...state,
|
|
1884
|
+
droppable: {
|
|
1885
|
+
...state.droppable,
|
|
1886
|
+
containers
|
|
1887
|
+
}
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1890
|
+
default: return state;
|
|
1517
1891
|
}
|
|
1518
|
-
}
|
|
1519
|
-
function
|
|
1520
|
-
|
|
1892
|
+
}
|
|
1893
|
+
function RestoreFocus(_ref) {
|
|
1894
|
+
let { disabled } = _ref;
|
|
1895
|
+
const { active, activatorEvent, draggableNodes } = (0, import_react.useContext)(InternalContext);
|
|
1896
|
+
const previousActivatorEvent = usePrevious(activatorEvent);
|
|
1897
|
+
const previousActiveId = usePrevious(active == null ? void 0 : active.id);
|
|
1898
|
+
(0, import_react.useEffect)(() => {
|
|
1899
|
+
if (disabled) return;
|
|
1900
|
+
if (!activatorEvent && previousActivatorEvent && previousActiveId != null) {
|
|
1901
|
+
if (!isKeyboardEvent(previousActivatorEvent)) return;
|
|
1902
|
+
if (document.activeElement === previousActivatorEvent.target) return;
|
|
1903
|
+
const draggableNode = draggableNodes.get(previousActiveId);
|
|
1904
|
+
if (!draggableNode) return;
|
|
1905
|
+
const { activatorNode, node } = draggableNode;
|
|
1906
|
+
if (!activatorNode.current && !node.current) return;
|
|
1907
|
+
requestAnimationFrame(() => {
|
|
1908
|
+
for (const element of [activatorNode.current, node.current]) {
|
|
1909
|
+
if (!element) continue;
|
|
1910
|
+
const focusableNode = findFirstFocusableNode(element);
|
|
1911
|
+
if (focusableNode) {
|
|
1912
|
+
focusableNode.focus();
|
|
1913
|
+
break;
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
}, [
|
|
1919
|
+
activatorEvent,
|
|
1920
|
+
disabled,
|
|
1921
|
+
draggableNodes,
|
|
1922
|
+
previousActiveId,
|
|
1923
|
+
previousActivatorEvent
|
|
1924
|
+
]);
|
|
1925
|
+
return null;
|
|
1926
|
+
}
|
|
1927
|
+
function applyModifiers(modifiers, _ref) {
|
|
1928
|
+
let { transform, ...args } = _ref;
|
|
1929
|
+
return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => {
|
|
1521
1930
|
return modifier({
|
|
1522
1931
|
transform: accumulator,
|
|
1523
1932
|
...args
|
|
1524
1933
|
});
|
|
1525
1934
|
}, transform) : transform;
|
|
1526
1935
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1936
|
+
function useMeasuringConfiguration(config) {
|
|
1937
|
+
return (0, import_react.useMemo)(() => ({
|
|
1938
|
+
draggable: {
|
|
1939
|
+
...defaultMeasuringConfiguration.draggable,
|
|
1940
|
+
...config == null ? void 0 : config.draggable
|
|
1941
|
+
},
|
|
1942
|
+
droppable: {
|
|
1943
|
+
...defaultMeasuringConfiguration.droppable,
|
|
1944
|
+
...config == null ? void 0 : config.droppable
|
|
1945
|
+
},
|
|
1946
|
+
dragOverlay: {
|
|
1947
|
+
...defaultMeasuringConfiguration.dragOverlay,
|
|
1948
|
+
...config == null ? void 0 : config.dragOverlay
|
|
1949
|
+
}
|
|
1950
|
+
}), [
|
|
1951
|
+
config == null ? void 0 : config.draggable,
|
|
1952
|
+
config == null ? void 0 : config.droppable,
|
|
1953
|
+
config == null ? void 0 : config.dragOverlay
|
|
1954
|
+
]);
|
|
1955
|
+
}
|
|
1956
|
+
function useLayoutShiftScrollCompensation(_ref) {
|
|
1957
|
+
let { activeNode, measure, initialRect, config = true } = _ref;
|
|
1958
|
+
const initialized = (0, import_react.useRef)(false);
|
|
1959
|
+
const { x, y } = typeof config === "boolean" ? {
|
|
1960
|
+
x: config,
|
|
1961
|
+
y: config
|
|
1962
|
+
} : config;
|
|
1963
|
+
useIsomorphicLayoutEffect(() => {
|
|
1964
|
+
if (!x && !y || !activeNode) {
|
|
1965
|
+
initialized.current = false;
|
|
1966
|
+
return;
|
|
1967
|
+
}
|
|
1968
|
+
if (initialized.current || !initialRect) return;
|
|
1969
|
+
const node = activeNode == null ? void 0 : activeNode.node.current;
|
|
1970
|
+
if (!node || node.isConnected === false) return;
|
|
1971
|
+
const rectDelta = getRectDelta(measure(node), initialRect);
|
|
1972
|
+
if (!x) rectDelta.x = 0;
|
|
1973
|
+
if (!y) rectDelta.y = 0;
|
|
1974
|
+
initialized.current = true;
|
|
1975
|
+
if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) {
|
|
1976
|
+
const firstScrollableAncestor = getFirstScrollableAncestor(node);
|
|
1977
|
+
if (firstScrollableAncestor) firstScrollableAncestor.scrollBy({
|
|
1978
|
+
top: rectDelta.y,
|
|
1979
|
+
left: rectDelta.x
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
}, [
|
|
1983
|
+
activeNode,
|
|
1984
|
+
x,
|
|
1985
|
+
y,
|
|
1986
|
+
initialRect,
|
|
1987
|
+
measure
|
|
1988
|
+
]);
|
|
1989
|
+
}
|
|
1990
|
+
var ActiveDraggableContext = /*#__PURE__*/ (0, import_react.createContext)({
|
|
1536
1991
|
...defaultCoordinates,
|
|
1537
1992
|
scaleX: 1,
|
|
1538
1993
|
scaleY: 1
|
|
1539
1994
|
});
|
|
1540
|
-
var
|
|
1541
|
-
|
|
1995
|
+
var Status;
|
|
1996
|
+
(function(Status) {
|
|
1997
|
+
Status[Status["Uninitialized"] = 0] = "Uninitialized";
|
|
1998
|
+
Status[Status["Initializing"] = 1] = "Initializing";
|
|
1999
|
+
Status[Status["Initialized"] = 2] = "Initialized";
|
|
2000
|
+
})(Status || (Status = {}));
|
|
2001
|
+
var DndContext = /*#__PURE__*/ (0, import_react.memo)(function DndContext(_ref) {
|
|
2002
|
+
var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
|
|
2003
|
+
let { id, accessibility, autoScroll = true, children, sensors = defaultSensors, collisionDetection = rectIntersection, measuring, modifiers, ...props } = _ref;
|
|
1542
2004
|
const [state, dispatch] = (0, import_react.useReducer)(reducer, void 0, getInitialState);
|
|
1543
|
-
const [
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
}));
|
|
1547
|
-
const [isDragging, setIsDragging] = (0, import_react.useState)(false);
|
|
2005
|
+
const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
|
|
2006
|
+
const [status, setStatus] = (0, import_react.useState)(Status.Uninitialized);
|
|
2007
|
+
const isInitialized = status === Status.Initialized;
|
|
1548
2008
|
const { draggable: { active: activeId, nodes: draggableNodes, translate }, droppable: { containers: droppableContainers } } = state;
|
|
1549
|
-
const node = activeId ? draggableNodes
|
|
2009
|
+
const node = activeId != null ? draggableNodes.get(activeId) : null;
|
|
1550
2010
|
const activeRects = (0, import_react.useRef)({
|
|
1551
2011
|
initial: null,
|
|
1552
2012
|
translated: null
|
|
@@ -1562,46 +2022,51 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1562
2022
|
const activeRef = (0, import_react.useRef)(null);
|
|
1563
2023
|
const [activeSensor, setActiveSensor] = (0, import_react.useState)(null);
|
|
1564
2024
|
const [activatorEvent, setActivatorEvent] = (0, import_react.useState)(null);
|
|
1565
|
-
const latestProps = (
|
|
1566
|
-
const draggableDescribedById = useUniqueId(
|
|
1567
|
-
const enabledDroppableContainers = (0, import_react.useMemo)(() =>
|
|
1568
|
-
|
|
1569
|
-
},
|
|
1570
|
-
|
|
1571
|
-
dragging: isDragging,
|
|
2025
|
+
const latestProps = useLatestValue(props, Object.values(props));
|
|
2026
|
+
const draggableDescribedById = useUniqueId("DndDescribedBy", id);
|
|
2027
|
+
const enabledDroppableContainers = (0, import_react.useMemo)(() => droppableContainers.getEnabled(), [droppableContainers]);
|
|
2028
|
+
const measuringConfiguration = useMeasuringConfiguration(measuring);
|
|
2029
|
+
const { droppableRects, measureDroppableContainers, measuringScheduled } = useDroppableMeasuring(enabledDroppableContainers, {
|
|
2030
|
+
dragging: isInitialized,
|
|
1572
2031
|
dependencies: [translate.x, translate.y],
|
|
1573
|
-
config:
|
|
2032
|
+
config: measuringConfiguration.droppable
|
|
1574
2033
|
});
|
|
1575
2034
|
const activeNode = useCachedNode(draggableNodes, activeId);
|
|
1576
|
-
const activationCoordinates = activatorEvent ? getEventCoordinates(activatorEvent) : null;
|
|
1577
|
-
const
|
|
1578
|
-
const
|
|
1579
|
-
|
|
1580
|
-
|
|
2035
|
+
const activationCoordinates = (0, import_react.useMemo)(() => activatorEvent ? getEventCoordinates(activatorEvent) : null, [activatorEvent]);
|
|
2036
|
+
const autoScrollOptions = getAutoScrollerOptions();
|
|
2037
|
+
const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
|
|
2038
|
+
useLayoutShiftScrollCompensation({
|
|
2039
|
+
activeNode: activeId != null ? draggableNodes.get(activeId) : null,
|
|
2040
|
+
config: autoScrollOptions.layoutShiftCompensation,
|
|
2041
|
+
initialRect: initialActiveNodeRect,
|
|
2042
|
+
measure: measuringConfiguration.draggable.measure
|
|
2043
|
+
});
|
|
2044
|
+
const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect);
|
|
2045
|
+
const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null);
|
|
1581
2046
|
const sensorContext = (0, import_react.useRef)({
|
|
2047
|
+
activatorEvent: null,
|
|
1582
2048
|
active: null,
|
|
1583
2049
|
activeNode,
|
|
1584
2050
|
collisionRect: null,
|
|
2051
|
+
collisions: null,
|
|
1585
2052
|
droppableRects,
|
|
1586
2053
|
draggableNodes,
|
|
2054
|
+
draggingNode: null,
|
|
1587
2055
|
draggingNodeRect: null,
|
|
1588
2056
|
droppableContainers,
|
|
1589
2057
|
over: null,
|
|
1590
2058
|
scrollableAncestors: [],
|
|
1591
|
-
scrollAdjustedTranslate: null
|
|
1592
|
-
translatedRect: null
|
|
2059
|
+
scrollAdjustedTranslate: null
|
|
1593
2060
|
});
|
|
1594
2061
|
const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
|
|
1595
|
-
const
|
|
1596
|
-
const
|
|
1597
|
-
const
|
|
1598
|
-
const
|
|
1599
|
-
const
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
const draggingNodeRect = (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect;
|
|
1604
|
-
const nodeRectDelta = draggingNodeRect === activeNodeRect ? getRectDelta(activeNodeRect, initialActiveNodeRect) : defaultCoordinates;
|
|
2062
|
+
const dragOverlay = useDragOverlayMeasuring({ measure: measuringConfiguration.dragOverlay.measure });
|
|
2063
|
+
const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode;
|
|
2064
|
+
const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null;
|
|
2065
|
+
const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect);
|
|
2066
|
+
const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect);
|
|
2067
|
+
const windowRect = useWindowRect(draggingNode ? getWindow(draggingNode) : null);
|
|
2068
|
+
const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null);
|
|
2069
|
+
const scrollableAncestorRects = useRects(scrollableAncestors);
|
|
1605
2070
|
const modifiedTranslate = applyModifiers(modifiers, {
|
|
1606
2071
|
transform: {
|
|
1607
2072
|
x: translate.x - nodeRectDelta.x,
|
|
@@ -1611,7 +2076,7 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1611
2076
|
},
|
|
1612
2077
|
activatorEvent,
|
|
1613
2078
|
active,
|
|
1614
|
-
activeNodeRect
|
|
2079
|
+
activeNodeRect,
|
|
1615
2080
|
containerNodeRect,
|
|
1616
2081
|
draggingNodeRect,
|
|
1617
2082
|
over: sensorContext.current.over,
|
|
@@ -1621,50 +2086,88 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1621
2086
|
windowRect
|
|
1622
2087
|
});
|
|
1623
2088
|
const pointerCoordinates = activationCoordinates ? add(activationCoordinates, translate) : null;
|
|
1624
|
-
const
|
|
2089
|
+
const scrollOffsets = useScrollOffsets(scrollableAncestors);
|
|
2090
|
+
const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets);
|
|
2091
|
+
const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
|
|
1625
2092
|
const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);
|
|
1626
|
-
const
|
|
1627
|
-
const
|
|
1628
|
-
const overId = active && collisionRect ? collisionDetection({
|
|
2093
|
+
const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
|
|
2094
|
+
const collisions = active && collisionRect ? collisionDetection({
|
|
1629
2095
|
active,
|
|
1630
2096
|
collisionRect,
|
|
1631
|
-
|
|
2097
|
+
droppableRects,
|
|
2098
|
+
droppableContainers: enabledDroppableContainers,
|
|
2099
|
+
pointerCoordinates
|
|
1632
2100
|
}) : null;
|
|
2101
|
+
const overId = getFirstCollision(collisions, "id");
|
|
1633
2102
|
const [over, setOver] = (0, import_react.useState)(null);
|
|
1634
|
-
const transform = adjustScale(modifiedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
|
|
1635
|
-
const
|
|
1636
|
-
|
|
1637
|
-
|
|
2103
|
+
const transform = adjustScale(usesDragOverlay ? modifiedTranslate : add(modifiedTranslate, activeNodeScrollDelta), (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
|
|
2104
|
+
const activeSensorRef = (0, import_react.useRef)(null);
|
|
2105
|
+
const instantiateSensor = (0, import_react.useCallback)((event, _ref2) => {
|
|
2106
|
+
let { sensor: Sensor, options } = _ref2;
|
|
2107
|
+
if (activeRef.current == null) return;
|
|
2108
|
+
const activeNode = draggableNodes.get(activeRef.current);
|
|
1638
2109
|
if (!activeNode) return;
|
|
2110
|
+
const activatorEvent = event.nativeEvent;
|
|
1639
2111
|
const sensorInstance = new Sensor({
|
|
1640
2112
|
active: activeRef.current,
|
|
1641
2113
|
activeNode,
|
|
1642
|
-
event:
|
|
2114
|
+
event: activatorEvent,
|
|
1643
2115
|
options,
|
|
1644
2116
|
context: sensorContext,
|
|
2117
|
+
onAbort(id) {
|
|
2118
|
+
if (!draggableNodes.get(id)) return;
|
|
2119
|
+
const { onDragAbort } = latestProps.current;
|
|
2120
|
+
const event = { id };
|
|
2121
|
+
onDragAbort?.(event);
|
|
2122
|
+
dispatchMonitorEvent({
|
|
2123
|
+
type: "onDragAbort",
|
|
2124
|
+
event
|
|
2125
|
+
});
|
|
2126
|
+
},
|
|
2127
|
+
onPending(id, constraint, initialCoordinates, offset) {
|
|
2128
|
+
if (!draggableNodes.get(id)) return;
|
|
2129
|
+
const { onDragPending } = latestProps.current;
|
|
2130
|
+
const event = {
|
|
2131
|
+
id,
|
|
2132
|
+
constraint,
|
|
2133
|
+
initialCoordinates,
|
|
2134
|
+
offset
|
|
2135
|
+
};
|
|
2136
|
+
onDragPending?.(event);
|
|
2137
|
+
dispatchMonitorEvent({
|
|
2138
|
+
type: "onDragPending",
|
|
2139
|
+
event
|
|
2140
|
+
});
|
|
2141
|
+
},
|
|
1645
2142
|
onStart(initialCoordinates) {
|
|
1646
2143
|
const id = activeRef.current;
|
|
1647
|
-
if (
|
|
1648
|
-
const
|
|
1649
|
-
if (!
|
|
2144
|
+
if (id == null) return;
|
|
2145
|
+
const draggableNode = draggableNodes.get(id);
|
|
2146
|
+
if (!draggableNode) return;
|
|
1650
2147
|
const { onDragStart } = latestProps.current;
|
|
1651
|
-
const event = {
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
2148
|
+
const event = {
|
|
2149
|
+
activatorEvent,
|
|
2150
|
+
active: {
|
|
2151
|
+
id,
|
|
2152
|
+
data: draggableNode.data,
|
|
2153
|
+
rect: activeRects
|
|
2154
|
+
}
|
|
2155
|
+
};
|
|
1656
2156
|
(0, import_react_dom.unstable_batchedUpdates)(() => {
|
|
2157
|
+
onDragStart?.(event);
|
|
2158
|
+
setStatus(Status.Initializing);
|
|
1657
2159
|
dispatch({
|
|
1658
2160
|
type: Action.DragStart,
|
|
1659
2161
|
initialCoordinates,
|
|
1660
2162
|
active: id
|
|
1661
2163
|
});
|
|
1662
|
-
|
|
1663
|
-
type:
|
|
2164
|
+
dispatchMonitorEvent({
|
|
2165
|
+
type: "onDragStart",
|
|
1664
2166
|
event
|
|
1665
2167
|
});
|
|
2168
|
+
setActiveSensor(activeSensorRef.current);
|
|
2169
|
+
setActivatorEvent(activatorEvent);
|
|
1666
2170
|
});
|
|
1667
|
-
onDragStart?.(event);
|
|
1668
2171
|
},
|
|
1669
2172
|
onMove(coordinates) {
|
|
1670
2173
|
dispatch({
|
|
@@ -1675,18 +2178,17 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1675
2178
|
onEnd: createHandler(Action.DragEnd),
|
|
1676
2179
|
onCancel: createHandler(Action.DragCancel)
|
|
1677
2180
|
});
|
|
1678
|
-
|
|
1679
|
-
setActiveSensor(sensorInstance);
|
|
1680
|
-
setActivatorEvent(event.nativeEvent);
|
|
1681
|
-
});
|
|
2181
|
+
activeSensorRef.current = sensorInstance;
|
|
1682
2182
|
function createHandler(type) {
|
|
1683
2183
|
return async function handler() {
|
|
1684
|
-
const { active, over, scrollAdjustedTranslate } = sensorContext.current;
|
|
2184
|
+
const { active, collisions, over, scrollAdjustedTranslate } = sensorContext.current;
|
|
1685
2185
|
let event = null;
|
|
1686
2186
|
if (active && scrollAdjustedTranslate) {
|
|
1687
2187
|
const { cancelDrop } = latestProps.current;
|
|
1688
2188
|
event = {
|
|
2189
|
+
activatorEvent,
|
|
1689
2190
|
active,
|
|
2191
|
+
collisions,
|
|
1690
2192
|
delta: scrollAdjustedTranslate,
|
|
1691
2193
|
over
|
|
1692
2194
|
};
|
|
@@ -1697,65 +2199,66 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1697
2199
|
activeRef.current = null;
|
|
1698
2200
|
(0, import_react_dom.unstable_batchedUpdates)(() => {
|
|
1699
2201
|
dispatch({ type });
|
|
2202
|
+
setStatus(Status.Uninitialized);
|
|
1700
2203
|
setOver(null);
|
|
1701
|
-
setIsDragging(false);
|
|
1702
2204
|
setActiveSensor(null);
|
|
1703
2205
|
setActivatorEvent(null);
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
2206
|
+
activeSensorRef.current = null;
|
|
2207
|
+
const eventName = type === Action.DragEnd ? "onDragEnd" : "onDragCancel";
|
|
2208
|
+
if (event) {
|
|
2209
|
+
const handler = latestProps.current[eventName];
|
|
2210
|
+
handler?.(event);
|
|
2211
|
+
dispatchMonitorEvent({
|
|
2212
|
+
type: eventName,
|
|
2213
|
+
event
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
1708
2216
|
});
|
|
1709
|
-
if (event) {
|
|
1710
|
-
const { onDragCancel, onDragEnd } = latestProps.current;
|
|
1711
|
-
(type === Action.DragEnd ? onDragEnd : onDragCancel)?.(event);
|
|
1712
|
-
}
|
|
1713
2217
|
};
|
|
1714
2218
|
}
|
|
1715
|
-
}, [
|
|
2219
|
+
}, [draggableNodes]);
|
|
1716
2220
|
const activators = useCombineActivators(sensors, (0, import_react.useCallback)((handler, sensor) => {
|
|
1717
2221
|
return (event, active) => {
|
|
1718
2222
|
const nativeEvent = event.nativeEvent;
|
|
1719
|
-
|
|
1720
|
-
if (
|
|
2223
|
+
const activeDraggableNode = draggableNodes.get(active);
|
|
2224
|
+
if (activeRef.current !== null || !activeDraggableNode || nativeEvent.dndKit || nativeEvent.defaultPrevented) return;
|
|
2225
|
+
const activationContext = { active: activeDraggableNode };
|
|
2226
|
+
if (handler(event, sensor.options, activationContext) === true) {
|
|
1721
2227
|
nativeEvent.dndKit = { capturedBy: sensor.sensor };
|
|
1722
2228
|
activeRef.current = active;
|
|
1723
2229
|
instantiateSensor(event, sensor);
|
|
1724
2230
|
}
|
|
1725
2231
|
};
|
|
1726
|
-
}, [instantiateSensor]));
|
|
2232
|
+
}, [draggableNodes, instantiateSensor]));
|
|
1727
2233
|
useSensorSetup(sensors);
|
|
1728
2234
|
useIsomorphicLayoutEffect(() => {
|
|
1729
|
-
|
|
1730
|
-
},
|
|
1731
|
-
(0, import_react.useEffect)(() => {
|
|
1732
|
-
if (activeId != null) setIsDragging(true);
|
|
1733
|
-
}, [activeId]);
|
|
1734
|
-
(0, import_react.useEffect)(() => {
|
|
1735
|
-
if (!active) initialActiveNodeRectRef.current = null;
|
|
1736
|
-
if (active && activeNodeRect && !initialActiveNodeRectRef.current) initialActiveNodeRectRef.current = activeNodeRect;
|
|
1737
|
-
}, [activeNodeRect, active]);
|
|
2235
|
+
if (activeNodeRect && status === Status.Initializing) setStatus(Status.Initialized);
|
|
2236
|
+
}, [activeNodeRect, status]);
|
|
1738
2237
|
(0, import_react.useEffect)(() => {
|
|
1739
2238
|
const { onDragMove } = latestProps.current;
|
|
1740
|
-
const { active, over } = sensorContext.current;
|
|
1741
|
-
if (!active) return;
|
|
2239
|
+
const { active, activatorEvent, collisions, over } = sensorContext.current;
|
|
2240
|
+
if (!active || !activatorEvent) return;
|
|
1742
2241
|
const event = {
|
|
1743
2242
|
active,
|
|
2243
|
+
activatorEvent,
|
|
2244
|
+
collisions,
|
|
1744
2245
|
delta: {
|
|
1745
2246
|
x: scrollAdjustedTranslate.x,
|
|
1746
2247
|
y: scrollAdjustedTranslate.y
|
|
1747
2248
|
},
|
|
1748
2249
|
over
|
|
1749
2250
|
};
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
2251
|
+
(0, import_react_dom.unstable_batchedUpdates)(() => {
|
|
2252
|
+
onDragMove?.(event);
|
|
2253
|
+
dispatchMonitorEvent({
|
|
2254
|
+
type: "onDragMove",
|
|
2255
|
+
event
|
|
2256
|
+
});
|
|
1753
2257
|
});
|
|
1754
|
-
onDragMove?.(event);
|
|
1755
2258
|
}, [scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]);
|
|
1756
2259
|
(0, import_react.useEffect)(() => {
|
|
1757
|
-
const { active, droppableContainers, scrollAdjustedTranslate } = sensorContext.current;
|
|
1758
|
-
if (!active ||
|
|
2260
|
+
const { active, activatorEvent, collisions, droppableContainers, scrollAdjustedTranslate } = sensorContext.current;
|
|
2261
|
+
if (!active || activeRef.current == null || !activatorEvent || !scrollAdjustedTranslate) return;
|
|
1759
2262
|
const { onDragOver } = latestProps.current;
|
|
1760
2263
|
const overContainer = droppableContainers.get(overId);
|
|
1761
2264
|
const over = overContainer && overContainer.rect.current ? {
|
|
@@ -1766,6 +2269,8 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1766
2269
|
} : null;
|
|
1767
2270
|
const event = {
|
|
1768
2271
|
active,
|
|
2272
|
+
activatorEvent,
|
|
2273
|
+
collisions,
|
|
1769
2274
|
delta: {
|
|
1770
2275
|
x: scrollAdjustedTranslate.x,
|
|
1771
2276
|
y: scrollAdjustedTranslate.y
|
|
@@ -1774,103 +2279,125 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1774
2279
|
};
|
|
1775
2280
|
(0, import_react_dom.unstable_batchedUpdates)(() => {
|
|
1776
2281
|
setOver(over);
|
|
1777
|
-
|
|
1778
|
-
|
|
2282
|
+
onDragOver?.(event);
|
|
2283
|
+
dispatchMonitorEvent({
|
|
2284
|
+
type: "onDragOver",
|
|
1779
2285
|
event
|
|
1780
2286
|
});
|
|
1781
|
-
onDragOver?.(event);
|
|
1782
2287
|
});
|
|
1783
2288
|
}, [overId]);
|
|
1784
2289
|
useIsomorphicLayoutEffect(() => {
|
|
1785
2290
|
sensorContext.current = {
|
|
2291
|
+
activatorEvent,
|
|
1786
2292
|
active,
|
|
1787
2293
|
activeNode,
|
|
1788
2294
|
collisionRect,
|
|
2295
|
+
collisions,
|
|
1789
2296
|
droppableRects,
|
|
1790
2297
|
draggableNodes,
|
|
2298
|
+
draggingNode,
|
|
1791
2299
|
draggingNodeRect,
|
|
1792
2300
|
droppableContainers,
|
|
1793
2301
|
over,
|
|
1794
2302
|
scrollableAncestors,
|
|
1795
|
-
scrollAdjustedTranslate
|
|
1796
|
-
translatedRect
|
|
2303
|
+
scrollAdjustedTranslate
|
|
1797
2304
|
};
|
|
1798
2305
|
activeRects.current = {
|
|
1799
2306
|
initial: draggingNodeRect,
|
|
1800
|
-
translated:
|
|
2307
|
+
translated: collisionRect
|
|
1801
2308
|
};
|
|
1802
2309
|
}, [
|
|
1803
2310
|
active,
|
|
1804
2311
|
activeNode,
|
|
2312
|
+
collisions,
|
|
1805
2313
|
collisionRect,
|
|
1806
2314
|
draggableNodes,
|
|
2315
|
+
draggingNode,
|
|
1807
2316
|
draggingNodeRect,
|
|
1808
2317
|
droppableRects,
|
|
1809
2318
|
droppableContainers,
|
|
1810
2319
|
over,
|
|
1811
2320
|
scrollableAncestors,
|
|
1812
|
-
scrollAdjustedTranslate
|
|
1813
|
-
translatedRect
|
|
2321
|
+
scrollAdjustedTranslate
|
|
1814
2322
|
]);
|
|
1815
2323
|
useAutoScroller({
|
|
1816
|
-
...
|
|
1817
|
-
|
|
2324
|
+
...autoScrollOptions,
|
|
2325
|
+
delta: translate,
|
|
2326
|
+
draggingRect: collisionRect,
|
|
1818
2327
|
pointerCoordinates,
|
|
1819
2328
|
scrollableAncestors,
|
|
1820
2329
|
scrollableAncestorRects
|
|
1821
2330
|
});
|
|
1822
|
-
const
|
|
2331
|
+
const publicContext = (0, import_react.useMemo)(() => {
|
|
1823
2332
|
return {
|
|
1824
2333
|
active,
|
|
1825
2334
|
activeNode,
|
|
1826
2335
|
activeNodeRect,
|
|
1827
|
-
activeNodeClientRect,
|
|
1828
2336
|
activatorEvent,
|
|
1829
|
-
|
|
1830
|
-
ariaDescribedById: { draggable: draggableDescribedById },
|
|
2337
|
+
collisions,
|
|
1831
2338
|
containerNodeRect,
|
|
1832
|
-
dispatch,
|
|
1833
2339
|
dragOverlay,
|
|
1834
2340
|
draggableNodes,
|
|
1835
2341
|
droppableContainers,
|
|
1836
2342
|
droppableRects,
|
|
1837
2343
|
over,
|
|
1838
|
-
|
|
2344
|
+
measureDroppableContainers,
|
|
1839
2345
|
scrollableAncestors,
|
|
1840
2346
|
scrollableAncestorRects,
|
|
1841
|
-
|
|
2347
|
+
measuringConfiguration,
|
|
2348
|
+
measuringScheduled,
|
|
1842
2349
|
windowRect
|
|
1843
2350
|
};
|
|
1844
2351
|
}, [
|
|
1845
2352
|
active,
|
|
1846
2353
|
activeNode,
|
|
1847
|
-
activeNodeClientRect,
|
|
1848
2354
|
activeNodeRect,
|
|
1849
2355
|
activatorEvent,
|
|
1850
|
-
|
|
2356
|
+
collisions,
|
|
1851
2357
|
containerNodeRect,
|
|
1852
2358
|
dragOverlay,
|
|
1853
|
-
dispatch,
|
|
1854
2359
|
draggableNodes,
|
|
1855
|
-
draggableDescribedById,
|
|
1856
2360
|
droppableContainers,
|
|
1857
2361
|
droppableRects,
|
|
1858
2362
|
over,
|
|
1859
|
-
|
|
2363
|
+
measureDroppableContainers,
|
|
1860
2364
|
scrollableAncestors,
|
|
1861
2365
|
scrollableAncestorRects,
|
|
1862
|
-
|
|
2366
|
+
measuringConfiguration,
|
|
2367
|
+
measuringScheduled,
|
|
1863
2368
|
windowRect
|
|
1864
2369
|
]);
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
2370
|
+
const internalContext = (0, import_react.useMemo)(() => {
|
|
2371
|
+
return {
|
|
2372
|
+
activatorEvent,
|
|
2373
|
+
activators,
|
|
2374
|
+
active,
|
|
2375
|
+
activeNodeRect,
|
|
2376
|
+
ariaDescribedById: { draggable: draggableDescribedById },
|
|
2377
|
+
dispatch,
|
|
2378
|
+
draggableNodes,
|
|
2379
|
+
over,
|
|
2380
|
+
measureDroppableContainers
|
|
2381
|
+
};
|
|
2382
|
+
}, [
|
|
2383
|
+
activatorEvent,
|
|
2384
|
+
activators,
|
|
2385
|
+
active,
|
|
2386
|
+
activeNodeRect,
|
|
2387
|
+
dispatch,
|
|
2388
|
+
draggableDescribedById,
|
|
2389
|
+
draggableNodes,
|
|
2390
|
+
over,
|
|
2391
|
+
measureDroppableContainers
|
|
2392
|
+
]);
|
|
2393
|
+
return import_react.createElement(DndMonitorContext.Provider, { value: registerMonitorListener }, import_react.createElement(InternalContext.Provider, { value: internalContext }, import_react.createElement(PublicContext.Provider, { value: publicContext }, import_react.createElement(ActiveDraggableContext.Provider, { value: transform }, children)), import_react.createElement(RestoreFocus, { disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false })), import_react.createElement(Accessibility, {
|
|
2394
|
+
...accessibility,
|
|
2395
|
+
hiddenTextDescribedById: draggableDescribedById
|
|
1869
2396
|
}));
|
|
1870
2397
|
function getAutoScrollerOptions() {
|
|
1871
2398
|
const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
|
|
1872
2399
|
const autoScrollGloballyDisabled = typeof autoScroll === "object" ? autoScroll.enabled === false : autoScroll === false;
|
|
1873
|
-
const enabled = !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
|
|
2400
|
+
const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
|
|
1874
2401
|
if (typeof autoScroll === "object") return {
|
|
1875
2402
|
...autoScroll,
|
|
1876
2403
|
enabled
|
|
@@ -1878,67 +2405,109 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1878
2405
|
return { enabled };
|
|
1879
2406
|
}
|
|
1880
2407
|
});
|
|
1881
|
-
var NullContext =
|
|
2408
|
+
var NullContext = /*#__PURE__*/ (0, import_react.createContext)(null);
|
|
1882
2409
|
var defaultRole = "button";
|
|
1883
|
-
var ID_PREFIX$
|
|
1884
|
-
function useDraggable(
|
|
1885
|
-
|
|
1886
|
-
const
|
|
2410
|
+
var ID_PREFIX$2 = "Draggable";
|
|
2411
|
+
function useDraggable(_ref) {
|
|
2412
|
+
let { id, data, disabled = false, attributes } = _ref;
|
|
2413
|
+
const key = useUniqueId(ID_PREFIX$2);
|
|
2414
|
+
const { activators, activatorEvent, active, activeNodeRect, ariaDescribedById, draggableNodes, over } = (0, import_react.useContext)(InternalContext);
|
|
1887
2415
|
const { role = defaultRole, roleDescription = "draggable", tabIndex = 0 } = attributes != null ? attributes : {};
|
|
1888
2416
|
const isDragging = (active == null ? void 0 : active.id) === id;
|
|
1889
2417
|
const transform = (0, import_react.useContext)(isDragging ? ActiveDraggableContext : NullContext);
|
|
1890
2418
|
const [node, setNodeRef] = useNodeRef();
|
|
2419
|
+
const [activatorNode, setActivatorNodeRef] = useNodeRef();
|
|
1891
2420
|
const listeners = useSyntheticListeners(activators, id);
|
|
1892
|
-
const dataRef =
|
|
1893
|
-
(
|
|
1894
|
-
draggableNodes
|
|
2421
|
+
const dataRef = useLatestValue(data);
|
|
2422
|
+
useIsomorphicLayoutEffect(() => {
|
|
2423
|
+
draggableNodes.set(id, {
|
|
1895
2424
|
id,
|
|
1896
2425
|
key,
|
|
1897
2426
|
node,
|
|
2427
|
+
activatorNode,
|
|
1898
2428
|
data: dataRef
|
|
1899
|
-
};
|
|
2429
|
+
});
|
|
1900
2430
|
return () => {
|
|
1901
|
-
const node = draggableNodes
|
|
1902
|
-
if (node && node.key === key) delete
|
|
2431
|
+
const node = draggableNodes.get(id);
|
|
2432
|
+
if (node && node.key === key) draggableNodes.delete(id);
|
|
1903
2433
|
};
|
|
1904
2434
|
}, [draggableNodes, id]);
|
|
1905
2435
|
return {
|
|
1906
2436
|
active,
|
|
1907
|
-
activeNodeRect,
|
|
1908
2437
|
activatorEvent,
|
|
2438
|
+
activeNodeRect,
|
|
1909
2439
|
attributes: (0, import_react.useMemo)(() => ({
|
|
1910
2440
|
role,
|
|
1911
2441
|
tabIndex,
|
|
2442
|
+
"aria-disabled": disabled,
|
|
1912
2443
|
"aria-pressed": isDragging && role === defaultRole ? true : void 0,
|
|
1913
2444
|
"aria-roledescription": roleDescription,
|
|
1914
2445
|
"aria-describedby": ariaDescribedById.draggable
|
|
1915
2446
|
}), [
|
|
2447
|
+
disabled,
|
|
1916
2448
|
role,
|
|
1917
2449
|
tabIndex,
|
|
1918
2450
|
isDragging,
|
|
1919
2451
|
roleDescription,
|
|
1920
2452
|
ariaDescribedById.draggable
|
|
1921
2453
|
]),
|
|
1922
|
-
droppableRects,
|
|
1923
2454
|
isDragging,
|
|
1924
2455
|
listeners: disabled ? void 0 : listeners,
|
|
1925
2456
|
node,
|
|
1926
2457
|
over,
|
|
1927
2458
|
setNodeRef,
|
|
2459
|
+
setActivatorNodeRef,
|
|
1928
2460
|
transform
|
|
1929
2461
|
};
|
|
1930
2462
|
}
|
|
1931
2463
|
function useDndContext() {
|
|
1932
|
-
return (0, import_react.useContext)(
|
|
2464
|
+
return (0, import_react.useContext)(PublicContext);
|
|
1933
2465
|
}
|
|
1934
|
-
var ID_PREFIX$1
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
2466
|
+
var ID_PREFIX$1 = "Droppable";
|
|
2467
|
+
var defaultResizeObserverConfig = { timeout: 25 };
|
|
2468
|
+
function useDroppable(_ref) {
|
|
2469
|
+
let { data, disabled = false, id, resizeObserverConfig } = _ref;
|
|
2470
|
+
const key = useUniqueId(ID_PREFIX$1);
|
|
2471
|
+
const { active, dispatch, over, measureDroppableContainers } = (0, import_react.useContext)(InternalContext);
|
|
2472
|
+
const previous = (0, import_react.useRef)({ disabled });
|
|
2473
|
+
const resizeObserverConnected = (0, import_react.useRef)(false);
|
|
1938
2474
|
const rect = (0, import_react.useRef)(null);
|
|
1939
|
-
const
|
|
1940
|
-
const
|
|
1941
|
-
|
|
2475
|
+
const callbackId = (0, import_react.useRef)(null);
|
|
2476
|
+
const { disabled: resizeObserverDisabled, updateMeasurementsFor, timeout: resizeObserverTimeout } = {
|
|
2477
|
+
...defaultResizeObserverConfig,
|
|
2478
|
+
...resizeObserverConfig
|
|
2479
|
+
};
|
|
2480
|
+
const ids = useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id);
|
|
2481
|
+
const resizeObserver = useResizeObserver({
|
|
2482
|
+
callback: (0, import_react.useCallback)(() => {
|
|
2483
|
+
if (!resizeObserverConnected.current) {
|
|
2484
|
+
resizeObserverConnected.current = true;
|
|
2485
|
+
return;
|
|
2486
|
+
}
|
|
2487
|
+
if (callbackId.current != null) clearTimeout(callbackId.current);
|
|
2488
|
+
callbackId.current = setTimeout(() => {
|
|
2489
|
+
measureDroppableContainers(Array.isArray(ids.current) ? ids.current : [ids.current]);
|
|
2490
|
+
callbackId.current = null;
|
|
2491
|
+
}, resizeObserverTimeout);
|
|
2492
|
+
}, [resizeObserverTimeout]),
|
|
2493
|
+
disabled: resizeObserverDisabled || !active
|
|
2494
|
+
});
|
|
2495
|
+
const [nodeRef, setNodeRef] = useNodeRef((0, import_react.useCallback)((newElement, previousElement) => {
|
|
2496
|
+
if (!resizeObserver) return;
|
|
2497
|
+
if (previousElement) {
|
|
2498
|
+
resizeObserver.unobserve(previousElement);
|
|
2499
|
+
resizeObserverConnected.current = false;
|
|
2500
|
+
}
|
|
2501
|
+
if (newElement) resizeObserver.observe(newElement);
|
|
2502
|
+
}, [resizeObserver]));
|
|
2503
|
+
const dataRef = useLatestValue(data);
|
|
2504
|
+
(0, import_react.useEffect)(() => {
|
|
2505
|
+
if (!resizeObserver || !nodeRef.current) return;
|
|
2506
|
+
resizeObserver.disconnect();
|
|
2507
|
+
resizeObserverConnected.current = false;
|
|
2508
|
+
resizeObserver.observe(nodeRef.current);
|
|
2509
|
+
}, [nodeRef, resizeObserver]);
|
|
2510
|
+
(0, import_react.useEffect)(() => {
|
|
1942
2511
|
dispatch({
|
|
1943
2512
|
type: Action.RegisterDroppable,
|
|
1944
2513
|
element: {
|
|
@@ -1957,13 +2526,21 @@ function useDroppable({ data, disabled = false, id }) {
|
|
|
1957
2526
|
});
|
|
1958
2527
|
}, [id]);
|
|
1959
2528
|
(0, import_react.useEffect)(() => {
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
2529
|
+
if (disabled !== previous.current.disabled) {
|
|
2530
|
+
dispatch({
|
|
2531
|
+
type: Action.SetDroppableDisabled,
|
|
2532
|
+
id,
|
|
2533
|
+
key,
|
|
2534
|
+
disabled
|
|
2535
|
+
});
|
|
2536
|
+
previous.current.disabled = disabled;
|
|
2537
|
+
}
|
|
2538
|
+
}, [
|
|
2539
|
+
id,
|
|
2540
|
+
key,
|
|
2541
|
+
disabled,
|
|
2542
|
+
dispatch
|
|
2543
|
+
]);
|
|
1967
2544
|
return {
|
|
1968
2545
|
active,
|
|
1969
2546
|
rect,
|
|
@@ -1974,7 +2551,7 @@ function useDroppable({ data, disabled = false, id }) {
|
|
|
1974
2551
|
};
|
|
1975
2552
|
}
|
|
1976
2553
|
//#endregion
|
|
1977
|
-
//#region ../../node_modules/.pnpm/@dnd-kit+sortable@
|
|
2554
|
+
//#region ../../node_modules/.pnpm/@dnd-kit+sortable@10.0.0_@dnd-kit+core@6.3.1_react-dom@19.3.1_react@19.3.1__react@19.3.1__react@19.3.1/node_modules/@dnd-kit/sortable/dist/sortable.esm.js
|
|
1978
2555
|
/**
|
|
1979
2556
|
* Move an array item to a different position. Returns a new array with the item moved to the new position.
|
|
1980
2557
|
*/
|
|
@@ -1983,30 +2560,44 @@ function arrayMove(array, from, to) {
|
|
|
1983
2560
|
newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
|
|
1984
2561
|
return newArray;
|
|
1985
2562
|
}
|
|
1986
|
-
function getSortedRects(items,
|
|
2563
|
+
function getSortedRects(items, rects) {
|
|
1987
2564
|
return items.reduce((accumulator, id, index) => {
|
|
1988
|
-
const
|
|
1989
|
-
if (
|
|
2565
|
+
const rect = rects.get(id);
|
|
2566
|
+
if (rect) accumulator[index] = rect;
|
|
1990
2567
|
return accumulator;
|
|
1991
2568
|
}, Array(items.length));
|
|
1992
2569
|
}
|
|
1993
2570
|
function isValidIndex(index) {
|
|
1994
2571
|
return index !== null && index >= 0;
|
|
1995
2572
|
}
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
2573
|
+
function itemsEqual(a, b) {
|
|
2574
|
+
if (a === b) return true;
|
|
2575
|
+
if (a.length !== b.length) return false;
|
|
2576
|
+
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
2577
|
+
return true;
|
|
2578
|
+
}
|
|
2579
|
+
function normalizeDisabled(disabled) {
|
|
2580
|
+
if (typeof disabled === "boolean") return {
|
|
2581
|
+
draggable: disabled,
|
|
2582
|
+
droppable: disabled
|
|
2583
|
+
};
|
|
2584
|
+
return disabled;
|
|
2585
|
+
}
|
|
2586
|
+
var rectSortingStrategy = (_ref) => {
|
|
2587
|
+
let { rects, activeIndex, overIndex, index } = _ref;
|
|
2588
|
+
const newRects = arrayMove(rects, overIndex, activeIndex);
|
|
2589
|
+
const oldRect = rects[index];
|
|
1999
2590
|
const newRect = newRects[index];
|
|
2000
2591
|
if (!newRect || !oldRect) return null;
|
|
2001
2592
|
return {
|
|
2002
|
-
x: newRect.
|
|
2003
|
-
y: newRect.
|
|
2593
|
+
x: newRect.left - oldRect.left,
|
|
2594
|
+
y: newRect.top - oldRect.top,
|
|
2004
2595
|
scaleX: newRect.width / oldRect.width,
|
|
2005
2596
|
scaleY: newRect.height / oldRect.height
|
|
2006
2597
|
};
|
|
2007
2598
|
};
|
|
2008
2599
|
var ID_PREFIX = "Sortable";
|
|
2009
|
-
var Context =
|
|
2600
|
+
var Context = /*#__PURE__*/ import_react.createContext({
|
|
2010
2601
|
activeIndex: -1,
|
|
2011
2602
|
containerId: ID_PREFIX,
|
|
2012
2603
|
disableTransforms: false,
|
|
@@ -2015,67 +2606,65 @@ var Context = /* @__PURE__ */ import_react.createContext({
|
|
|
2015
2606
|
useDragOverlay: false,
|
|
2016
2607
|
sortedRects: [],
|
|
2017
2608
|
strategy: rectSortingStrategy,
|
|
2018
|
-
|
|
2609
|
+
disabled: {
|
|
2610
|
+
draggable: false,
|
|
2611
|
+
droppable: false
|
|
2612
|
+
}
|
|
2019
2613
|
});
|
|
2020
|
-
function SortableContext(
|
|
2021
|
-
|
|
2614
|
+
function SortableContext(_ref) {
|
|
2615
|
+
let { children, id, items: userDefinedItems, strategy = rectSortingStrategy, disabled: disabledProp = false } = _ref;
|
|
2616
|
+
const { active, dragOverlay, droppableRects, over, measureDroppableContainers } = useDndContext();
|
|
2022
2617
|
const containerId = useUniqueId(ID_PREFIX, id);
|
|
2023
2618
|
const useDragOverlay = Boolean(dragOverlay.rect !== null);
|
|
2024
|
-
const items = (0, import_react.useMemo)(() => userDefinedItems.map((item) => typeof item === "
|
|
2619
|
+
const items = (0, import_react.useMemo)(() => userDefinedItems.map((item) => typeof item === "object" && "id" in item ? item.id : item), [userDefinedItems]);
|
|
2025
2620
|
const isDragging = active != null;
|
|
2026
|
-
const wasDragging = (0, import_react.useRef)(false);
|
|
2027
2621
|
const activeIndex = active ? items.indexOf(active.id) : -1;
|
|
2028
|
-
const isSorting = activeIndex !== -1;
|
|
2029
2622
|
const overIndex = over ? items.indexOf(over.id) : -1;
|
|
2030
2623
|
const previousItemsRef = (0, import_react.useRef)(items);
|
|
2031
|
-
const
|
|
2032
|
-
const itemsHaveChanged = !isEqual(items, previousItemsRef.current);
|
|
2624
|
+
const itemsHaveChanged = !itemsEqual(items, previousItemsRef.current);
|
|
2033
2625
|
const disableTransforms = overIndex !== -1 && activeIndex === -1 || itemsHaveChanged;
|
|
2626
|
+
const disabled = normalizeDisabled(disabledProp);
|
|
2034
2627
|
useIsomorphicLayoutEffect(() => {
|
|
2035
|
-
if (itemsHaveChanged &&
|
|
2628
|
+
if (itemsHaveChanged && isDragging) measureDroppableContainers(items);
|
|
2036
2629
|
}, [
|
|
2037
2630
|
itemsHaveChanged,
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2631
|
+
items,
|
|
2632
|
+
isDragging,
|
|
2633
|
+
measureDroppableContainers
|
|
2041
2634
|
]);
|
|
2042
2635
|
(0, import_react.useEffect)(() => {
|
|
2043
2636
|
previousItemsRef.current = items;
|
|
2044
2637
|
}, [items]);
|
|
2045
|
-
(0, import_react.useEffect)(() => {
|
|
2046
|
-
const timeoutId = setTimeout(() => {
|
|
2047
|
-
wasDragging.current = isDragging;
|
|
2048
|
-
}, 100);
|
|
2049
|
-
return () => clearTimeout(timeoutId);
|
|
2050
|
-
}, [isDragging]);
|
|
2051
2638
|
const contextValue = (0, import_react.useMemo)(() => ({
|
|
2052
2639
|
activeIndex,
|
|
2053
2640
|
containerId,
|
|
2641
|
+
disabled,
|
|
2054
2642
|
disableTransforms,
|
|
2055
2643
|
items,
|
|
2056
2644
|
overIndex,
|
|
2057
2645
|
useDragOverlay,
|
|
2058
|
-
sortedRects,
|
|
2059
|
-
strategy
|
|
2060
|
-
wasDragging
|
|
2646
|
+
sortedRects: getSortedRects(items, droppableRects),
|
|
2647
|
+
strategy
|
|
2061
2648
|
}), [
|
|
2062
2649
|
activeIndex,
|
|
2063
2650
|
containerId,
|
|
2651
|
+
disabled.draggable,
|
|
2652
|
+
disabled.droppable,
|
|
2064
2653
|
disableTransforms,
|
|
2065
2654
|
items,
|
|
2066
2655
|
overIndex,
|
|
2067
|
-
|
|
2656
|
+
droppableRects,
|
|
2068
2657
|
useDragOverlay,
|
|
2069
|
-
strategy
|
|
2070
|
-
wasDragging
|
|
2658
|
+
strategy
|
|
2071
2659
|
]);
|
|
2072
2660
|
return import_react.createElement(Context.Provider, { value: contextValue }, children);
|
|
2073
2661
|
}
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
var defaultAnimateLayoutChanges = (
|
|
2662
|
+
var defaultNewIndexGetter = (_ref) => {
|
|
2663
|
+
let { id, items, activeIndex, overIndex } = _ref;
|
|
2664
|
+
return arrayMove(items, activeIndex, overIndex).indexOf(id);
|
|
2665
|
+
};
|
|
2666
|
+
var defaultAnimateLayoutChanges = (_ref2) => {
|
|
2667
|
+
let { containerId, isSorting, wasDragging, index, items, newIndex, previousItems, previousContainerId, transition } = _ref2;
|
|
2079
2668
|
if (!transition || !wasDragging) return false;
|
|
2080
2669
|
if (previousItems !== items && index === newIndex) return false;
|
|
2081
2670
|
if (isSorting) return true;
|
|
@@ -2086,23 +2675,24 @@ var defaultTransition = {
|
|
|
2086
2675
|
easing: "ease"
|
|
2087
2676
|
};
|
|
2088
2677
|
var transitionProperty = "transform";
|
|
2089
|
-
var disabledTransition =
|
|
2678
|
+
var disabledTransition = /*#__PURE__*/ CSS.Transition.toString({
|
|
2090
2679
|
property: transitionProperty,
|
|
2091
2680
|
duration: 0,
|
|
2092
2681
|
easing: "linear"
|
|
2093
2682
|
});
|
|
2094
2683
|
var defaultAttributes = { roleDescription: "sortable" };
|
|
2095
|
-
function useDerivedTransform(
|
|
2684
|
+
function useDerivedTransform(_ref) {
|
|
2685
|
+
let { disabled, index, node, rect } = _ref;
|
|
2096
2686
|
const [derivedTransform, setDerivedtransform] = (0, import_react.useState)(null);
|
|
2097
2687
|
const previousIndex = (0, import_react.useRef)(index);
|
|
2098
2688
|
useIsomorphicLayoutEffect(() => {
|
|
2099
2689
|
if (!disabled && index !== previousIndex.current && node.current) {
|
|
2100
2690
|
const initial = rect.current;
|
|
2101
2691
|
if (initial) {
|
|
2102
|
-
const current =
|
|
2692
|
+
const current = getClientRect(node.current, { ignoreTransform: true });
|
|
2103
2693
|
const delta = {
|
|
2104
|
-
x: initial.
|
|
2105
|
-
y: initial.
|
|
2694
|
+
x: initial.left - current.left,
|
|
2695
|
+
y: initial.top - current.top,
|
|
2106
2696
|
scaleX: initial.width / current.width,
|
|
2107
2697
|
scaleY: initial.height / current.height
|
|
2108
2698
|
};
|
|
@@ -2117,14 +2707,14 @@ function useDerivedTransform({ disabled, index, node, rect }) {
|
|
|
2117
2707
|
rect
|
|
2118
2708
|
]);
|
|
2119
2709
|
(0, import_react.useEffect)(() => {
|
|
2120
|
-
if (derivedTransform)
|
|
2121
|
-
setDerivedtransform(null);
|
|
2122
|
-
});
|
|
2710
|
+
if (derivedTransform) setDerivedtransform(null);
|
|
2123
2711
|
}, [derivedTransform]);
|
|
2124
2712
|
return derivedTransform;
|
|
2125
2713
|
}
|
|
2126
|
-
function useSortable(
|
|
2127
|
-
|
|
2714
|
+
function useSortable(_ref) {
|
|
2715
|
+
let { animateLayoutChanges = defaultAnimateLayoutChanges, attributes: userDefinedAttributes, disabled: localDisabled, data: customData, getNewIndex = defaultNewIndexGetter, id, strategy: localStrategy, resizeObserverConfig, transition = defaultTransition } = _ref;
|
|
2716
|
+
const { items, containerId, activeIndex, disabled: globalDisabled, disableTransforms, sortedRects, overIndex, useDragOverlay, strategy: globalStrategy } = (0, import_react.useContext)(Context);
|
|
2717
|
+
const disabled = normalizeLocalDisabled(localDisabled, globalDisabled);
|
|
2128
2718
|
const index = items.indexOf(id);
|
|
2129
2719
|
const data = (0, import_react.useMemo)(() => ({
|
|
2130
2720
|
sortable: {
|
|
@@ -2139,26 +2729,32 @@ function useSortable({ animateLayoutChanges = defaultAnimateLayoutChanges, attri
|
|
|
2139
2729
|
index,
|
|
2140
2730
|
items
|
|
2141
2731
|
]);
|
|
2142
|
-
const
|
|
2732
|
+
const itemsAfterCurrentSortable = (0, import_react.useMemo)(() => items.slice(items.indexOf(id)), [items, id]);
|
|
2733
|
+
const { rect, node, isOver, setNodeRef: setDroppableNodeRef } = useDroppable({
|
|
2143
2734
|
id,
|
|
2144
|
-
data
|
|
2735
|
+
data,
|
|
2736
|
+
disabled: disabled.droppable,
|
|
2737
|
+
resizeObserverConfig: {
|
|
2738
|
+
updateMeasurementsFor: itemsAfterCurrentSortable,
|
|
2739
|
+
...resizeObserverConfig
|
|
2740
|
+
}
|
|
2145
2741
|
});
|
|
2146
|
-
const { active,
|
|
2742
|
+
const { active, activatorEvent, activeNodeRect, attributes, setNodeRef: setDraggableNodeRef, listeners, isDragging, over, setActivatorNodeRef, transform } = useDraggable({
|
|
2147
2743
|
id,
|
|
2148
2744
|
data,
|
|
2149
2745
|
attributes: {
|
|
2150
2746
|
...defaultAttributes,
|
|
2151
2747
|
...userDefinedAttributes
|
|
2152
2748
|
},
|
|
2153
|
-
disabled
|
|
2749
|
+
disabled: disabled.draggable
|
|
2154
2750
|
});
|
|
2155
2751
|
const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
2156
2752
|
const isSorting = Boolean(active);
|
|
2157
|
-
const displaceItem = isSorting &&
|
|
2753
|
+
const displaceItem = isSorting && !disableTransforms && isValidIndex(activeIndex) && isValidIndex(overIndex);
|
|
2158
2754
|
const shouldDisplaceDragSource = !useDragOverlay && isDragging;
|
|
2159
2755
|
const dragSourceDisplacement = shouldDisplaceDragSource && displaceItem ? transform : null;
|
|
2160
2756
|
const finalTransform = displaceItem ? dragSourceDisplacement != null ? dragSourceDisplacement : (localStrategy != null ? localStrategy : globalStrategy)({
|
|
2161
|
-
|
|
2757
|
+
rects: sortedRects,
|
|
2162
2758
|
activeNodeRect,
|
|
2163
2759
|
activeIndex,
|
|
2164
2760
|
overIndex,
|
|
@@ -2170,10 +2766,14 @@ function useSortable({ animateLayoutChanges = defaultAnimateLayoutChanges, attri
|
|
|
2170
2766
|
activeIndex,
|
|
2171
2767
|
overIndex
|
|
2172
2768
|
}) : index;
|
|
2173
|
-
const
|
|
2174
|
-
const
|
|
2175
|
-
|
|
2176
|
-
|
|
2769
|
+
const activeId = active == null ? void 0 : active.id;
|
|
2770
|
+
const previous = (0, import_react.useRef)({
|
|
2771
|
+
activeId,
|
|
2772
|
+
items,
|
|
2773
|
+
newIndex,
|
|
2774
|
+
containerId
|
|
2775
|
+
});
|
|
2776
|
+
const itemsHaveChanged = items !== previous.current.items;
|
|
2177
2777
|
const shouldAnimateLayoutChanges = animateLayoutChanges({
|
|
2178
2778
|
active,
|
|
2179
2779
|
containerId,
|
|
@@ -2182,11 +2782,11 @@ function useSortable({ animateLayoutChanges = defaultAnimateLayoutChanges, attri
|
|
|
2182
2782
|
id,
|
|
2183
2783
|
index,
|
|
2184
2784
|
items,
|
|
2185
|
-
newIndex:
|
|
2186
|
-
previousItems:
|
|
2187
|
-
previousContainerId:
|
|
2785
|
+
newIndex: previous.current.newIndex,
|
|
2786
|
+
previousItems: previous.current.items,
|
|
2787
|
+
previousContainerId: previous.current.containerId,
|
|
2188
2788
|
transition,
|
|
2189
|
-
wasDragging:
|
|
2789
|
+
wasDragging: previous.current.activeId != null
|
|
2190
2790
|
});
|
|
2191
2791
|
const derivedTransform = useDerivedTransform({
|
|
2192
2792
|
disabled: !shouldAnimateLayoutChanges,
|
|
@@ -2195,21 +2795,36 @@ function useSortable({ animateLayoutChanges = defaultAnimateLayoutChanges, attri
|
|
|
2195
2795
|
rect
|
|
2196
2796
|
});
|
|
2197
2797
|
(0, import_react.useEffect)(() => {
|
|
2198
|
-
if (isSorting &&
|
|
2199
|
-
if (containerId !==
|
|
2200
|
-
if (items !==
|
|
2798
|
+
if (isSorting && previous.current.newIndex !== newIndex) previous.current.newIndex = newIndex;
|
|
2799
|
+
if (containerId !== previous.current.containerId) previous.current.containerId = containerId;
|
|
2800
|
+
if (items !== previous.current.items) previous.current.items = items;
|
|
2201
2801
|
}, [
|
|
2202
2802
|
isSorting,
|
|
2203
2803
|
newIndex,
|
|
2204
2804
|
containerId,
|
|
2205
2805
|
items
|
|
2206
2806
|
]);
|
|
2807
|
+
(0, import_react.useEffect)(() => {
|
|
2808
|
+
if (activeId === previous.current.activeId) return;
|
|
2809
|
+
if (activeId != null && previous.current.activeId == null) {
|
|
2810
|
+
previous.current.activeId = activeId;
|
|
2811
|
+
return;
|
|
2812
|
+
}
|
|
2813
|
+
const timeoutId = setTimeout(() => {
|
|
2814
|
+
previous.current.activeId = activeId;
|
|
2815
|
+
}, 50);
|
|
2816
|
+
return () => clearTimeout(timeoutId);
|
|
2817
|
+
}, [activeId]);
|
|
2207
2818
|
return {
|
|
2208
2819
|
active,
|
|
2820
|
+
activeIndex,
|
|
2209
2821
|
attributes,
|
|
2210
|
-
|
|
2822
|
+
data,
|
|
2211
2823
|
rect,
|
|
2212
2824
|
index,
|
|
2825
|
+
newIndex,
|
|
2826
|
+
items,
|
|
2827
|
+
isOver,
|
|
2213
2828
|
isSorting,
|
|
2214
2829
|
isDragging,
|
|
2215
2830
|
listeners,
|
|
@@ -2217,46 +2832,69 @@ function useSortable({ animateLayoutChanges = defaultAnimateLayoutChanges, attri
|
|
|
2217
2832
|
overIndex,
|
|
2218
2833
|
over,
|
|
2219
2834
|
setNodeRef,
|
|
2835
|
+
setActivatorNodeRef,
|
|
2220
2836
|
setDroppableNodeRef,
|
|
2221
2837
|
setDraggableNodeRef,
|
|
2222
2838
|
transform: derivedTransform != null ? derivedTransform : finalTransform,
|
|
2223
2839
|
transition: getTransition()
|
|
2224
2840
|
};
|
|
2225
2841
|
function getTransition() {
|
|
2226
|
-
if (derivedTransform || itemsHaveChanged &&
|
|
2227
|
-
if (shouldDisplaceDragSource || !transition) return;
|
|
2842
|
+
if (derivedTransform || itemsHaveChanged && previous.current.newIndex === index) return disabledTransition;
|
|
2843
|
+
if (shouldDisplaceDragSource && !isKeyboardEvent(activatorEvent) || !transition) return;
|
|
2228
2844
|
if (isSorting || shouldAnimateLayoutChanges) return CSS.Transition.toString({
|
|
2229
2845
|
...transition,
|
|
2230
2846
|
property: transitionProperty
|
|
2231
2847
|
});
|
|
2232
2848
|
}
|
|
2233
2849
|
}
|
|
2850
|
+
function normalizeLocalDisabled(localDisabled, globalDisabled) {
|
|
2851
|
+
var _localDisabled$dragga, _localDisabled$droppa;
|
|
2852
|
+
if (typeof localDisabled === "boolean") return {
|
|
2853
|
+
draggable: localDisabled,
|
|
2854
|
+
droppable: false
|
|
2855
|
+
};
|
|
2856
|
+
return {
|
|
2857
|
+
draggable: (_localDisabled$dragga = localDisabled == null ? void 0 : localDisabled.draggable) != null ? _localDisabled$dragga : globalDisabled.draggable,
|
|
2858
|
+
droppable: (_localDisabled$droppa = localDisabled == null ? void 0 : localDisabled.droppable) != null ? _localDisabled$droppa : globalDisabled.droppable
|
|
2859
|
+
};
|
|
2860
|
+
}
|
|
2234
2861
|
KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left;
|
|
2235
2862
|
//#endregion
|
|
2236
2863
|
//#region ~icons/lucide/gauge.jsx
|
|
2237
2864
|
var import_jsx_runtime = require_jsx_runtime();
|
|
2238
|
-
var lucideGauge = (props) => /* @__PURE__ */ (0, import_jsx_runtime.
|
|
2865
|
+
var lucideGauge = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
|
|
2239
2866
|
viewBox: "0 0 24 24",
|
|
2240
2867
|
width: "1.2em",
|
|
2241
2868
|
height: "1.2em",
|
|
2869
|
+
ref,
|
|
2870
|
+
"aria-labelledby": titleId,
|
|
2242
2871
|
...props,
|
|
2243
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("
|
|
2872
|
+
children: [title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", {
|
|
2873
|
+
id: titleId,
|
|
2874
|
+
children: title
|
|
2875
|
+
}) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
|
|
2244
2876
|
fill: "none",
|
|
2245
2877
|
stroke: "currentColor",
|
|
2246
2878
|
strokeLinecap: "round",
|
|
2247
2879
|
strokeLinejoin: "round",
|
|
2248
2880
|
strokeWidth: 2,
|
|
2249
2881
|
d: "m12 14l4-4M3.34 19a10 10 0 1 1 17.32 0"
|
|
2250
|
-
})
|
|
2882
|
+
})]
|
|
2251
2883
|
});
|
|
2884
|
+
var ForwardRef$1 = (0, import_react.forwardRef)(lucideGauge);
|
|
2252
2885
|
//#endregion
|
|
2253
2886
|
//#region ~icons/lucide/grip-vertical.jsx
|
|
2254
|
-
var lucideGripVertical = (props) => /* @__PURE__ */ (0, import_jsx_runtime.
|
|
2887
|
+
var lucideGripVertical = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
|
|
2255
2888
|
viewBox: "0 0 24 24",
|
|
2256
2889
|
width: "1.2em",
|
|
2257
2890
|
height: "1.2em",
|
|
2891
|
+
ref,
|
|
2892
|
+
"aria-labelledby": titleId,
|
|
2258
2893
|
...props,
|
|
2259
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.
|
|
2894
|
+
children: [title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", {
|
|
2895
|
+
id: titleId,
|
|
2896
|
+
children: title
|
|
2897
|
+
}) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
2260
2898
|
fill: "none",
|
|
2261
2899
|
stroke: "currentColor",
|
|
2262
2900
|
strokeLinecap: "round",
|
|
@@ -2294,11 +2932,12 @@ var lucideGripVertical = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
|
2294
2932
|
r: 1
|
|
2295
2933
|
})
|
|
2296
2934
|
]
|
|
2297
|
-
})
|
|
2935
|
+
})]
|
|
2298
2936
|
});
|
|
2937
|
+
var ForwardRef = (0, import_react.forwardRef)(lucideGripVertical);
|
|
2299
2938
|
//#endregion
|
|
2300
2939
|
//#region src/components/qgrid/UsageCard.tsx
|
|
2301
|
-
var QUOTA_THRESHOLD_PROVIDERS = new Set([
|
|
2940
|
+
var QUOTA_THRESHOLD_PROVIDERS = /* @__PURE__ */ new Set([
|
|
2302
2941
|
"anthropic",
|
|
2303
2942
|
"openai",
|
|
2304
2943
|
"grok"
|
|
@@ -2456,13 +3095,10 @@ function UsageRow({ label, utilization, resetsAt, windowDurationMins, theme, thr
|
|
|
2456
3095
|
function TokenUsage({ token, theme }) {
|
|
2457
3096
|
const queryClient = useQueryClient();
|
|
2458
3097
|
const { data, isLoading, dataUpdatedAt } = QgridService.useUsage(token.id);
|
|
3098
|
+
const failedLookupAt = data?.error ? dataUpdatedAt : void 0;
|
|
2459
3099
|
(0, import_react.useEffect)(() => {
|
|
2460
|
-
if (
|
|
2461
|
-
}, [
|
|
2462
|
-
data?.error,
|
|
2463
|
-
dataUpdatedAt,
|
|
2464
|
-
queryClient
|
|
2465
|
-
]);
|
|
3100
|
+
if (failedLookupAt !== void 0) queryClient.invalidateQueries({ queryKey: ["Token"] });
|
|
3101
|
+
}, [failedLookupAt, queryClient]);
|
|
2466
3102
|
if (token.reauth_required) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2467
3103
|
className: "py-1",
|
|
2468
3104
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
@@ -2537,9 +3173,10 @@ function ThresholdControl({ token }) {
|
|
|
2537
3173
|
const left = Math.min(Math.max(rect.right - POPOVER_WIDTH, MARGIN), Math.max(window.innerWidth - POPOVER_WIDTH - MARGIN, MARGIN));
|
|
2538
3174
|
const above = rect.top - GAP - POPOVER_EST_HEIGHT;
|
|
2539
3175
|
const below = rect.bottom + GAP;
|
|
3176
|
+
const clampedTop = Math.min(Math.max(above >= MARGIN ? above : below, MARGIN), Math.max(window.innerHeight - POPOVER_EST_HEIGHT - MARGIN, MARGIN));
|
|
2540
3177
|
setPos({
|
|
2541
3178
|
left,
|
|
2542
|
-
top:
|
|
3179
|
+
top: clampedTop
|
|
2543
3180
|
});
|
|
2544
3181
|
setValue(String(token.quota_threshold ?? 100));
|
|
2545
3182
|
};
|
|
@@ -2547,7 +3184,7 @@ function ThresholdControl({ token }) {
|
|
|
2547
3184
|
if (!supported) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
2548
3185
|
className: "inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[10px] text-sand-300 border border-sand-100",
|
|
2549
3186
|
title: "Quota threshold는 이 provider에서 지원되지 않습니다",
|
|
2550
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3187
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$1, { className: "size-3" }), "n/a"]
|
|
2551
3188
|
});
|
|
2552
3189
|
const adjust = (delta) => {
|
|
2553
3190
|
const current = /^\d+$/.test(value.trim()) ? Number(value.trim()) : 0;
|
|
@@ -2571,7 +3208,7 @@ function ThresholdControl({ token }) {
|
|
|
2571
3208
|
title: "사용률 제한 설정",
|
|
2572
3209
|
onClick: open ? close : openPopover,
|
|
2573
3210
|
className: "flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[10px] border border-sand-200/80 text-sand-400 hover:text-sand-600 hover:border-sand-300 transition-colors duration-150",
|
|
2574
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3211
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$1, { className: "size-3" }), "Set limit"]
|
|
2575
3212
|
}), open && pos && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
2576
3213
|
className: "fixed inset-0 z-40",
|
|
2577
3214
|
onPointerDown: close
|
|
@@ -2812,14 +3449,15 @@ function SortableTokenCard({ token }) {
|
|
|
2812
3449
|
if (token.name) totalCostParams.token_name = token.name;
|
|
2813
3450
|
const { data: costData } = QgridService.useTotalCost(totalCostParams, { enabled: !!token.name });
|
|
2814
3451
|
const theme = getProviderTheme(token.provider);
|
|
3452
|
+
const style = {
|
|
3453
|
+
transform: CSS.Translate.toString(transform),
|
|
3454
|
+
transition,
|
|
3455
|
+
opacity: isDragging ? .5 : 1,
|
|
3456
|
+
zIndex: isDragging ? 10 : void 0
|
|
3457
|
+
};
|
|
2815
3458
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2816
3459
|
ref: setNodeRef,
|
|
2817
|
-
style
|
|
2818
|
-
transform: CSS.Translate.toString(transform),
|
|
2819
|
-
transition,
|
|
2820
|
-
opacity: isDragging ? .5 : 1,
|
|
2821
|
-
zIndex: isDragging ? 10 : void 0
|
|
2822
|
-
},
|
|
3460
|
+
style,
|
|
2823
3461
|
className: "relative rounded-lg bg-white border border-sand-200/80 overflow-hidden shadow-sm hover:shadow-md transition-shadow duration-200",
|
|
2824
3462
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `absolute inset-y-0 left-0 w-1 ${theme.stripe}` }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2825
3463
|
className: "pl-4 pr-3 py-3",
|
|
@@ -2834,7 +3472,7 @@ function SortableTokenCard({ token }) {
|
|
|
2834
3472
|
...attributes,
|
|
2835
3473
|
...listeners,
|
|
2836
3474
|
className: "shrink-0 -m-1 p-1 text-sand-300 hover:text-sand-500 cursor-grab active:cursor-grabbing touch-none",
|
|
2837
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3475
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef, { className: "size-3.5" })
|
|
2838
3476
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2839
3477
|
className: "text-[13px] font-medium text-sand-800 truncate select-none",
|
|
2840
3478
|
children: token.name ?? "Unnamed"
|
|
@@ -2899,11 +3537,10 @@ function UsageCard() {
|
|
|
2899
3537
|
const { data, isLoading } = TokenService.useTokens("A", { orderBy: "ord-asc" });
|
|
2900
3538
|
const queryClient = useQueryClient();
|
|
2901
3539
|
const reorderMutation = TokenService.useReorderMutation();
|
|
2902
|
-
const [
|
|
3540
|
+
const [reorder, setReorder] = (0, import_react.useState)(null);
|
|
2903
3541
|
const [providerFilter, setProviderFilter] = (0, import_react.useState)("all");
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
}, [data?.rows]);
|
|
3542
|
+
const serverTokens = data?.rows ?? [];
|
|
3543
|
+
const localTokens = reorder !== null && reorder.from === data?.rows ? reorder.tokens : serverTokens;
|
|
2907
3544
|
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));
|
|
2908
3545
|
const handleDragEnd = (event) => {
|
|
2909
3546
|
const { active, over } = event;
|
|
@@ -2914,7 +3551,10 @@ function UsageCard() {
|
|
|
2914
3551
|
const newIndex = localTokens.findIndex((t) => t.id === overId);
|
|
2915
3552
|
if (oldIndex === -1 || newIndex === -1) return;
|
|
2916
3553
|
const reordered = arrayMove(localTokens, oldIndex, newIndex);
|
|
2917
|
-
|
|
3554
|
+
setReorder({
|
|
3555
|
+
from: serverTokens,
|
|
3556
|
+
tokens: reordered
|
|
3557
|
+
});
|
|
2918
3558
|
const queryKey = TokenService.getTokensQueryOptions("A", { orderBy: "ord-asc" }).queryKey;
|
|
2919
3559
|
const prev = queryClient.getQueryData(queryKey);
|
|
2920
3560
|
queryClient.setQueryData(queryKey, (old) => old ? {
|
|
@@ -2924,7 +3564,7 @@ function UsageCard() {
|
|
|
2924
3564
|
reorderMutation.mutate({ ids: reordered.map((t) => t.id) }, {
|
|
2925
3565
|
onError: () => {
|
|
2926
3566
|
queryClient.setQueryData(queryKey, prev);
|
|
2927
|
-
|
|
3567
|
+
setReorder(null);
|
|
2928
3568
|
},
|
|
2929
3569
|
onSettled: () => {
|
|
2930
3570
|
Promise.all([queryClient.invalidateQueries({ queryKey: ["Token"] }), queryClient.invalidateQueries({ queryKey: ["Qgrid"] })]);
|