@cartanova/qgrid-cli 2.11.1 → 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-response-format.js +9 -1
- package/bundle/dist/application/qgrid/qgrid-run-lifecycle.js +30 -6
- package/bundle/dist/application/qgrid/qgrid.dispatcher.js +7 -4
- package/bundle/dist/application/qgrid/qgrid.frame.js +30 -9
- 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 +13 -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 +9 -3
- package/bundle/dist/utils/providers/anthropic/anthropic-thinking.js +5 -2
- package/bundle/dist/utils/providers/anthropic/claude-session.js +10 -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-backend-protocol.js +1 -1
- package/bundle/dist/utils/providers/grok/grok-constants.js +1 -1
- package/bundle/dist/utils/providers/grok/grok-dispatcher.js +47 -14
- 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/grok/grok-types.js +2 -2
- package/bundle/dist/utils/providers/openai/openai-dispatcher.js +16 -8
- package/bundle/dist/utils/providers/openai/openai-image-generation.js +4 -4
- package/bundle/src/application/qgrid/qgrid-response-format.ts +9 -0
- package/bundle/src/application/qgrid/qgrid-run-lifecycle.test.ts +63 -0
- package/bundle/src/application/qgrid/qgrid-run-lifecycle.ts +49 -7
- package/bundle/src/application/qgrid/qgrid.dispatcher.ts +6 -0
- package/bundle/src/application/qgrid/qgrid.frame.test.ts +12 -4
- package/bundle/src/application/qgrid/qgrid.frame.ts +39 -3
- package/bundle/src/application/qgrid/qgrid.types.ts +5 -5
- package/bundle/src/application/request-log/request-log.model.ts +12 -1
- package/bundle/src/sonamu.config.ts +14 -14
- package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.ts +2 -0
- package/bundle/src/utils/providers/anthropic/claude-session.ts +15 -1
- package/bundle/src/utils/providers/common/model-cost.ts +8 -6
- package/bundle/src/utils/providers/common/provider-dispatcher.ts +10 -0
- package/bundle/src/utils/providers/grok/grok-backend-protocol.ts +6 -1
- package/bundle/src/utils/providers/grok/grok-constants.ts +7 -8
- package/bundle/src/utils/providers/grok/grok-dispatcher.test.ts +74 -3
- package/bundle/src/utils/providers/grok/grok-dispatcher.ts +66 -18
- package/bundle/src/utils/providers/grok/grok-quota.test.ts +18 -0
- package/bundle/src/utils/providers/grok/grok-types.ts +2 -1
- package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +18 -0
- package/bundle/src/utils/providers/openai/openai-dispatcher.ts +10 -2
- 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-B7QmGJq3.js → logs-C0md5rmp.js} +67 -37
- 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-DIuPZZwu.js +38 -0
- package/bundle/web-dist/server/assets/{routes-_Y-PJfgO.js → routes-CjWxvHAO.js} +1745 -1120
- package/bundle/web-dist/server/assets/{services.generated-CMJ8AHbO.js → services.generated-CqS8DCjT.js} +11973 -6081
- package/bundle/web-dist/server/assets/{settings-JwJKxn2e.js → settings-CXwnKiMG.js} +40 -19
- package/bundle/web-dist/server/assets/{show-BEv6z1v_.js → show-G1t8dOEh.js} +274 -213
- package/bundle/web-dist/server/assets/{tokens-CNT4mI-f.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 +11641 -5075
- package/dist/cli.js +20 -11
- package/package.json +24 -24
- package/skills/qgrid/references/ai-sdk-provider-contract.md +5 -5
- package/skills/qgrid/references/cli-env-and-server-boot.md +4 -3
- package/skills/qgrid/references/decision-rationale.md +5 -1
- package/skills/qgrid/references/grok-runtime.md +7 -1
- package/skills/qgrid/references/repo-map.md +2 -0
- package/skills/qgrid/references/request-log-run-lifecycle.md +6 -1
- package/skills/qgrid/references/tool-calling-and-multiturn.md +2 -2
- package/skills/qgrid/references/verification-and-debugging.md +24 -5
- 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-C96h3feE.js +0 -32
- package/bundle/web-dist/client/assets/logs-DBM6U0QD.js +0 -1
- package/bundle/web-dist/client/assets/monit-BBjXa7vB.js +0 -1
- package/bundle/web-dist/client/assets/plus-BsQdY7PS.js +0 -1
- package/bundle/web-dist/client/assets/preload-helper-DWTEM3RW.js +0 -1
- package/bundle/web-dist/client/assets/refresh-cw-D9IUmT23.js +0 -1
- package/bundle/web-dist/client/assets/request-model-Bpp_rkK8.js +0 -1
- package/bundle/web-dist/client/assets/rolldown-runtime-Dw2cE7zH.js +0 -1
- package/bundle/web-dist/client/assets/routes-Crz_PQzi.js +0 -5
- package/bundle/web-dist/client/assets/services.generated-B5lc3aIC.js +0 -51
- package/bundle/web-dist/client/assets/settings-Cdwm3OBB.js +0 -1
- package/bundle/web-dist/client/assets/show-DBUhALT1.js +0 -2
- package/bundle/web-dist/client/assets/tokens-CVQAVJTo.js +0 -1
- package/bundle/web-dist/client/assets/total-cost-MnfKU8IN.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-DFt7x3bh.js +0 -1652
- package/bundle/web-dist/server/assets/plus-DaYQRpBt.js +0 -19
- package/bundle/web-dist/server/assets/react-dom-Cv23mm1K.js +0 -335
- package/bundle/web-dist/server/assets/refresh-cw-BpXNsAy-.js +0 -23
- package/bundle/web-dist/server/assets/request-model-eHE6YbaF.js +0 -31
- package/bundle/web-dist/server/assets/total-cost-fTE9Xy82.js +0 -18
- /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,10 +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
|
-
|
|
7
|
-
//#region ../../node_modules/.pnpm/@dnd-kit+utilities@3.2.2_react@19.2.4/node_modules/@dnd-kit/utilities/dist/utilities.esm.js
|
|
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
|
|
8
7
|
var import_react_dom = /* @__PURE__ */ __toESM(require_react_dom());
|
|
9
8
|
var import_react = /* @__PURE__ */ __toESM(require_react());
|
|
10
9
|
function useCombinedRefs() {
|
|
@@ -73,6 +72,14 @@ function useInterval() {
|
|
|
73
72
|
}
|
|
74
73
|
}, [])];
|
|
75
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
|
+
}
|
|
76
83
|
function useLazyMemo(callback, dependencies) {
|
|
77
84
|
const valueRef = (0, import_react.useRef)();
|
|
78
85
|
return (0, import_react.useMemo)(() => {
|
|
@@ -89,6 +96,13 @@ function useNodeRef(onChange) {
|
|
|
89
96
|
node.current = element;
|
|
90
97
|
}, [])];
|
|
91
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
|
+
}
|
|
92
106
|
var ids = {};
|
|
93
107
|
function useUniqueId(prefix, value) {
|
|
94
108
|
return (0, import_react.useMemo)(() => {
|
|
@@ -111,8 +125,8 @@ function createAdjustmentFn(modifier) {
|
|
|
111
125
|
}, { ...object });
|
|
112
126
|
};
|
|
113
127
|
}
|
|
114
|
-
var add =
|
|
115
|
-
var subtract =
|
|
128
|
+
var add = /*#__PURE__*/ createAdjustmentFn(1);
|
|
129
|
+
var subtract = /*#__PURE__*/ createAdjustmentFn(-1);
|
|
116
130
|
function hasViewportRelativeCoordinates(event) {
|
|
117
131
|
return "clientX" in event && "clientY" in event;
|
|
118
132
|
}
|
|
@@ -151,7 +165,7 @@ function getEventCoordinates(event) {
|
|
|
151
165
|
};
|
|
152
166
|
return null;
|
|
153
167
|
}
|
|
154
|
-
var CSS =
|
|
168
|
+
var CSS = /*#__PURE__*/ Object.freeze({
|
|
155
169
|
Translate: { toString(transform) {
|
|
156
170
|
if (!transform) return;
|
|
157
171
|
const { x, y } = transform;
|
|
@@ -171,8 +185,13 @@ var CSS = /* @__PURE__ */ Object.freeze({
|
|
|
171
185
|
return property + " " + duration + "ms " + easing;
|
|
172
186
|
} }
|
|
173
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
|
+
}
|
|
174
193
|
//#endregion
|
|
175
|
-
//#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
|
|
176
195
|
var hiddenStyles = { display: "none" };
|
|
177
196
|
function HiddenText(_ref) {
|
|
178
197
|
let { id, value } = _ref;
|
|
@@ -214,254 +233,125 @@ function useAnnouncement() {
|
|
|
214
233
|
};
|
|
215
234
|
}
|
|
216
235
|
//#endregion
|
|
217
|
-
//#region ../../node_modules/.pnpm/@dnd-kit+core@
|
|
218
|
-
var
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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 " };
|
|
223
260
|
var defaultAnnouncements = {
|
|
224
|
-
onDragStart(
|
|
225
|
-
|
|
261
|
+
onDragStart(_ref) {
|
|
262
|
+
let { active } = _ref;
|
|
263
|
+
return "Picked up draggable item " + active.id + ".";
|
|
226
264
|
},
|
|
227
|
-
onDragOver(
|
|
228
|
-
|
|
229
|
-
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.";
|
|
230
269
|
},
|
|
231
|
-
onDragEnd(
|
|
232
|
-
|
|
233
|
-
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.";
|
|
234
274
|
},
|
|
235
|
-
onDragCancel(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
};
|
|
239
|
-
var Action;
|
|
240
|
-
(function(Action) {
|
|
241
|
-
Action["DragStart"] = "dragStart";
|
|
242
|
-
Action["DragMove"] = "dragMove";
|
|
243
|
-
Action["DragEnd"] = "dragEnd";
|
|
244
|
-
Action["DragCancel"] = "dragCancel";
|
|
245
|
-
Action["DragOver"] = "dragOver";
|
|
246
|
-
Action["RegisterDroppable"] = "registerDroppable";
|
|
247
|
-
Action["SetDroppableDisabled"] = "setDroppableDisabled";
|
|
248
|
-
Action["UnregisterDroppable"] = "unregisterDroppable";
|
|
249
|
-
})(Action || (Action = {}));
|
|
250
|
-
function noop(..._args) {}
|
|
251
|
-
var DroppableContainersMap = class extends Map {
|
|
252
|
-
get(id) {
|
|
253
|
-
var _super$get;
|
|
254
|
-
return id != null ? (_super$get = super.get(id)) != null ? _super$get : void 0 : void 0;
|
|
255
|
-
}
|
|
256
|
-
toArray() {
|
|
257
|
-
return Array.from(this.values());
|
|
258
|
-
}
|
|
259
|
-
getEnabled() {
|
|
260
|
-
return this.toArray().filter(({ disabled }) => !disabled);
|
|
261
|
-
}
|
|
262
|
-
getNodeFor(id) {
|
|
263
|
-
var _this$get$node$curren, _this$get;
|
|
264
|
-
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.";
|
|
265
278
|
}
|
|
266
279
|
};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
active: null,
|
|
270
|
-
activeNode: null,
|
|
271
|
-
activeNodeRect: null,
|
|
272
|
-
activeNodeClientRect: null,
|
|
273
|
-
activators: [],
|
|
274
|
-
ariaDescribedById: { draggable: "" },
|
|
275
|
-
containerNodeRect: null,
|
|
276
|
-
dispatch: noop,
|
|
277
|
-
draggableNodes: {},
|
|
278
|
-
droppableRects: /* @__PURE__ */ new Map(),
|
|
279
|
-
droppableContainers: /* @__PURE__ */ new DroppableContainersMap(),
|
|
280
|
-
over: null,
|
|
281
|
-
dragOverlay: {
|
|
282
|
-
nodeRef: { current: null },
|
|
283
|
-
rect: null,
|
|
284
|
-
setRef: noop
|
|
285
|
-
},
|
|
286
|
-
scrollableAncestors: [],
|
|
287
|
-
scrollableAncestorRects: [],
|
|
288
|
-
recomputeLayouts: noop,
|
|
289
|
-
windowRect: null,
|
|
290
|
-
willRecomputeLayouts: false
|
|
291
|
-
});
|
|
292
|
-
function getInitialState() {
|
|
293
|
-
return {
|
|
294
|
-
draggable: {
|
|
295
|
-
active: null,
|
|
296
|
-
initialCoordinates: {
|
|
297
|
-
x: 0,
|
|
298
|
-
y: 0
|
|
299
|
-
},
|
|
300
|
-
nodes: {},
|
|
301
|
-
translate: {
|
|
302
|
-
x: 0,
|
|
303
|
-
y: 0
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
droppable: { containers: new DroppableContainersMap() }
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
function reducer(state, action) {
|
|
310
|
-
switch (action.type) {
|
|
311
|
-
case Action.DragStart: return {
|
|
312
|
-
...state,
|
|
313
|
-
draggable: {
|
|
314
|
-
...state.draggable,
|
|
315
|
-
initialCoordinates: action.initialCoordinates,
|
|
316
|
-
active: action.active
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
case Action.DragMove:
|
|
320
|
-
if (!state.draggable.active) return state;
|
|
321
|
-
return {
|
|
322
|
-
...state,
|
|
323
|
-
draggable: {
|
|
324
|
-
...state.draggable,
|
|
325
|
-
translate: {
|
|
326
|
-
x: action.coordinates.x - state.draggable.initialCoordinates.x,
|
|
327
|
-
y: action.coordinates.y - state.draggable.initialCoordinates.y
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
case Action.DragEnd:
|
|
332
|
-
case Action.DragCancel: return {
|
|
333
|
-
...state,
|
|
334
|
-
draggable: {
|
|
335
|
-
...state.draggable,
|
|
336
|
-
active: null,
|
|
337
|
-
initialCoordinates: {
|
|
338
|
-
x: 0,
|
|
339
|
-
y: 0
|
|
340
|
-
},
|
|
341
|
-
translate: {
|
|
342
|
-
x: 0,
|
|
343
|
-
y: 0
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
case Action.RegisterDroppable: {
|
|
348
|
-
const { element } = action;
|
|
349
|
-
const { id } = element;
|
|
350
|
-
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
351
|
-
containers.set(id, element);
|
|
352
|
-
return {
|
|
353
|
-
...state,
|
|
354
|
-
droppable: {
|
|
355
|
-
...state.droppable,
|
|
356
|
-
containers
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
case Action.SetDroppableDisabled: {
|
|
361
|
-
const { id, key, disabled } = action;
|
|
362
|
-
const element = state.droppable.containers.get(id);
|
|
363
|
-
if (!element || key !== element.key) return state;
|
|
364
|
-
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
365
|
-
containers.set(id, {
|
|
366
|
-
...element,
|
|
367
|
-
disabled
|
|
368
|
-
});
|
|
369
|
-
return {
|
|
370
|
-
...state,
|
|
371
|
-
droppable: {
|
|
372
|
-
...state.droppable,
|
|
373
|
-
containers
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
case Action.UnregisterDroppable: {
|
|
378
|
-
const { id, key } = action;
|
|
379
|
-
const element = state.droppable.containers.get(id);
|
|
380
|
-
if (!element || key !== element.key) return state;
|
|
381
|
-
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
382
|
-
containers.delete(id);
|
|
383
|
-
return {
|
|
384
|
-
...state,
|
|
385
|
-
droppable: {
|
|
386
|
-
...state.droppable,
|
|
387
|
-
containers
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
default: return state;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
var DndMonitorContext = /* @__PURE__ */ (0, import_react.createContext)({
|
|
395
|
-
type: null,
|
|
396
|
-
event: null
|
|
397
|
-
});
|
|
398
|
-
function useDndMonitor({ onDragStart, onDragMove, onDragOver, onDragEnd, onDragCancel }) {
|
|
399
|
-
const monitorState = (0, import_react.useContext)(DndMonitorContext);
|
|
400
|
-
const previousMonitorState = (0, import_react.useRef)(monitorState);
|
|
401
|
-
(0, import_react.useEffect)(() => {
|
|
402
|
-
if (monitorState !== previousMonitorState.current) {
|
|
403
|
-
const { type, event } = monitorState;
|
|
404
|
-
switch (type) {
|
|
405
|
-
case Action.DragStart:
|
|
406
|
-
onDragStart?.(event);
|
|
407
|
-
break;
|
|
408
|
-
case Action.DragMove:
|
|
409
|
-
onDragMove?.(event);
|
|
410
|
-
break;
|
|
411
|
-
case Action.DragOver:
|
|
412
|
-
onDragOver?.(event);
|
|
413
|
-
break;
|
|
414
|
-
case Action.DragCancel:
|
|
415
|
-
onDragCancel?.(event);
|
|
416
|
-
break;
|
|
417
|
-
case Action.DragEnd:
|
|
418
|
-
onDragEnd?.(event);
|
|
419
|
-
break;
|
|
420
|
-
}
|
|
421
|
-
previousMonitorState.current = monitorState;
|
|
422
|
-
}
|
|
423
|
-
}, [
|
|
424
|
-
monitorState,
|
|
425
|
-
onDragStart,
|
|
426
|
-
onDragMove,
|
|
427
|
-
onDragOver,
|
|
428
|
-
onDragEnd,
|
|
429
|
-
onDragCancel
|
|
430
|
-
]);
|
|
431
|
-
}
|
|
432
|
-
function Accessibility({ announcements = defaultAnnouncements, hiddenTextDescribedById, screenReaderInstructions }) {
|
|
280
|
+
function Accessibility(_ref) {
|
|
281
|
+
let { announcements = defaultAnnouncements, container, hiddenTextDescribedById, screenReaderInstructions = defaultScreenReaderInstructions } = _ref;
|
|
433
282
|
const { announce, announcement } = useAnnouncement();
|
|
434
|
-
const liveRegionId = useUniqueId(
|
|
283
|
+
const liveRegionId = useUniqueId("DndLiveRegion");
|
|
435
284
|
const [mounted, setMounted] = (0, import_react.useState)(false);
|
|
436
285
|
(0, import_react.useEffect)(() => {
|
|
437
286
|
setMounted(true);
|
|
438
287
|
}, []);
|
|
439
288
|
useDndMonitor((0, import_react.useMemo)(() => ({
|
|
440
|
-
onDragStart(
|
|
441
|
-
|
|
289
|
+
onDragStart(_ref2) {
|
|
290
|
+
let { active } = _ref2;
|
|
291
|
+
announce(announcements.onDragStart({ active }));
|
|
442
292
|
},
|
|
443
|
-
onDragMove(
|
|
444
|
-
|
|
293
|
+
onDragMove(_ref3) {
|
|
294
|
+
let { active, over } = _ref3;
|
|
295
|
+
if (announcements.onDragMove) announce(announcements.onDragMove({
|
|
296
|
+
active,
|
|
297
|
+
over
|
|
298
|
+
}));
|
|
445
299
|
},
|
|
446
|
-
onDragOver(
|
|
447
|
-
|
|
300
|
+
onDragOver(_ref4) {
|
|
301
|
+
let { active, over } = _ref4;
|
|
302
|
+
announce(announcements.onDragOver({
|
|
303
|
+
active,
|
|
304
|
+
over
|
|
305
|
+
}));
|
|
448
306
|
},
|
|
449
|
-
onDragEnd(
|
|
450
|
-
|
|
307
|
+
onDragEnd(_ref5) {
|
|
308
|
+
let { active, over } = _ref5;
|
|
309
|
+
announce(announcements.onDragEnd({
|
|
310
|
+
active,
|
|
311
|
+
over
|
|
312
|
+
}));
|
|
451
313
|
},
|
|
452
|
-
onDragCancel(
|
|
453
|
-
|
|
314
|
+
onDragCancel(_ref6) {
|
|
315
|
+
let { active, over } = _ref6;
|
|
316
|
+
announce(announcements.onDragCancel({
|
|
317
|
+
active,
|
|
318
|
+
over
|
|
319
|
+
}));
|
|
454
320
|
}
|
|
455
321
|
}), [announce, announcements]));
|
|
456
|
-
|
|
322
|
+
if (!mounted) return null;
|
|
323
|
+
const markup = import_react.createElement(import_react.Fragment, null, import_react.createElement(HiddenText, {
|
|
457
324
|
id: hiddenTextDescribedById,
|
|
458
325
|
value: screenReaderInstructions.draggable
|
|
459
326
|
}), import_react.createElement(LiveRegion, {
|
|
460
327
|
id: liveRegionId,
|
|
461
328
|
announcement
|
|
462
|
-
}))
|
|
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]);
|
|
463
353
|
}
|
|
464
|
-
var defaultCoordinates =
|
|
354
|
+
var defaultCoordinates = /*#__PURE__*/ Object.freeze({
|
|
465
355
|
x: 0,
|
|
466
356
|
y: 0
|
|
467
357
|
});
|
|
@@ -472,33 +362,102 @@ function distanceBetween(p1, p2) {
|
|
|
472
362
|
return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
|
|
473
363
|
}
|
|
474
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
|
+
/**
|
|
475
386
|
* Returns the coordinates of the center of a given ClientRect
|
|
476
387
|
*/
|
|
477
|
-
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;
|
|
478
391
|
return {
|
|
479
392
|
x: left + rect.width * .5,
|
|
480
393
|
y: top + rect.height * .5
|
|
481
394
|
};
|
|
482
395
|
}
|
|
483
396
|
/**
|
|
484
|
-
* Returns the closest
|
|
397
|
+
* Returns the closest rectangles from an array of rectangles to the center of a given
|
|
485
398
|
* rectangle.
|
|
486
399
|
*/
|
|
487
|
-
var closestCenter = (
|
|
400
|
+
var closestCenter = (_ref) => {
|
|
401
|
+
let { collisionRect, droppableRects, droppableContainers } = _ref;
|
|
488
402
|
const centerRect = centerOfRectangle(collisionRect, collisionRect.left, collisionRect.top);
|
|
489
|
-
|
|
490
|
-
let minDroppableContainer = null;
|
|
403
|
+
const collisions = [];
|
|
491
404
|
for (const droppableContainer of droppableContainers) {
|
|
492
|
-
const {
|
|
405
|
+
const { id } = droppableContainer;
|
|
406
|
+
const rect = droppableRects.get(id);
|
|
493
407
|
if (rect) {
|
|
494
408
|
const distBetween = distanceBetween(centerOfRectangle(rect), centerRect);
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
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
|
+
});
|
|
499
458
|
}
|
|
500
459
|
}
|
|
501
|
-
return
|
|
460
|
+
return collisions.sort(sortCollisionsDesc);
|
|
502
461
|
};
|
|
503
462
|
function adjustScale(transform, rect1, rect2) {
|
|
504
463
|
return {
|
|
@@ -514,36 +473,119 @@ function getRectDelta(rect1, rect2) {
|
|
|
514
473
|
} : defaultCoordinates;
|
|
515
474
|
}
|
|
516
475
|
function createRectAdjustmentFn(modifier) {
|
|
517
|
-
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];
|
|
518
478
|
return adjustments.reduce((acc, adjustment) => ({
|
|
519
479
|
...acc,
|
|
520
480
|
top: acc.top + modifier * adjustment.y,
|
|
521
481
|
bottom: acc.bottom + modifier * adjustment.y,
|
|
522
482
|
left: acc.left + modifier * adjustment.x,
|
|
523
|
-
right: acc.right + modifier * adjustment.x
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
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
|
|
527
567
|
};
|
|
528
568
|
}
|
|
529
|
-
|
|
530
|
-
|
|
569
|
+
function isFixed(node, computedStyle) {
|
|
570
|
+
if (computedStyle === void 0) computedStyle = getWindow(node).getComputedStyle(node);
|
|
531
571
|
return computedStyle.position === "fixed";
|
|
532
572
|
}
|
|
533
|
-
function isScrollable(
|
|
573
|
+
function isScrollable(element, computedStyle) {
|
|
574
|
+
if (computedStyle === void 0) computedStyle = getWindow(element).getComputedStyle(element);
|
|
534
575
|
const overflowRegex = /(auto|scroll|overlay)/;
|
|
535
576
|
return [
|
|
536
577
|
"overflow",
|
|
537
578
|
"overflowX",
|
|
538
579
|
"overflowY"
|
|
539
|
-
].
|
|
580
|
+
].some((property) => {
|
|
540
581
|
const value = computedStyle[property];
|
|
541
582
|
return typeof value === "string" ? overflowRegex.test(value) : false;
|
|
542
|
-
})
|
|
583
|
+
});
|
|
543
584
|
}
|
|
544
|
-
function getScrollableAncestors(element) {
|
|
585
|
+
function getScrollableAncestors(element, limit) {
|
|
545
586
|
const scrollParents = [];
|
|
546
587
|
function findScrollableAncestors(node) {
|
|
588
|
+
if (limit != null && scrollParents.length >= limit) return scrollParents;
|
|
547
589
|
if (!node) return scrollParents;
|
|
548
590
|
if (isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
|
|
549
591
|
scrollParents.push(node.scrollingElement);
|
|
@@ -551,12 +593,19 @@ function getScrollableAncestors(element) {
|
|
|
551
593
|
}
|
|
552
594
|
if (!isHTMLElement(node) || isSVGElement(node)) return scrollParents;
|
|
553
595
|
if (scrollParents.includes(node)) return scrollParents;
|
|
554
|
-
const computedStyle =
|
|
555
|
-
if (
|
|
596
|
+
const computedStyle = getWindow(element).getComputedStyle(node);
|
|
597
|
+
if (node !== element) {
|
|
598
|
+
if (isScrollable(node, computedStyle)) scrollParents.push(node);
|
|
599
|
+
}
|
|
556
600
|
if (isFixed(node, computedStyle)) return scrollParents;
|
|
557
601
|
return findScrollableAncestors(node.parentNode);
|
|
558
602
|
}
|
|
559
|
-
|
|
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;
|
|
560
609
|
}
|
|
561
610
|
function getScrollableElement(element) {
|
|
562
611
|
if (!canUseDOM || !element) return null;
|
|
@@ -566,14 +615,18 @@ function getScrollableElement(element) {
|
|
|
566
615
|
if (isHTMLElement(element)) return element;
|
|
567
616
|
return null;
|
|
568
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
|
+
}
|
|
569
626
|
function getScrollCoordinates(element) {
|
|
570
|
-
if (isWindow(element)) return {
|
|
571
|
-
x: element.scrollX,
|
|
572
|
-
y: element.scrollY
|
|
573
|
-
};
|
|
574
627
|
return {
|
|
575
|
-
x: element
|
|
576
|
-
y: element
|
|
628
|
+
x: getScrollXCoordinate(element),
|
|
629
|
+
y: getScrollYCoordinate(element)
|
|
577
630
|
};
|
|
578
631
|
}
|
|
579
632
|
var Direction;
|
|
@@ -581,14 +634,25 @@ var Direction;
|
|
|
581
634
|
Direction[Direction["Forward"] = 1] = "Forward";
|
|
582
635
|
Direction[Direction["Backward"] = -1] = "Backward";
|
|
583
636
|
})(Direction || (Direction = {}));
|
|
637
|
+
function isDocumentScrollingElement(element) {
|
|
638
|
+
if (!canUseDOM || !element) return false;
|
|
639
|
+
return element === document.scrollingElement;
|
|
640
|
+
}
|
|
584
641
|
function getScrollPosition(scrollingContainer) {
|
|
585
642
|
const minScroll = {
|
|
586
643
|
x: 0,
|
|
587
644
|
y: 0
|
|
588
645
|
};
|
|
646
|
+
const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
|
|
647
|
+
height: window.innerHeight,
|
|
648
|
+
width: window.innerWidth
|
|
649
|
+
} : {
|
|
650
|
+
height: scrollingContainer.clientHeight,
|
|
651
|
+
width: scrollingContainer.clientWidth
|
|
652
|
+
};
|
|
589
653
|
const maxScroll = {
|
|
590
|
-
x: scrollingContainer.scrollWidth -
|
|
591
|
-
y: scrollingContainer.scrollHeight -
|
|
654
|
+
x: scrollingContainer.scrollWidth - dimensions.width,
|
|
655
|
+
y: scrollingContainer.scrollHeight - dimensions.height
|
|
592
656
|
};
|
|
593
657
|
return {
|
|
594
658
|
isTop: scrollingContainer.scrollTop <= minScroll.y,
|
|
@@ -599,24 +663,14 @@ function getScrollPosition(scrollingContainer) {
|
|
|
599
663
|
minScroll
|
|
600
664
|
};
|
|
601
665
|
}
|
|
602
|
-
function isDocumentScrollingElement(element) {
|
|
603
|
-
if (!canUseDOM || !element) return false;
|
|
604
|
-
return element === document.scrollingElement;
|
|
605
|
-
}
|
|
606
666
|
var defaultThreshold = {
|
|
607
667
|
x: .2,
|
|
608
668
|
y: .2
|
|
609
669
|
};
|
|
610
|
-
function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect,
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
left: 0,
|
|
615
|
-
right: clientWidth,
|
|
616
|
-
bottom: clientHeight,
|
|
617
|
-
width: clientWidth,
|
|
618
|
-
height: clientHeight
|
|
619
|
-
} : 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;
|
|
620
674
|
const { isTop, isBottom, isLeft, isRight } = getScrollPosition(scrollContainer);
|
|
621
675
|
const direction = {
|
|
622
676
|
x: 0,
|
|
@@ -627,22 +681,22 @@ function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, { top,
|
|
|
627
681
|
y: 0
|
|
628
682
|
};
|
|
629
683
|
const threshold = {
|
|
630
|
-
height:
|
|
631
|
-
width:
|
|
684
|
+
height: scrollContainerRect.height * thresholdPercentage.y,
|
|
685
|
+
width: scrollContainerRect.width * thresholdPercentage.x
|
|
632
686
|
};
|
|
633
|
-
if (!isTop && top <=
|
|
687
|
+
if (!isTop && top <= scrollContainerRect.top + threshold.height) {
|
|
634
688
|
direction.y = Direction.Backward;
|
|
635
|
-
speed.y = acceleration * Math.abs((
|
|
636
|
-
} 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) {
|
|
637
691
|
direction.y = Direction.Forward;
|
|
638
|
-
speed.y = acceleration * Math.abs((
|
|
692
|
+
speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
|
|
639
693
|
}
|
|
640
|
-
if (!isRight && right >=
|
|
694
|
+
if (!isRight && right >= scrollContainerRect.right - threshold.width) {
|
|
641
695
|
direction.x = Direction.Forward;
|
|
642
|
-
speed.x = acceleration * Math.abs((
|
|
643
|
-
} 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) {
|
|
644
698
|
direction.x = Direction.Backward;
|
|
645
|
-
speed.x = acceleration * Math.abs((
|
|
699
|
+
speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
|
|
646
700
|
}
|
|
647
701
|
return {
|
|
648
702
|
direction,
|
|
@@ -676,519 +730,133 @@ function getScrollOffsets(scrollableAncestors) {
|
|
|
676
730
|
return add(acc, getScrollCoordinates(node));
|
|
677
731
|
}, defaultCoordinates);
|
|
678
732
|
}
|
|
679
|
-
function
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
y: offset.y + node.offsetTop
|
|
684
|
-
};
|
|
685
|
-
if (node.offsetParent === parent) return nodeOffset;
|
|
686
|
-
return getEdgeOffset(node.offsetParent, parent, nodeOffset);
|
|
733
|
+
function getScrollXOffset(scrollableAncestors) {
|
|
734
|
+
return scrollableAncestors.reduce((acc, node) => {
|
|
735
|
+
return acc + getScrollXCoordinate(node);
|
|
736
|
+
}, 0);
|
|
687
737
|
}
|
|
688
|
-
function
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
};
|
|
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
|
+
});
|
|
697
752
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
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 });
|
|
712
785
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
function getViewRect(element) {
|
|
727
|
-
const { width, height, offsetTop, offsetLeft } = getLayoutRect(element);
|
|
728
|
-
const scrollOffsets = getScrollOffsets(getScrollableAncestors(element));
|
|
729
|
-
const top = offsetTop - scrollOffsets.y;
|
|
730
|
-
const left = offsetLeft - scrollOffsets.x;
|
|
731
|
-
return {
|
|
732
|
-
width,
|
|
733
|
-
height,
|
|
734
|
-
top,
|
|
735
|
-
bottom: top + height,
|
|
736
|
-
right: left + width,
|
|
737
|
-
left,
|
|
738
|
-
offsetTop,
|
|
739
|
-
offsetLeft
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
/**
|
|
743
|
-
* Returns the intersecting rectangle area between two rectangles
|
|
744
|
-
*/
|
|
745
|
-
function getIntersectionRatio(entry, target) {
|
|
746
|
-
const top = Math.max(target.top, entry.offsetTop);
|
|
747
|
-
const left = Math.max(target.left, entry.offsetLeft);
|
|
748
|
-
const right = Math.min(target.left + target.width, entry.offsetLeft + entry.width);
|
|
749
|
-
const bottom = Math.min(target.top + target.height, entry.offsetTop + entry.height);
|
|
750
|
-
const width = right - left;
|
|
751
|
-
const height = bottom - top;
|
|
752
|
-
if (left < right && top < bottom) {
|
|
753
|
-
const targetArea = target.width * target.height;
|
|
754
|
-
const entryArea = entry.width * entry.height;
|
|
755
|
-
const intersectionArea = width * height;
|
|
756
|
-
const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
|
|
757
|
-
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;
|
|
758
798
|
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
let maxIntersectingDroppableContainer = null;
|
|
768
|
-
for (const droppableContainer of droppableContainers) {
|
|
769
|
-
const { rect: { current: rect } } = droppableContainer;
|
|
770
|
-
if (rect) {
|
|
771
|
-
const intersectionRatio = getIntersectionRatio(rect, collisionRect);
|
|
772
|
-
if (intersectionRatio > maxIntersectionRatio) {
|
|
773
|
-
maxIntersectionRatio = intersectionRatio;
|
|
774
|
-
maxIntersectingDroppableContainer = droppableContainer.id;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
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
|
+
]);
|
|
777
807
|
}
|
|
778
|
-
return maxIntersectingDroppableContainer;
|
|
779
808
|
};
|
|
780
|
-
|
|
781
|
-
(
|
|
782
|
-
|
|
783
|
-
AutoScrollActivator[AutoScrollActivator["DraggableRect"] = 1] = "DraggableRect";
|
|
784
|
-
})(AutoScrollActivator || (AutoScrollActivator = {}));
|
|
785
|
-
var TraversalOrder;
|
|
786
|
-
(function(TraversalOrder) {
|
|
787
|
-
TraversalOrder[TraversalOrder["TreeOrder"] = 0] = "TreeOrder";
|
|
788
|
-
TraversalOrder[TraversalOrder["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
|
|
789
|
-
})(TraversalOrder || (TraversalOrder = {}));
|
|
790
|
-
function useAutoScroller({ acceleration, activator = AutoScrollActivator.Pointer, canScroll, draggingRect, enabled, interval = 5, order = TraversalOrder.TreeOrder, pointerCoordinates, scrollableAncestors, scrollableAncestorRects, threshold }) {
|
|
791
|
-
const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
|
|
792
|
-
const scrollSpeed = (0, import_react.useRef)({
|
|
793
|
-
x: 1,
|
|
794
|
-
y: 1
|
|
795
|
-
});
|
|
796
|
-
const rect = (0, import_react.useMemo)(() => {
|
|
797
|
-
switch (activator) {
|
|
798
|
-
case AutoScrollActivator.Pointer: return pointerCoordinates ? {
|
|
799
|
-
top: pointerCoordinates.y,
|
|
800
|
-
bottom: pointerCoordinates.y,
|
|
801
|
-
left: pointerCoordinates.x,
|
|
802
|
-
right: pointerCoordinates.x
|
|
803
|
-
} : null;
|
|
804
|
-
case AutoScrollActivator.DraggableRect: return draggingRect;
|
|
805
|
-
}
|
|
806
|
-
return null;
|
|
807
|
-
}, [
|
|
808
|
-
activator,
|
|
809
|
-
draggingRect,
|
|
810
|
-
pointerCoordinates
|
|
811
|
-
]);
|
|
812
|
-
const scrollDirection = (0, import_react.useRef)(defaultCoordinates);
|
|
813
|
-
const scrollContainerRef = (0, import_react.useRef)(null);
|
|
814
|
-
const autoScroll = (0, import_react.useCallback)(() => {
|
|
815
|
-
const scrollContainer = scrollContainerRef.current;
|
|
816
|
-
if (!scrollContainer) return;
|
|
817
|
-
const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
|
|
818
|
-
const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
|
|
819
|
-
scrollContainer.scrollBy(scrollLeft, scrollTop);
|
|
820
|
-
}, []);
|
|
821
|
-
const sortedScrollableAncestors = (0, import_react.useMemo)(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
|
|
822
|
-
(0, import_react.useEffect)(() => {
|
|
823
|
-
if (!enabled || !scrollableAncestors.length || !rect) {
|
|
824
|
-
clearAutoScrollInterval();
|
|
825
|
-
return;
|
|
826
|
-
}
|
|
827
|
-
for (const scrollContainer of sortedScrollableAncestors) {
|
|
828
|
-
if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) continue;
|
|
829
|
-
const scrolllContainerRect = scrollableAncestorRects[scrollableAncestors.indexOf(scrollContainer)];
|
|
830
|
-
if (!scrolllContainerRect) continue;
|
|
831
|
-
const { direction, speed } = getScrollDirectionAndSpeed(scrollContainer, scrolllContainerRect, rect, acceleration, threshold);
|
|
832
|
-
if (speed.x > 0 || speed.y > 0) {
|
|
833
|
-
clearAutoScrollInterval();
|
|
834
|
-
scrollContainerRef.current = scrollContainer;
|
|
835
|
-
setAutoScrollInterval(autoScroll, interval);
|
|
836
|
-
scrollSpeed.current = speed;
|
|
837
|
-
scrollDirection.current = direction;
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
scrollSpeed.current = {
|
|
842
|
-
x: 0,
|
|
843
|
-
y: 0
|
|
844
|
-
};
|
|
845
|
-
scrollDirection.current = {
|
|
846
|
-
x: 0,
|
|
847
|
-
y: 0
|
|
848
|
-
};
|
|
849
|
-
clearAutoScrollInterval();
|
|
850
|
-
}, [
|
|
851
|
-
acceleration,
|
|
852
|
-
autoScroll,
|
|
853
|
-
canScroll,
|
|
854
|
-
clearAutoScrollInterval,
|
|
855
|
-
enabled,
|
|
856
|
-
interval,
|
|
857
|
-
JSON.stringify(rect),
|
|
858
|
-
setAutoScrollInterval,
|
|
859
|
-
scrollableAncestors,
|
|
860
|
-
sortedScrollableAncestors,
|
|
861
|
-
scrollableAncestorRects,
|
|
862
|
-
JSON.stringify(threshold)
|
|
863
|
-
]);
|
|
809
|
+
function getEventListenerTarget(target) {
|
|
810
|
+
const { EventTarget } = getWindow(target);
|
|
811
|
+
return target instanceof EventTarget ? target : getOwnerDocument(target);
|
|
864
812
|
}
|
|
865
|
-
function
|
|
866
|
-
const
|
|
867
|
-
const
|
|
868
|
-
return
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
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;
|
|
873
821
|
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
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();
|
|
883
834
|
}
|
|
884
|
-
function
|
|
885
|
-
|
|
886
|
-
useIsomorphicLayoutEffect(() => {
|
|
887
|
-
if (dataRef.current !== data) dataRef.current = data;
|
|
888
|
-
}, [data]);
|
|
889
|
-
return dataRef;
|
|
835
|
+
function stopPropagation(event) {
|
|
836
|
+
event.stopPropagation();
|
|
890
837
|
}
|
|
891
|
-
var
|
|
892
|
-
(function(
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
var
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
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
|
+
]
|
|
906
857
|
};
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
const { frequency, measure, strategy } = {
|
|
910
|
-
...defaultConfig,
|
|
911
|
-
...config
|
|
912
|
-
};
|
|
913
|
-
const containersRef = (0, import_react.useRef)(containers);
|
|
914
|
-
const recomputeLayouts = (0, import_react.useCallback)(() => setWillRecomputeLayouts(true), []);
|
|
915
|
-
const recomputeLayoutsTimeoutId = (0, import_react.useRef)(null);
|
|
916
|
-
const disabled = isDisabled();
|
|
917
|
-
const layoutRectMap = useLazyMemo((previousValue) => {
|
|
918
|
-
if (disabled && !dragging) return defaultValue;
|
|
919
|
-
if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || willRecomputeLayouts) {
|
|
920
|
-
for (let container of containers) {
|
|
921
|
-
if (!container) continue;
|
|
922
|
-
container.rect.current = container.node.current ? measure(container.node.current) : null;
|
|
923
|
-
}
|
|
924
|
-
return createLayoutRectMap(containers);
|
|
925
|
-
}
|
|
926
|
-
return previousValue;
|
|
927
|
-
}, [
|
|
928
|
-
containers,
|
|
929
|
-
dragging,
|
|
930
|
-
disabled,
|
|
931
|
-
measure,
|
|
932
|
-
willRecomputeLayouts
|
|
933
|
-
]);
|
|
934
|
-
(0, import_react.useEffect)(() => {
|
|
935
|
-
containersRef.current = containers;
|
|
936
|
-
}, [containers]);
|
|
937
|
-
(0, import_react.useEffect)(() => {
|
|
938
|
-
if (willRecomputeLayouts) setWillRecomputeLayouts(false);
|
|
939
|
-
}, [willRecomputeLayouts]);
|
|
940
|
-
(0, import_react.useEffect)(function recompute() {
|
|
941
|
-
if (disabled) return;
|
|
942
|
-
requestAnimationFrame(recomputeLayouts);
|
|
943
|
-
}, [dragging, disabled]);
|
|
944
|
-
(0, import_react.useEffect)(function forceRecomputeLayouts() {
|
|
945
|
-
if (disabled || typeof frequency !== "number" || recomputeLayoutsTimeoutId.current !== null) return;
|
|
946
|
-
recomputeLayoutsTimeoutId.current = setTimeout(() => {
|
|
947
|
-
recomputeLayouts();
|
|
948
|
-
recomputeLayoutsTimeoutId.current = null;
|
|
949
|
-
}, frequency);
|
|
950
|
-
}, [
|
|
951
|
-
frequency,
|
|
952
|
-
disabled,
|
|
953
|
-
recomputeLayouts,
|
|
954
|
-
...dependencies
|
|
955
|
-
]);
|
|
956
|
-
return {
|
|
957
|
-
layoutRectMap,
|
|
958
|
-
recomputeLayouts,
|
|
959
|
-
willRecomputeLayouts
|
|
960
|
-
};
|
|
961
|
-
function isDisabled() {
|
|
962
|
-
switch (strategy) {
|
|
963
|
-
case MeasuringStrategy.Always: return false;
|
|
964
|
-
case MeasuringStrategy.BeforeDragging: return dragging;
|
|
965
|
-
default: return !dragging;
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
function createLayoutRectMap(containers) {
|
|
970
|
-
const layoutRectMap = /* @__PURE__ */ new Map();
|
|
971
|
-
if (containers) for (const container of containers) {
|
|
972
|
-
if (!container) continue;
|
|
973
|
-
const { id, rect } = container;
|
|
974
|
-
if (rect.current == null) continue;
|
|
975
|
-
layoutRectMap.set(id, rect.current);
|
|
976
|
-
}
|
|
977
|
-
return layoutRectMap;
|
|
978
|
-
}
|
|
979
|
-
function useScrollOffsets(elements) {
|
|
980
|
-
const [scrollCoordinates, setScrollCoordinates] = (0, import_react.useState)(null);
|
|
981
|
-
const prevElements = (0, import_react.useRef)(elements);
|
|
982
|
-
const handleScroll = (0, import_react.useCallback)((event) => {
|
|
983
|
-
const scrollingElement = getScrollableElement(event.target);
|
|
984
|
-
if (!scrollingElement) return;
|
|
985
|
-
setScrollCoordinates((scrollCoordinates) => {
|
|
986
|
-
if (!scrollCoordinates) return null;
|
|
987
|
-
scrollCoordinates.set(scrollingElement, getScrollCoordinates(scrollingElement));
|
|
988
|
-
return new Map(scrollCoordinates);
|
|
989
|
-
});
|
|
990
|
-
}, []);
|
|
991
|
-
(0, import_react.useEffect)(() => {
|
|
992
|
-
const previousElements = prevElements.current;
|
|
993
|
-
if (elements !== previousElements) {
|
|
994
|
-
cleanup(previousElements);
|
|
995
|
-
const entries = elements.map((element) => {
|
|
996
|
-
const scrollableElement = getScrollableElement(element);
|
|
997
|
-
if (scrollableElement) {
|
|
998
|
-
scrollableElement.addEventListener("scroll", handleScroll, { passive: true });
|
|
999
|
-
return [scrollableElement, getScrollCoordinates(scrollableElement)];
|
|
1000
|
-
}
|
|
1001
|
-
return null;
|
|
1002
|
-
}).filter((entry) => entry != null);
|
|
1003
|
-
setScrollCoordinates(entries.length ? new Map(entries) : null);
|
|
1004
|
-
prevElements.current = elements;
|
|
1005
|
-
}
|
|
1006
|
-
return () => {
|
|
1007
|
-
cleanup(elements);
|
|
1008
|
-
cleanup(previousElements);
|
|
1009
|
-
};
|
|
1010
|
-
function cleanup(elements) {
|
|
1011
|
-
elements.forEach((element) => {
|
|
1012
|
-
getScrollableElement(element)?.removeEventListener("scroll", handleScroll);
|
|
1013
|
-
});
|
|
1014
|
-
}
|
|
1015
|
-
}, [handleScroll, elements]);
|
|
1016
|
-
return (0, import_react.useMemo)(() => {
|
|
1017
|
-
if (elements.length) return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
|
|
1018
|
-
return defaultCoordinates;
|
|
1019
|
-
}, [elements, scrollCoordinates]);
|
|
1020
|
-
}
|
|
1021
|
-
var defaultValue$1 = [];
|
|
1022
|
-
function useScrollableAncestors(node) {
|
|
1023
|
-
const previousNode = (0, import_react.useRef)(node);
|
|
1024
|
-
const ancestors = useLazyMemo((previousValue) => {
|
|
1025
|
-
if (!node) return defaultValue$1;
|
|
1026
|
-
if (previousValue && node && previousNode.current && node.parentNode === previousNode.current.parentNode) return previousValue;
|
|
1027
|
-
return getScrollableAncestors(node);
|
|
1028
|
-
}, [node]);
|
|
1029
|
-
(0, import_react.useEffect)(() => {
|
|
1030
|
-
previousNode.current = node;
|
|
1031
|
-
}, [node]);
|
|
1032
|
-
return ancestors;
|
|
1033
|
-
}
|
|
1034
|
-
function useSensorSetup(sensors) {
|
|
1035
|
-
(0, import_react.useEffect)(() => {
|
|
1036
|
-
if (!canUseDOM) return;
|
|
1037
|
-
const teardownFns = sensors.map(({ sensor }) => sensor.setup == null ? void 0 : sensor.setup());
|
|
1038
|
-
return () => {
|
|
1039
|
-
for (const teardown of teardownFns) teardown?.();
|
|
1040
|
-
};
|
|
1041
|
-
}, sensors.map(({ sensor }) => sensor));
|
|
1042
|
-
}
|
|
1043
|
-
function useSyntheticListeners(listeners, id) {
|
|
1044
|
-
return (0, import_react.useMemo)(() => {
|
|
1045
|
-
return listeners.reduce((acc, { eventName, handler }) => {
|
|
1046
|
-
acc[eventName] = (event) => {
|
|
1047
|
-
handler(event, id);
|
|
1048
|
-
};
|
|
1049
|
-
return acc;
|
|
1050
|
-
}, {});
|
|
1051
|
-
}, [listeners, id]);
|
|
1052
|
-
}
|
|
1053
|
-
var useClientRect = /* @__PURE__ */ createUseRectFn(getBoundingClientRect);
|
|
1054
|
-
var useClientRects = /* @__PURE__ */ createUseRectsFn(getBoundingClientRect);
|
|
1055
|
-
function useRect(element, getRect, forceRecompute) {
|
|
1056
|
-
const previousElement = (0, import_react.useRef)(element);
|
|
1057
|
-
return useLazyMemo((previousValue) => {
|
|
1058
|
-
if (!element) return null;
|
|
1059
|
-
if (forceRecompute || !previousValue && element || element !== previousElement.current) {
|
|
1060
|
-
if (isHTMLElement(element) && element.parentNode == null) return null;
|
|
1061
|
-
return getRect(element);
|
|
1062
|
-
}
|
|
1063
|
-
return previousValue != null ? previousValue : null;
|
|
1064
|
-
}, [
|
|
1065
|
-
element,
|
|
1066
|
-
forceRecompute,
|
|
1067
|
-
getRect
|
|
1068
|
-
]);
|
|
1069
|
-
}
|
|
1070
|
-
function createUseRectFn(getRect) {
|
|
1071
|
-
return (element, forceRecompute) => useRect(element, getRect, forceRecompute);
|
|
1072
|
-
}
|
|
1073
|
-
function createUseRectsFn(getRect) {
|
|
1074
|
-
const defaultValue = [];
|
|
1075
|
-
return function useRects(elements, forceRecompute) {
|
|
1076
|
-
const previousElements = (0, import_react.useRef)(elements);
|
|
1077
|
-
return useLazyMemo((previousValue) => {
|
|
1078
|
-
if (!elements.length) return defaultValue;
|
|
1079
|
-
if (forceRecompute || !previousValue && elements.length || elements !== previousElements.current) return elements.map((element) => getRect(element));
|
|
1080
|
-
return previousValue != null ? previousValue : defaultValue;
|
|
1081
|
-
}, [elements, forceRecompute]);
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1084
|
-
function getMeasurableNode(node) {
|
|
1085
|
-
if (!node) return null;
|
|
1086
|
-
if (node.children.length > 1) return node;
|
|
1087
|
-
const firstChild = node.children[0];
|
|
1088
|
-
return isHTMLElement(firstChild) ? firstChild : node;
|
|
1089
|
-
}
|
|
1090
|
-
function getDragOverlayRect(element) {
|
|
1091
|
-
const { width, height, offsetLeft, offsetTop } = getLayoutRect(element);
|
|
1092
|
-
return {
|
|
1093
|
-
top: offsetTop,
|
|
1094
|
-
bottom: offsetTop + height,
|
|
1095
|
-
left: offsetLeft,
|
|
1096
|
-
right: offsetLeft + width,
|
|
1097
|
-
width,
|
|
1098
|
-
height,
|
|
1099
|
-
offsetTop,
|
|
1100
|
-
offsetLeft
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
var useDragOverlayRect = /* @__PURE__ */ createUseRectFn(getDragOverlayRect);
|
|
1104
|
-
function useDragOverlayMeasuring({ disabled, forceRecompute }) {
|
|
1105
|
-
const [nodeRef, setRef] = useNodeRef();
|
|
1106
|
-
const rect = useDragOverlayRect(disabled ? null : getMeasurableNode(nodeRef.current), forceRecompute);
|
|
1107
|
-
return (0, import_react.useMemo)(() => ({
|
|
1108
|
-
nodeRef,
|
|
1109
|
-
rect,
|
|
1110
|
-
setRef
|
|
1111
|
-
}), [
|
|
1112
|
-
rect,
|
|
1113
|
-
nodeRef,
|
|
1114
|
-
setRef
|
|
1115
|
-
]);
|
|
1116
|
-
}
|
|
1117
|
-
function useSensor(sensor, options) {
|
|
1118
|
-
return (0, import_react.useMemo)(() => ({
|
|
1119
|
-
sensor,
|
|
1120
|
-
options: options != null ? options : {}
|
|
1121
|
-
}), [sensor, options]);
|
|
1122
|
-
}
|
|
1123
|
-
function useSensors(...sensors) {
|
|
1124
|
-
return (0, import_react.useMemo)(() => [...sensors].filter((sensor) => sensor != null), [...sensors]);
|
|
1125
|
-
}
|
|
1126
|
-
var Listeners = class {
|
|
1127
|
-
constructor(target) {
|
|
1128
|
-
this.target = target;
|
|
1129
|
-
this.listeners = [];
|
|
1130
|
-
this.removeAll = () => {
|
|
1131
|
-
this.listeners.forEach((listener) => {
|
|
1132
|
-
var _this$target;
|
|
1133
|
-
return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
|
|
1134
|
-
});
|
|
1135
|
-
};
|
|
1136
|
-
}
|
|
1137
|
-
add(eventName, handler, options) {
|
|
1138
|
-
var _this$target2;
|
|
1139
|
-
(_this$target2 = this.target) == null || _this$target2.addEventListener(eventName, handler, options);
|
|
1140
|
-
this.listeners.push([
|
|
1141
|
-
eventName,
|
|
1142
|
-
handler,
|
|
1143
|
-
options
|
|
1144
|
-
]);
|
|
1145
|
-
}
|
|
1146
|
-
};
|
|
1147
|
-
function getEventListenerTarget(target) {
|
|
1148
|
-
const { EventTarget } = getWindow(target);
|
|
1149
|
-
return target instanceof EventTarget ? target : getOwnerDocument(target);
|
|
1150
|
-
}
|
|
1151
|
-
function hasExceededDistance(delta, measurement) {
|
|
1152
|
-
const dx = Math.abs(delta.x);
|
|
1153
|
-
const dy = Math.abs(delta.y);
|
|
1154
|
-
if (typeof measurement === "number") return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
|
|
1155
|
-
if ("x" in measurement && "y" in measurement) return dx > measurement.x && dy > measurement.y;
|
|
1156
|
-
if ("x" in measurement) return dx > measurement.x;
|
|
1157
|
-
if ("y" in measurement) return dy > measurement.y;
|
|
1158
|
-
return false;
|
|
1159
|
-
}
|
|
1160
|
-
var EventName;
|
|
1161
|
-
(function(EventName) {
|
|
1162
|
-
EventName["Click"] = "click";
|
|
1163
|
-
EventName["DragStart"] = "dragstart";
|
|
1164
|
-
EventName["Keydown"] = "keydown";
|
|
1165
|
-
EventName["ContextMenu"] = "contextmenu";
|
|
1166
|
-
EventName["Resize"] = "resize";
|
|
1167
|
-
EventName["SelectionChange"] = "selectionchange";
|
|
1168
|
-
EventName["VisibilityChange"] = "visibilitychange";
|
|
1169
|
-
})(EventName || (EventName = {}));
|
|
1170
|
-
function preventDefault(event) {
|
|
1171
|
-
event.preventDefault();
|
|
1172
|
-
}
|
|
1173
|
-
function stopPropagation(event) {
|
|
1174
|
-
event.stopPropagation();
|
|
1175
|
-
}
|
|
1176
|
-
var KeyboardCode;
|
|
1177
|
-
(function(KeyboardCode) {
|
|
1178
|
-
KeyboardCode["Space"] = "Space";
|
|
1179
|
-
KeyboardCode["Down"] = "ArrowDown";
|
|
1180
|
-
KeyboardCode["Right"] = "ArrowRight";
|
|
1181
|
-
KeyboardCode["Left"] = "ArrowLeft";
|
|
1182
|
-
KeyboardCode["Up"] = "ArrowUp";
|
|
1183
|
-
KeyboardCode["Esc"] = "Escape";
|
|
1184
|
-
KeyboardCode["Enter"] = "Enter";
|
|
1185
|
-
})(KeyboardCode || (KeyboardCode = {}));
|
|
1186
|
-
var defaultKeyboardCodes = {
|
|
1187
|
-
start: [KeyboardCode.Space, KeyboardCode.Enter],
|
|
1188
|
-
cancel: [KeyboardCode.Esc],
|
|
1189
|
-
end: [KeyboardCode.Space, KeyboardCode.Enter]
|
|
1190
|
-
};
|
|
1191
|
-
var defaultKeyboardCoordinateGetter = (event, { currentCoordinates }) => {
|
|
858
|
+
var defaultKeyboardCoordinateGetter = (event, _ref) => {
|
|
859
|
+
let { currentCoordinates } = _ref;
|
|
1192
860
|
switch (event.code) {
|
|
1193
861
|
case KeyboardCode.Right: return {
|
|
1194
862
|
...currentCoordinates,
|
|
@@ -1210,9 +878,12 @@ var defaultKeyboardCoordinateGetter = (event, { currentCoordinates }) => {
|
|
|
1210
878
|
};
|
|
1211
879
|
var KeyboardSensor = class {
|
|
1212
880
|
constructor(props) {
|
|
1213
|
-
this.props =
|
|
881
|
+
this.props = void 0;
|
|
1214
882
|
this.autoScrollEnabled = false;
|
|
1215
|
-
this.
|
|
883
|
+
this.referenceCoordinates = void 0;
|
|
884
|
+
this.listeners = void 0;
|
|
885
|
+
this.windowListeners = void 0;
|
|
886
|
+
this.props = props;
|
|
1216
887
|
const { event: { target } } = props;
|
|
1217
888
|
this.props = props;
|
|
1218
889
|
this.listeners = new Listeners(getOwnerDocument(target));
|
|
@@ -1229,18 +900,12 @@ var KeyboardSensor = class {
|
|
|
1229
900
|
}
|
|
1230
901
|
handleStart() {
|
|
1231
902
|
const { activeNode, onStart } = this.props;
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
x: activeNodeRect.left,
|
|
1236
|
-
y: activeNodeRect.top
|
|
1237
|
-
};
|
|
1238
|
-
this.coordinates = coordinates;
|
|
1239
|
-
onStart(coordinates);
|
|
903
|
+
const node = activeNode.node.current;
|
|
904
|
+
if (node) scrollIntoViewIfNeeded(node);
|
|
905
|
+
onStart(defaultCoordinates);
|
|
1240
906
|
}
|
|
1241
907
|
handleKeyDown(event) {
|
|
1242
908
|
if (isKeyboardEvent(event)) {
|
|
1243
|
-
const { coordinates } = this;
|
|
1244
909
|
const { active, context, options } = this.props;
|
|
1245
910
|
const { keyboardCodes = defaultKeyboardCodes, coordinateGetter = defaultKeyboardCoordinateGetter, scrollBehavior = "smooth" } = options;
|
|
1246
911
|
const { code } = event;
|
|
@@ -1252,12 +917,19 @@ var KeyboardSensor = class {
|
|
|
1252
917
|
this.handleCancel(event);
|
|
1253
918
|
return;
|
|
1254
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;
|
|
1255
926
|
const newCoordinates = coordinateGetter(event, {
|
|
1256
927
|
active,
|
|
1257
928
|
context: context.current,
|
|
1258
|
-
currentCoordinates
|
|
929
|
+
currentCoordinates
|
|
1259
930
|
});
|
|
1260
931
|
if (newCoordinates) {
|
|
932
|
+
const coordinatesDelta = subtract(newCoordinates, currentCoordinates);
|
|
1261
933
|
const scrollDelta = {
|
|
1262
934
|
x: 0,
|
|
1263
935
|
y: 0
|
|
@@ -1265,7 +937,6 @@ var KeyboardSensor = class {
|
|
|
1265
937
|
const { scrollableAncestors } = context.current;
|
|
1266
938
|
for (const scrollContainer of scrollableAncestors) {
|
|
1267
939
|
const direction = event.code;
|
|
1268
|
-
const coordinatesDelta = subtract(newCoordinates, coordinates);
|
|
1269
940
|
const { isTop, isRight, isLeft, isBottom, maxScroll, minScroll } = getScrollPosition(scrollContainer);
|
|
1270
941
|
const scrollElementRect = getScrollElementRect(scrollContainer);
|
|
1271
942
|
const clampedCoordinates = {
|
|
@@ -1275,36 +946,42 @@ var KeyboardSensor = class {
|
|
|
1275
946
|
const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft;
|
|
1276
947
|
const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop;
|
|
1277
948
|
if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
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,
|
|
1281
954
|
behavior: scrollBehavior
|
|
1282
955
|
});
|
|
1283
956
|
return;
|
|
1284
957
|
}
|
|
1285
|
-
scrollDelta.x =
|
|
1286
|
-
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({
|
|
1287
961
|
left: -scrollDelta.x,
|
|
1288
962
|
behavior: scrollBehavior
|
|
1289
963
|
});
|
|
1290
964
|
break;
|
|
1291
965
|
} else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
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,
|
|
1295
971
|
behavior: scrollBehavior
|
|
1296
972
|
});
|
|
1297
973
|
return;
|
|
1298
974
|
}
|
|
1299
|
-
scrollDelta.y =
|
|
1300
|
-
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({
|
|
1301
978
|
top: -scrollDelta.y,
|
|
1302
979
|
behavior: scrollBehavior
|
|
1303
980
|
});
|
|
1304
981
|
break;
|
|
1305
982
|
}
|
|
1306
983
|
}
|
|
1307
|
-
this.handleMove(event, add(newCoordinates, scrollDelta));
|
|
984
|
+
this.handleMove(event, add(subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
|
|
1308
985
|
}
|
|
1309
986
|
}
|
|
1310
987
|
}
|
|
@@ -1312,7 +989,6 @@ var KeyboardSensor = class {
|
|
|
1312
989
|
const { onMove } = this.props;
|
|
1313
990
|
event.preventDefault();
|
|
1314
991
|
onMove(coordinates);
|
|
1315
|
-
this.coordinates = coordinates;
|
|
1316
992
|
}
|
|
1317
993
|
handleEnd(event) {
|
|
1318
994
|
const { onEnd } = this.props;
|
|
@@ -1333,9 +1009,13 @@ var KeyboardSensor = class {
|
|
|
1333
1009
|
};
|
|
1334
1010
|
KeyboardSensor.activators = [{
|
|
1335
1011
|
eventName: "onKeyDown",
|
|
1336
|
-
handler: (event,
|
|
1012
|
+
handler: (event, _ref, _ref2) => {
|
|
1013
|
+
let { keyboardCodes = defaultKeyboardCodes, onActivation } = _ref;
|
|
1014
|
+
let { active } = _ref2;
|
|
1337
1015
|
const { code } = event.nativeEvent;
|
|
1338
1016
|
if (keyboardCodes.start.includes(code)) {
|
|
1017
|
+
const activator = active.activatorNode.current;
|
|
1018
|
+
if (activator && event.target !== activator) return false;
|
|
1339
1019
|
event.preventDefault();
|
|
1340
1020
|
onActivation?.({ event: event.nativeEvent });
|
|
1341
1021
|
return true;
|
|
@@ -1350,12 +1030,21 @@ function isDelayConstraint(constraint) {
|
|
|
1350
1030
|
return Boolean(constraint && "delay" in constraint);
|
|
1351
1031
|
}
|
|
1352
1032
|
var AbstractPointerSensor = class {
|
|
1353
|
-
constructor(props, events, listenerTarget
|
|
1354
|
-
|
|
1355
|
-
|
|
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;
|
|
1356
1038
|
this.autoScrollEnabled = true;
|
|
1039
|
+
this.document = void 0;
|
|
1357
1040
|
this.activated = false;
|
|
1041
|
+
this.initialCoordinates = void 0;
|
|
1358
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;
|
|
1359
1048
|
const { event } = props;
|
|
1360
1049
|
const { target } = event;
|
|
1361
1050
|
this.props = props;
|
|
@@ -1364,7 +1053,7 @@ var AbstractPointerSensor = class {
|
|
|
1364
1053
|
this.documentListeners = new Listeners(this.document);
|
|
1365
1054
|
this.listeners = new Listeners(listenerTarget);
|
|
1366
1055
|
this.windowListeners = new Listeners(getWindow(target));
|
|
1367
|
-
this.initialCoordinates = getEventCoordinates(event);
|
|
1056
|
+
this.initialCoordinates = (_getEventCoordinates = getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
|
|
1368
1057
|
this.handleStart = this.handleStart.bind(this);
|
|
1369
1058
|
this.handleMove = this.handleMove.bind(this);
|
|
1370
1059
|
this.handleEnd = this.handleEnd.bind(this);
|
|
@@ -1374,18 +1063,28 @@ var AbstractPointerSensor = class {
|
|
|
1374
1063
|
this.attach();
|
|
1375
1064
|
}
|
|
1376
1065
|
attach() {
|
|
1377
|
-
const { events, props: { options: { activationConstraint } } } = this;
|
|
1066
|
+
const { events, props: { options: { activationConstraint, bypassActivationConstraint } } } = this;
|
|
1378
1067
|
this.listeners.add(events.move.name, this.handleMove, { passive: false });
|
|
1379
1068
|
this.listeners.add(events.end.name, this.handleEnd);
|
|
1069
|
+
if (events.cancel) this.listeners.add(events.cancel.name, this.handleCancel);
|
|
1380
1070
|
this.windowListeners.add(EventName.Resize, this.handleCancel);
|
|
1381
1071
|
this.windowListeners.add(EventName.DragStart, preventDefault);
|
|
1382
1072
|
this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
|
|
1383
1073
|
this.windowListeners.add(EventName.ContextMenu, preventDefault);
|
|
1384
1074
|
this.documentListeners.add(EventName.Keydown, this.handleKeydown);
|
|
1385
1075
|
if (activationConstraint) {
|
|
1386
|
-
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();
|
|
1387
1081
|
if (isDelayConstraint(activationConstraint)) {
|
|
1388
1082
|
this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
|
|
1083
|
+
this.handlePending(activationConstraint);
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
if (isDistanceConstraint(activationConstraint)) {
|
|
1087
|
+
this.handlePending(activationConstraint);
|
|
1389
1088
|
return;
|
|
1390
1089
|
}
|
|
1391
1090
|
}
|
|
@@ -1400,6 +1099,10 @@ var AbstractPointerSensor = class {
|
|
|
1400
1099
|
this.timeoutId = null;
|
|
1401
1100
|
}
|
|
1402
1101
|
}
|
|
1102
|
+
handlePending(constraint, offset) {
|
|
1103
|
+
const { active, onPending } = this.props;
|
|
1104
|
+
onPending(active, constraint, this.initialCoordinates, offset);
|
|
1105
|
+
}
|
|
1403
1106
|
handleStart() {
|
|
1404
1107
|
const { initialCoordinates } = this;
|
|
1405
1108
|
const { onStart } = this.props;
|
|
@@ -1412,33 +1115,36 @@ var AbstractPointerSensor = class {
|
|
|
1412
1115
|
}
|
|
1413
1116
|
}
|
|
1414
1117
|
handleMove(event) {
|
|
1118
|
+
var _getEventCoordinates2;
|
|
1415
1119
|
const { activated, initialCoordinates, props } = this;
|
|
1416
1120
|
const { onMove, options: { activationConstraint } } = props;
|
|
1417
1121
|
if (!initialCoordinates) return;
|
|
1418
|
-
const coordinates = getEventCoordinates(event);
|
|
1122
|
+
const coordinates = (_getEventCoordinates2 = getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
|
|
1419
1123
|
const delta = subtract(initialCoordinates, coordinates);
|
|
1420
1124
|
if (!activated && activationConstraint) {
|
|
1421
|
-
if (isDelayConstraint(activationConstraint)) {
|
|
1422
|
-
if (hasExceededDistance(delta, activationConstraint.tolerance)) return this.handleCancel();
|
|
1423
|
-
return;
|
|
1424
|
-
}
|
|
1425
1125
|
if (isDistanceConstraint(activationConstraint)) {
|
|
1426
1126
|
if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) return this.handleCancel();
|
|
1427
1127
|
if (hasExceededDistance(delta, activationConstraint.distance)) return this.handleStart();
|
|
1428
|
-
return;
|
|
1429
1128
|
}
|
|
1129
|
+
if (isDelayConstraint(activationConstraint)) {
|
|
1130
|
+
if (hasExceededDistance(delta, activationConstraint.tolerance)) return this.handleCancel();
|
|
1131
|
+
}
|
|
1132
|
+
this.handlePending(activationConstraint, delta);
|
|
1133
|
+
return;
|
|
1430
1134
|
}
|
|
1431
1135
|
if (event.cancelable) event.preventDefault();
|
|
1432
1136
|
onMove(coordinates);
|
|
1433
1137
|
}
|
|
1434
1138
|
handleEnd() {
|
|
1435
|
-
const { onEnd } = this.props;
|
|
1139
|
+
const { onAbort, onEnd } = this.props;
|
|
1436
1140
|
this.detach();
|
|
1141
|
+
if (!this.activated) onAbort(this.props.active);
|
|
1437
1142
|
onEnd();
|
|
1438
1143
|
}
|
|
1439
1144
|
handleCancel() {
|
|
1440
|
-
const { onCancel } = this.props;
|
|
1145
|
+
const { onAbort, onCancel } = this.props;
|
|
1441
1146
|
this.detach();
|
|
1147
|
+
if (!this.activated) onAbort(this.props.active);
|
|
1442
1148
|
onCancel();
|
|
1443
1149
|
}
|
|
1444
1150
|
handleKeydown(event) {
|
|
@@ -1450,6 +1156,7 @@ var AbstractPointerSensor = class {
|
|
|
1450
1156
|
}
|
|
1451
1157
|
};
|
|
1452
1158
|
var events = {
|
|
1159
|
+
cancel: { name: "pointercancel" },
|
|
1453
1160
|
move: { name: "pointermove" },
|
|
1454
1161
|
end: { name: "pointerup" }
|
|
1455
1162
|
};
|
|
@@ -1462,7 +1169,9 @@ var PointerSensor = class extends AbstractPointerSensor {
|
|
|
1462
1169
|
};
|
|
1463
1170
|
PointerSensor.activators = [{
|
|
1464
1171
|
eventName: "onPointerDown",
|
|
1465
|
-
handler: (
|
|
1172
|
+
handler: (_ref, _ref2) => {
|
|
1173
|
+
let { nativeEvent: event } = _ref;
|
|
1174
|
+
let { onActivation } = _ref2;
|
|
1466
1175
|
if (!event.isPrimary || event.button !== 0) return false;
|
|
1467
1176
|
onActivation?.({ event });
|
|
1468
1177
|
return true;
|
|
@@ -1483,13 +1192,16 @@ var MouseSensor = class extends AbstractPointerSensor {
|
|
|
1483
1192
|
};
|
|
1484
1193
|
MouseSensor.activators = [{
|
|
1485
1194
|
eventName: "onMouseDown",
|
|
1486
|
-
handler: (
|
|
1195
|
+
handler: (_ref, _ref2) => {
|
|
1196
|
+
let { nativeEvent: event } = _ref;
|
|
1197
|
+
let { onActivation } = _ref2;
|
|
1487
1198
|
if (event.button === MouseButton.RightClick) return false;
|
|
1488
1199
|
onActivation?.({ event });
|
|
1489
1200
|
return true;
|
|
1490
1201
|
}
|
|
1491
1202
|
}];
|
|
1492
1203
|
var events$2 = {
|
|
1204
|
+
cancel: { name: "touchcancel" },
|
|
1493
1205
|
move: { name: "touchmove" },
|
|
1494
1206
|
end: { name: "touchend" }
|
|
1495
1207
|
};
|
|
@@ -1505,49 +1217,796 @@ var TouchSensor = class extends AbstractPointerSensor {
|
|
|
1505
1217
|
return function teardown() {
|
|
1506
1218
|
window.removeEventListener(events$2.move.name, noop);
|
|
1507
1219
|
};
|
|
1508
|
-
function noop() {}
|
|
1509
|
-
}
|
|
1510
|
-
};
|
|
1511
|
-
TouchSensor.activators = [{
|
|
1512
|
-
eventName: "onTouchStart",
|
|
1513
|
-
handler: (
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
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;
|
|
1518
1891
|
}
|
|
1519
|
-
}
|
|
1520
|
-
function
|
|
1521
|
-
|
|
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) => {
|
|
1522
1930
|
return modifier({
|
|
1523
1931
|
transform: accumulator,
|
|
1524
1932
|
...args
|
|
1525
1933
|
});
|
|
1526
1934
|
}, transform) : transform;
|
|
1527
1935
|
}
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
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)({
|
|
1537
1991
|
...defaultCoordinates,
|
|
1538
1992
|
scaleX: 1,
|
|
1539
1993
|
scaleY: 1
|
|
1540
1994
|
});
|
|
1541
|
-
var
|
|
1542
|
-
|
|
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;
|
|
1543
2004
|
const [state, dispatch] = (0, import_react.useReducer)(reducer, void 0, getInitialState);
|
|
1544
|
-
const [
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
}));
|
|
1548
|
-
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;
|
|
1549
2008
|
const { draggable: { active: activeId, nodes: draggableNodes, translate }, droppable: { containers: droppableContainers } } = state;
|
|
1550
|
-
const node = activeId ? draggableNodes
|
|
2009
|
+
const node = activeId != null ? draggableNodes.get(activeId) : null;
|
|
1551
2010
|
const activeRects = (0, import_react.useRef)({
|
|
1552
2011
|
initial: null,
|
|
1553
2012
|
translated: null
|
|
@@ -1563,46 +2022,51 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1563
2022
|
const activeRef = (0, import_react.useRef)(null);
|
|
1564
2023
|
const [activeSensor, setActiveSensor] = (0, import_react.useState)(null);
|
|
1565
2024
|
const [activatorEvent, setActivatorEvent] = (0, import_react.useState)(null);
|
|
1566
|
-
const latestProps = (
|
|
1567
|
-
const draggableDescribedById = useUniqueId(
|
|
1568
|
-
const enabledDroppableContainers = (0, import_react.useMemo)(() =>
|
|
1569
|
-
|
|
1570
|
-
},
|
|
1571
|
-
|
|
1572
|
-
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,
|
|
1573
2031
|
dependencies: [translate.x, translate.y],
|
|
1574
|
-
config:
|
|
2032
|
+
config: measuringConfiguration.droppable
|
|
1575
2033
|
});
|
|
1576
2034
|
const activeNode = useCachedNode(draggableNodes, activeId);
|
|
1577
|
-
const activationCoordinates = activatorEvent ? getEventCoordinates(activatorEvent) : null;
|
|
1578
|
-
const
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1581
|
-
|
|
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);
|
|
1582
2046
|
const sensorContext = (0, import_react.useRef)({
|
|
2047
|
+
activatorEvent: null,
|
|
1583
2048
|
active: null,
|
|
1584
2049
|
activeNode,
|
|
1585
2050
|
collisionRect: null,
|
|
2051
|
+
collisions: null,
|
|
1586
2052
|
droppableRects,
|
|
1587
2053
|
draggableNodes,
|
|
2054
|
+
draggingNode: null,
|
|
1588
2055
|
draggingNodeRect: null,
|
|
1589
2056
|
droppableContainers,
|
|
1590
2057
|
over: null,
|
|
1591
2058
|
scrollableAncestors: [],
|
|
1592
|
-
scrollAdjustedTranslate: null
|
|
1593
|
-
translatedRect: null
|
|
2059
|
+
scrollAdjustedTranslate: null
|
|
1594
2060
|
});
|
|
1595
2061
|
const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
|
|
1596
|
-
const
|
|
1597
|
-
const
|
|
1598
|
-
const
|
|
1599
|
-
const
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
const draggingNodeRect = (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect;
|
|
1605
|
-
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);
|
|
1606
2070
|
const modifiedTranslate = applyModifiers(modifiers, {
|
|
1607
2071
|
transform: {
|
|
1608
2072
|
x: translate.x - nodeRectDelta.x,
|
|
@@ -1612,7 +2076,7 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1612
2076
|
},
|
|
1613
2077
|
activatorEvent,
|
|
1614
2078
|
active,
|
|
1615
|
-
activeNodeRect
|
|
2079
|
+
activeNodeRect,
|
|
1616
2080
|
containerNodeRect,
|
|
1617
2081
|
draggingNodeRect,
|
|
1618
2082
|
over: sensorContext.current.over,
|
|
@@ -1622,50 +2086,88 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1622
2086
|
windowRect
|
|
1623
2087
|
});
|
|
1624
2088
|
const pointerCoordinates = activationCoordinates ? add(activationCoordinates, translate) : null;
|
|
1625
|
-
const
|
|
2089
|
+
const scrollOffsets = useScrollOffsets(scrollableAncestors);
|
|
2090
|
+
const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets);
|
|
2091
|
+
const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
|
|
1626
2092
|
const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);
|
|
1627
|
-
const
|
|
1628
|
-
const
|
|
1629
|
-
const overId = active && collisionRect ? collisionDetection({
|
|
2093
|
+
const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
|
|
2094
|
+
const collisions = active && collisionRect ? collisionDetection({
|
|
1630
2095
|
active,
|
|
1631
2096
|
collisionRect,
|
|
1632
|
-
|
|
2097
|
+
droppableRects,
|
|
2098
|
+
droppableContainers: enabledDroppableContainers,
|
|
2099
|
+
pointerCoordinates
|
|
1633
2100
|
}) : null;
|
|
2101
|
+
const overId = getFirstCollision(collisions, "id");
|
|
1634
2102
|
const [over, setOver] = (0, import_react.useState)(null);
|
|
1635
|
-
const transform = adjustScale(modifiedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
|
|
1636
|
-
const
|
|
1637
|
-
|
|
1638
|
-
|
|
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);
|
|
1639
2109
|
if (!activeNode) return;
|
|
2110
|
+
const activatorEvent = event.nativeEvent;
|
|
1640
2111
|
const sensorInstance = new Sensor({
|
|
1641
2112
|
active: activeRef.current,
|
|
1642
2113
|
activeNode,
|
|
1643
|
-
event:
|
|
2114
|
+
event: activatorEvent,
|
|
1644
2115
|
options,
|
|
1645
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
|
+
},
|
|
1646
2142
|
onStart(initialCoordinates) {
|
|
1647
2143
|
const id = activeRef.current;
|
|
1648
|
-
if (
|
|
1649
|
-
const
|
|
1650
|
-
if (!
|
|
2144
|
+
if (id == null) return;
|
|
2145
|
+
const draggableNode = draggableNodes.get(id);
|
|
2146
|
+
if (!draggableNode) return;
|
|
1651
2147
|
const { onDragStart } = latestProps.current;
|
|
1652
|
-
const event = {
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
2148
|
+
const event = {
|
|
2149
|
+
activatorEvent,
|
|
2150
|
+
active: {
|
|
2151
|
+
id,
|
|
2152
|
+
data: draggableNode.data,
|
|
2153
|
+
rect: activeRects
|
|
2154
|
+
}
|
|
2155
|
+
};
|
|
1657
2156
|
(0, import_react_dom.unstable_batchedUpdates)(() => {
|
|
2157
|
+
onDragStart?.(event);
|
|
2158
|
+
setStatus(Status.Initializing);
|
|
1658
2159
|
dispatch({
|
|
1659
2160
|
type: Action.DragStart,
|
|
1660
2161
|
initialCoordinates,
|
|
1661
2162
|
active: id
|
|
1662
2163
|
});
|
|
1663
|
-
|
|
1664
|
-
type:
|
|
2164
|
+
dispatchMonitorEvent({
|
|
2165
|
+
type: "onDragStart",
|
|
1665
2166
|
event
|
|
1666
2167
|
});
|
|
2168
|
+
setActiveSensor(activeSensorRef.current);
|
|
2169
|
+
setActivatorEvent(activatorEvent);
|
|
1667
2170
|
});
|
|
1668
|
-
onDragStart?.(event);
|
|
1669
2171
|
},
|
|
1670
2172
|
onMove(coordinates) {
|
|
1671
2173
|
dispatch({
|
|
@@ -1676,18 +2178,17 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1676
2178
|
onEnd: createHandler(Action.DragEnd),
|
|
1677
2179
|
onCancel: createHandler(Action.DragCancel)
|
|
1678
2180
|
});
|
|
1679
|
-
|
|
1680
|
-
setActiveSensor(sensorInstance);
|
|
1681
|
-
setActivatorEvent(event.nativeEvent);
|
|
1682
|
-
});
|
|
2181
|
+
activeSensorRef.current = sensorInstance;
|
|
1683
2182
|
function createHandler(type) {
|
|
1684
2183
|
return async function handler() {
|
|
1685
|
-
const { active, over, scrollAdjustedTranslate } = sensorContext.current;
|
|
2184
|
+
const { active, collisions, over, scrollAdjustedTranslate } = sensorContext.current;
|
|
1686
2185
|
let event = null;
|
|
1687
2186
|
if (active && scrollAdjustedTranslate) {
|
|
1688
2187
|
const { cancelDrop } = latestProps.current;
|
|
1689
2188
|
event = {
|
|
2189
|
+
activatorEvent,
|
|
1690
2190
|
active,
|
|
2191
|
+
collisions,
|
|
1691
2192
|
delta: scrollAdjustedTranslate,
|
|
1692
2193
|
over
|
|
1693
2194
|
};
|
|
@@ -1698,65 +2199,66 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1698
2199
|
activeRef.current = null;
|
|
1699
2200
|
(0, import_react_dom.unstable_batchedUpdates)(() => {
|
|
1700
2201
|
dispatch({ type });
|
|
2202
|
+
setStatus(Status.Uninitialized);
|
|
1701
2203
|
setOver(null);
|
|
1702
|
-
setIsDragging(false);
|
|
1703
2204
|
setActiveSensor(null);
|
|
1704
2205
|
setActivatorEvent(null);
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
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
|
+
}
|
|
1709
2216
|
});
|
|
1710
|
-
if (event) {
|
|
1711
|
-
const { onDragCancel, onDragEnd } = latestProps.current;
|
|
1712
|
-
(type === Action.DragEnd ? onDragEnd : onDragCancel)?.(event);
|
|
1713
|
-
}
|
|
1714
2217
|
};
|
|
1715
2218
|
}
|
|
1716
|
-
}, [
|
|
2219
|
+
}, [draggableNodes]);
|
|
1717
2220
|
const activators = useCombineActivators(sensors, (0, import_react.useCallback)((handler, sensor) => {
|
|
1718
2221
|
return (event, active) => {
|
|
1719
2222
|
const nativeEvent = event.nativeEvent;
|
|
1720
|
-
|
|
1721
|
-
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) {
|
|
1722
2227
|
nativeEvent.dndKit = { capturedBy: sensor.sensor };
|
|
1723
2228
|
activeRef.current = active;
|
|
1724
2229
|
instantiateSensor(event, sensor);
|
|
1725
2230
|
}
|
|
1726
2231
|
};
|
|
1727
|
-
}, [instantiateSensor]));
|
|
2232
|
+
}, [draggableNodes, instantiateSensor]));
|
|
1728
2233
|
useSensorSetup(sensors);
|
|
1729
2234
|
useIsomorphicLayoutEffect(() => {
|
|
1730
|
-
|
|
1731
|
-
},
|
|
1732
|
-
(0, import_react.useEffect)(() => {
|
|
1733
|
-
if (activeId != null) setIsDragging(true);
|
|
1734
|
-
}, [activeId]);
|
|
1735
|
-
(0, import_react.useEffect)(() => {
|
|
1736
|
-
if (!active) initialActiveNodeRectRef.current = null;
|
|
1737
|
-
if (active && activeNodeRect && !initialActiveNodeRectRef.current) initialActiveNodeRectRef.current = activeNodeRect;
|
|
1738
|
-
}, [activeNodeRect, active]);
|
|
2235
|
+
if (activeNodeRect && status === Status.Initializing) setStatus(Status.Initialized);
|
|
2236
|
+
}, [activeNodeRect, status]);
|
|
1739
2237
|
(0, import_react.useEffect)(() => {
|
|
1740
2238
|
const { onDragMove } = latestProps.current;
|
|
1741
|
-
const { active, over } = sensorContext.current;
|
|
1742
|
-
if (!active) return;
|
|
2239
|
+
const { active, activatorEvent, collisions, over } = sensorContext.current;
|
|
2240
|
+
if (!active || !activatorEvent) return;
|
|
1743
2241
|
const event = {
|
|
1744
2242
|
active,
|
|
2243
|
+
activatorEvent,
|
|
2244
|
+
collisions,
|
|
1745
2245
|
delta: {
|
|
1746
2246
|
x: scrollAdjustedTranslate.x,
|
|
1747
2247
|
y: scrollAdjustedTranslate.y
|
|
1748
2248
|
},
|
|
1749
2249
|
over
|
|
1750
2250
|
};
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
2251
|
+
(0, import_react_dom.unstable_batchedUpdates)(() => {
|
|
2252
|
+
onDragMove?.(event);
|
|
2253
|
+
dispatchMonitorEvent({
|
|
2254
|
+
type: "onDragMove",
|
|
2255
|
+
event
|
|
2256
|
+
});
|
|
1754
2257
|
});
|
|
1755
|
-
onDragMove?.(event);
|
|
1756
2258
|
}, [scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]);
|
|
1757
2259
|
(0, import_react.useEffect)(() => {
|
|
1758
|
-
const { active, droppableContainers, scrollAdjustedTranslate } = sensorContext.current;
|
|
1759
|
-
if (!active ||
|
|
2260
|
+
const { active, activatorEvent, collisions, droppableContainers, scrollAdjustedTranslate } = sensorContext.current;
|
|
2261
|
+
if (!active || activeRef.current == null || !activatorEvent || !scrollAdjustedTranslate) return;
|
|
1760
2262
|
const { onDragOver } = latestProps.current;
|
|
1761
2263
|
const overContainer = droppableContainers.get(overId);
|
|
1762
2264
|
const over = overContainer && overContainer.rect.current ? {
|
|
@@ -1767,6 +2269,8 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1767
2269
|
} : null;
|
|
1768
2270
|
const event = {
|
|
1769
2271
|
active,
|
|
2272
|
+
activatorEvent,
|
|
2273
|
+
collisions,
|
|
1770
2274
|
delta: {
|
|
1771
2275
|
x: scrollAdjustedTranslate.x,
|
|
1772
2276
|
y: scrollAdjustedTranslate.y
|
|
@@ -1775,103 +2279,125 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1775
2279
|
};
|
|
1776
2280
|
(0, import_react_dom.unstable_batchedUpdates)(() => {
|
|
1777
2281
|
setOver(over);
|
|
1778
|
-
|
|
1779
|
-
|
|
2282
|
+
onDragOver?.(event);
|
|
2283
|
+
dispatchMonitorEvent({
|
|
2284
|
+
type: "onDragOver",
|
|
1780
2285
|
event
|
|
1781
2286
|
});
|
|
1782
|
-
onDragOver?.(event);
|
|
1783
2287
|
});
|
|
1784
2288
|
}, [overId]);
|
|
1785
2289
|
useIsomorphicLayoutEffect(() => {
|
|
1786
2290
|
sensorContext.current = {
|
|
2291
|
+
activatorEvent,
|
|
1787
2292
|
active,
|
|
1788
2293
|
activeNode,
|
|
1789
2294
|
collisionRect,
|
|
2295
|
+
collisions,
|
|
1790
2296
|
droppableRects,
|
|
1791
2297
|
draggableNodes,
|
|
2298
|
+
draggingNode,
|
|
1792
2299
|
draggingNodeRect,
|
|
1793
2300
|
droppableContainers,
|
|
1794
2301
|
over,
|
|
1795
2302
|
scrollableAncestors,
|
|
1796
|
-
scrollAdjustedTranslate
|
|
1797
|
-
translatedRect
|
|
2303
|
+
scrollAdjustedTranslate
|
|
1798
2304
|
};
|
|
1799
2305
|
activeRects.current = {
|
|
1800
2306
|
initial: draggingNodeRect,
|
|
1801
|
-
translated:
|
|
2307
|
+
translated: collisionRect
|
|
1802
2308
|
};
|
|
1803
2309
|
}, [
|
|
1804
2310
|
active,
|
|
1805
2311
|
activeNode,
|
|
2312
|
+
collisions,
|
|
1806
2313
|
collisionRect,
|
|
1807
2314
|
draggableNodes,
|
|
2315
|
+
draggingNode,
|
|
1808
2316
|
draggingNodeRect,
|
|
1809
2317
|
droppableRects,
|
|
1810
2318
|
droppableContainers,
|
|
1811
2319
|
over,
|
|
1812
2320
|
scrollableAncestors,
|
|
1813
|
-
scrollAdjustedTranslate
|
|
1814
|
-
translatedRect
|
|
2321
|
+
scrollAdjustedTranslate
|
|
1815
2322
|
]);
|
|
1816
2323
|
useAutoScroller({
|
|
1817
|
-
...
|
|
1818
|
-
|
|
2324
|
+
...autoScrollOptions,
|
|
2325
|
+
delta: translate,
|
|
2326
|
+
draggingRect: collisionRect,
|
|
1819
2327
|
pointerCoordinates,
|
|
1820
2328
|
scrollableAncestors,
|
|
1821
2329
|
scrollableAncestorRects
|
|
1822
2330
|
});
|
|
1823
|
-
const
|
|
2331
|
+
const publicContext = (0, import_react.useMemo)(() => {
|
|
1824
2332
|
return {
|
|
1825
2333
|
active,
|
|
1826
2334
|
activeNode,
|
|
1827
2335
|
activeNodeRect,
|
|
1828
|
-
activeNodeClientRect,
|
|
1829
2336
|
activatorEvent,
|
|
1830
|
-
|
|
1831
|
-
ariaDescribedById: { draggable: draggableDescribedById },
|
|
2337
|
+
collisions,
|
|
1832
2338
|
containerNodeRect,
|
|
1833
|
-
dispatch,
|
|
1834
2339
|
dragOverlay,
|
|
1835
2340
|
draggableNodes,
|
|
1836
2341
|
droppableContainers,
|
|
1837
2342
|
droppableRects,
|
|
1838
2343
|
over,
|
|
1839
|
-
|
|
2344
|
+
measureDroppableContainers,
|
|
1840
2345
|
scrollableAncestors,
|
|
1841
2346
|
scrollableAncestorRects,
|
|
1842
|
-
|
|
2347
|
+
measuringConfiguration,
|
|
2348
|
+
measuringScheduled,
|
|
1843
2349
|
windowRect
|
|
1844
2350
|
};
|
|
1845
2351
|
}, [
|
|
1846
2352
|
active,
|
|
1847
2353
|
activeNode,
|
|
1848
|
-
activeNodeClientRect,
|
|
1849
2354
|
activeNodeRect,
|
|
1850
2355
|
activatorEvent,
|
|
1851
|
-
|
|
2356
|
+
collisions,
|
|
1852
2357
|
containerNodeRect,
|
|
1853
2358
|
dragOverlay,
|
|
1854
|
-
dispatch,
|
|
1855
2359
|
draggableNodes,
|
|
1856
|
-
draggableDescribedById,
|
|
1857
2360
|
droppableContainers,
|
|
1858
2361
|
droppableRects,
|
|
1859
2362
|
over,
|
|
1860
|
-
|
|
2363
|
+
measureDroppableContainers,
|
|
1861
2364
|
scrollableAncestors,
|
|
1862
2365
|
scrollableAncestorRects,
|
|
1863
|
-
|
|
2366
|
+
measuringConfiguration,
|
|
2367
|
+
measuringScheduled,
|
|
1864
2368
|
windowRect
|
|
1865
2369
|
]);
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
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
|
|
1870
2396
|
}));
|
|
1871
2397
|
function getAutoScrollerOptions() {
|
|
1872
2398
|
const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
|
|
1873
2399
|
const autoScrollGloballyDisabled = typeof autoScroll === "object" ? autoScroll.enabled === false : autoScroll === false;
|
|
1874
|
-
const enabled = !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
|
|
2400
|
+
const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
|
|
1875
2401
|
if (typeof autoScroll === "object") return {
|
|
1876
2402
|
...autoScroll,
|
|
1877
2403
|
enabled
|
|
@@ -1879,67 +2405,109 @@ var DndContext = /* @__PURE__ */ (0, import_react.memo)(function DndContext({ id
|
|
|
1879
2405
|
return { enabled };
|
|
1880
2406
|
}
|
|
1881
2407
|
});
|
|
1882
|
-
var NullContext =
|
|
2408
|
+
var NullContext = /*#__PURE__*/ (0, import_react.createContext)(null);
|
|
1883
2409
|
var defaultRole = "button";
|
|
1884
|
-
var ID_PREFIX$
|
|
1885
|
-
function useDraggable(
|
|
1886
|
-
|
|
1887
|
-
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);
|
|
1888
2415
|
const { role = defaultRole, roleDescription = "draggable", tabIndex = 0 } = attributes != null ? attributes : {};
|
|
1889
2416
|
const isDragging = (active == null ? void 0 : active.id) === id;
|
|
1890
2417
|
const transform = (0, import_react.useContext)(isDragging ? ActiveDraggableContext : NullContext);
|
|
1891
2418
|
const [node, setNodeRef] = useNodeRef();
|
|
2419
|
+
const [activatorNode, setActivatorNodeRef] = useNodeRef();
|
|
1892
2420
|
const listeners = useSyntheticListeners(activators, id);
|
|
1893
|
-
const dataRef =
|
|
1894
|
-
(
|
|
1895
|
-
draggableNodes
|
|
2421
|
+
const dataRef = useLatestValue(data);
|
|
2422
|
+
useIsomorphicLayoutEffect(() => {
|
|
2423
|
+
draggableNodes.set(id, {
|
|
1896
2424
|
id,
|
|
1897
2425
|
key,
|
|
1898
2426
|
node,
|
|
2427
|
+
activatorNode,
|
|
1899
2428
|
data: dataRef
|
|
1900
|
-
};
|
|
2429
|
+
});
|
|
1901
2430
|
return () => {
|
|
1902
|
-
const node = draggableNodes
|
|
1903
|
-
if (node && node.key === key) delete
|
|
2431
|
+
const node = draggableNodes.get(id);
|
|
2432
|
+
if (node && node.key === key) draggableNodes.delete(id);
|
|
1904
2433
|
};
|
|
1905
2434
|
}, [draggableNodes, id]);
|
|
1906
2435
|
return {
|
|
1907
2436
|
active,
|
|
1908
|
-
activeNodeRect,
|
|
1909
2437
|
activatorEvent,
|
|
2438
|
+
activeNodeRect,
|
|
1910
2439
|
attributes: (0, import_react.useMemo)(() => ({
|
|
1911
2440
|
role,
|
|
1912
2441
|
tabIndex,
|
|
2442
|
+
"aria-disabled": disabled,
|
|
1913
2443
|
"aria-pressed": isDragging && role === defaultRole ? true : void 0,
|
|
1914
2444
|
"aria-roledescription": roleDescription,
|
|
1915
2445
|
"aria-describedby": ariaDescribedById.draggable
|
|
1916
2446
|
}), [
|
|
2447
|
+
disabled,
|
|
1917
2448
|
role,
|
|
1918
2449
|
tabIndex,
|
|
1919
2450
|
isDragging,
|
|
1920
2451
|
roleDescription,
|
|
1921
2452
|
ariaDescribedById.draggable
|
|
1922
2453
|
]),
|
|
1923
|
-
droppableRects,
|
|
1924
2454
|
isDragging,
|
|
1925
2455
|
listeners: disabled ? void 0 : listeners,
|
|
1926
2456
|
node,
|
|
1927
2457
|
over,
|
|
1928
2458
|
setNodeRef,
|
|
2459
|
+
setActivatorNodeRef,
|
|
1929
2460
|
transform
|
|
1930
2461
|
};
|
|
1931
2462
|
}
|
|
1932
2463
|
function useDndContext() {
|
|
1933
|
-
return (0, import_react.useContext)(
|
|
2464
|
+
return (0, import_react.useContext)(PublicContext);
|
|
1934
2465
|
}
|
|
1935
|
-
var ID_PREFIX$1
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
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);
|
|
1939
2474
|
const rect = (0, import_react.useRef)(null);
|
|
1940
|
-
const
|
|
1941
|
-
const
|
|
1942
|
-
|
|
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)(() => {
|
|
1943
2511
|
dispatch({
|
|
1944
2512
|
type: Action.RegisterDroppable,
|
|
1945
2513
|
element: {
|
|
@@ -1958,13 +2526,21 @@ function useDroppable({ data, disabled = false, id }) {
|
|
|
1958
2526
|
});
|
|
1959
2527
|
}, [id]);
|
|
1960
2528
|
(0, import_react.useEffect)(() => {
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
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
|
+
]);
|
|
1968
2544
|
return {
|
|
1969
2545
|
active,
|
|
1970
2546
|
rect,
|
|
@@ -1975,7 +2551,7 @@ function useDroppable({ data, disabled = false, id }) {
|
|
|
1975
2551
|
};
|
|
1976
2552
|
}
|
|
1977
2553
|
//#endregion
|
|
1978
|
-
//#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
|
|
1979
2555
|
/**
|
|
1980
2556
|
* Move an array item to a different position. Returns a new array with the item moved to the new position.
|
|
1981
2557
|
*/
|
|
@@ -1984,30 +2560,44 @@ function arrayMove(array, from, to) {
|
|
|
1984
2560
|
newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
|
|
1985
2561
|
return newArray;
|
|
1986
2562
|
}
|
|
1987
|
-
function getSortedRects(items,
|
|
2563
|
+
function getSortedRects(items, rects) {
|
|
1988
2564
|
return items.reduce((accumulator, id, index) => {
|
|
1989
|
-
const
|
|
1990
|
-
if (
|
|
2565
|
+
const rect = rects.get(id);
|
|
2566
|
+
if (rect) accumulator[index] = rect;
|
|
1991
2567
|
return accumulator;
|
|
1992
2568
|
}, Array(items.length));
|
|
1993
2569
|
}
|
|
1994
2570
|
function isValidIndex(index) {
|
|
1995
2571
|
return index !== null && index >= 0;
|
|
1996
2572
|
}
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
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];
|
|
2000
2590
|
const newRect = newRects[index];
|
|
2001
2591
|
if (!newRect || !oldRect) return null;
|
|
2002
2592
|
return {
|
|
2003
|
-
x: newRect.
|
|
2004
|
-
y: newRect.
|
|
2593
|
+
x: newRect.left - oldRect.left,
|
|
2594
|
+
y: newRect.top - oldRect.top,
|
|
2005
2595
|
scaleX: newRect.width / oldRect.width,
|
|
2006
2596
|
scaleY: newRect.height / oldRect.height
|
|
2007
2597
|
};
|
|
2008
2598
|
};
|
|
2009
2599
|
var ID_PREFIX = "Sortable";
|
|
2010
|
-
var Context =
|
|
2600
|
+
var Context = /*#__PURE__*/ import_react.createContext({
|
|
2011
2601
|
activeIndex: -1,
|
|
2012
2602
|
containerId: ID_PREFIX,
|
|
2013
2603
|
disableTransforms: false,
|
|
@@ -2016,67 +2606,65 @@ var Context = /* @__PURE__ */ import_react.createContext({
|
|
|
2016
2606
|
useDragOverlay: false,
|
|
2017
2607
|
sortedRects: [],
|
|
2018
2608
|
strategy: rectSortingStrategy,
|
|
2019
|
-
|
|
2609
|
+
disabled: {
|
|
2610
|
+
draggable: false,
|
|
2611
|
+
droppable: false
|
|
2612
|
+
}
|
|
2020
2613
|
});
|
|
2021
|
-
function SortableContext(
|
|
2022
|
-
|
|
2614
|
+
function SortableContext(_ref) {
|
|
2615
|
+
let { children, id, items: userDefinedItems, strategy = rectSortingStrategy, disabled: disabledProp = false } = _ref;
|
|
2616
|
+
const { active, dragOverlay, droppableRects, over, measureDroppableContainers } = useDndContext();
|
|
2023
2617
|
const containerId = useUniqueId(ID_PREFIX, id);
|
|
2024
2618
|
const useDragOverlay = Boolean(dragOverlay.rect !== null);
|
|
2025
|
-
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]);
|
|
2026
2620
|
const isDragging = active != null;
|
|
2027
|
-
const wasDragging = (0, import_react.useRef)(false);
|
|
2028
2621
|
const activeIndex = active ? items.indexOf(active.id) : -1;
|
|
2029
|
-
const isSorting = activeIndex !== -1;
|
|
2030
2622
|
const overIndex = over ? items.indexOf(over.id) : -1;
|
|
2031
2623
|
const previousItemsRef = (0, import_react.useRef)(items);
|
|
2032
|
-
const
|
|
2033
|
-
const itemsHaveChanged = !isEqual(items, previousItemsRef.current);
|
|
2624
|
+
const itemsHaveChanged = !itemsEqual(items, previousItemsRef.current);
|
|
2034
2625
|
const disableTransforms = overIndex !== -1 && activeIndex === -1 || itemsHaveChanged;
|
|
2626
|
+
const disabled = normalizeDisabled(disabledProp);
|
|
2035
2627
|
useIsomorphicLayoutEffect(() => {
|
|
2036
|
-
if (itemsHaveChanged &&
|
|
2628
|
+
if (itemsHaveChanged && isDragging) measureDroppableContainers(items);
|
|
2037
2629
|
}, [
|
|
2038
2630
|
itemsHaveChanged,
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2631
|
+
items,
|
|
2632
|
+
isDragging,
|
|
2633
|
+
measureDroppableContainers
|
|
2042
2634
|
]);
|
|
2043
2635
|
(0, import_react.useEffect)(() => {
|
|
2044
2636
|
previousItemsRef.current = items;
|
|
2045
2637
|
}, [items]);
|
|
2046
|
-
(0, import_react.useEffect)(() => {
|
|
2047
|
-
const timeoutId = setTimeout(() => {
|
|
2048
|
-
wasDragging.current = isDragging;
|
|
2049
|
-
}, 100);
|
|
2050
|
-
return () => clearTimeout(timeoutId);
|
|
2051
|
-
}, [isDragging]);
|
|
2052
2638
|
const contextValue = (0, import_react.useMemo)(() => ({
|
|
2053
2639
|
activeIndex,
|
|
2054
2640
|
containerId,
|
|
2641
|
+
disabled,
|
|
2055
2642
|
disableTransforms,
|
|
2056
2643
|
items,
|
|
2057
2644
|
overIndex,
|
|
2058
2645
|
useDragOverlay,
|
|
2059
|
-
sortedRects,
|
|
2060
|
-
strategy
|
|
2061
|
-
wasDragging
|
|
2646
|
+
sortedRects: getSortedRects(items, droppableRects),
|
|
2647
|
+
strategy
|
|
2062
2648
|
}), [
|
|
2063
2649
|
activeIndex,
|
|
2064
2650
|
containerId,
|
|
2651
|
+
disabled.draggable,
|
|
2652
|
+
disabled.droppable,
|
|
2065
2653
|
disableTransforms,
|
|
2066
2654
|
items,
|
|
2067
2655
|
overIndex,
|
|
2068
|
-
|
|
2656
|
+
droppableRects,
|
|
2069
2657
|
useDragOverlay,
|
|
2070
|
-
strategy
|
|
2071
|
-
wasDragging
|
|
2658
|
+
strategy
|
|
2072
2659
|
]);
|
|
2073
2660
|
return import_react.createElement(Context.Provider, { value: contextValue }, children);
|
|
2074
2661
|
}
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
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;
|
|
2080
2668
|
if (!transition || !wasDragging) return false;
|
|
2081
2669
|
if (previousItems !== items && index === newIndex) return false;
|
|
2082
2670
|
if (isSorting) return true;
|
|
@@ -2087,23 +2675,24 @@ var defaultTransition = {
|
|
|
2087
2675
|
easing: "ease"
|
|
2088
2676
|
};
|
|
2089
2677
|
var transitionProperty = "transform";
|
|
2090
|
-
var disabledTransition =
|
|
2678
|
+
var disabledTransition = /*#__PURE__*/ CSS.Transition.toString({
|
|
2091
2679
|
property: transitionProperty,
|
|
2092
2680
|
duration: 0,
|
|
2093
2681
|
easing: "linear"
|
|
2094
2682
|
});
|
|
2095
2683
|
var defaultAttributes = { roleDescription: "sortable" };
|
|
2096
|
-
function useDerivedTransform(
|
|
2684
|
+
function useDerivedTransform(_ref) {
|
|
2685
|
+
let { disabled, index, node, rect } = _ref;
|
|
2097
2686
|
const [derivedTransform, setDerivedtransform] = (0, import_react.useState)(null);
|
|
2098
2687
|
const previousIndex = (0, import_react.useRef)(index);
|
|
2099
2688
|
useIsomorphicLayoutEffect(() => {
|
|
2100
2689
|
if (!disabled && index !== previousIndex.current && node.current) {
|
|
2101
2690
|
const initial = rect.current;
|
|
2102
2691
|
if (initial) {
|
|
2103
|
-
const current =
|
|
2692
|
+
const current = getClientRect(node.current, { ignoreTransform: true });
|
|
2104
2693
|
const delta = {
|
|
2105
|
-
x: initial.
|
|
2106
|
-
y: initial.
|
|
2694
|
+
x: initial.left - current.left,
|
|
2695
|
+
y: initial.top - current.top,
|
|
2107
2696
|
scaleX: initial.width / current.width,
|
|
2108
2697
|
scaleY: initial.height / current.height
|
|
2109
2698
|
};
|
|
@@ -2118,14 +2707,14 @@ function useDerivedTransform({ disabled, index, node, rect }) {
|
|
|
2118
2707
|
rect
|
|
2119
2708
|
]);
|
|
2120
2709
|
(0, import_react.useEffect)(() => {
|
|
2121
|
-
if (derivedTransform)
|
|
2122
|
-
setDerivedtransform(null);
|
|
2123
|
-
});
|
|
2710
|
+
if (derivedTransform) setDerivedtransform(null);
|
|
2124
2711
|
}, [derivedTransform]);
|
|
2125
2712
|
return derivedTransform;
|
|
2126
2713
|
}
|
|
2127
|
-
function useSortable(
|
|
2128
|
-
|
|
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);
|
|
2129
2718
|
const index = items.indexOf(id);
|
|
2130
2719
|
const data = (0, import_react.useMemo)(() => ({
|
|
2131
2720
|
sortable: {
|
|
@@ -2140,26 +2729,32 @@ function useSortable({ animateLayoutChanges = defaultAnimateLayoutChanges, attri
|
|
|
2140
2729
|
index,
|
|
2141
2730
|
items
|
|
2142
2731
|
]);
|
|
2143
|
-
const
|
|
2732
|
+
const itemsAfterCurrentSortable = (0, import_react.useMemo)(() => items.slice(items.indexOf(id)), [items, id]);
|
|
2733
|
+
const { rect, node, isOver, setNodeRef: setDroppableNodeRef } = useDroppable({
|
|
2144
2734
|
id,
|
|
2145
|
-
data
|
|
2735
|
+
data,
|
|
2736
|
+
disabled: disabled.droppable,
|
|
2737
|
+
resizeObserverConfig: {
|
|
2738
|
+
updateMeasurementsFor: itemsAfterCurrentSortable,
|
|
2739
|
+
...resizeObserverConfig
|
|
2740
|
+
}
|
|
2146
2741
|
});
|
|
2147
|
-
const { active,
|
|
2742
|
+
const { active, activatorEvent, activeNodeRect, attributes, setNodeRef: setDraggableNodeRef, listeners, isDragging, over, setActivatorNodeRef, transform } = useDraggable({
|
|
2148
2743
|
id,
|
|
2149
2744
|
data,
|
|
2150
2745
|
attributes: {
|
|
2151
2746
|
...defaultAttributes,
|
|
2152
2747
|
...userDefinedAttributes
|
|
2153
2748
|
},
|
|
2154
|
-
disabled
|
|
2749
|
+
disabled: disabled.draggable
|
|
2155
2750
|
});
|
|
2156
2751
|
const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
2157
2752
|
const isSorting = Boolean(active);
|
|
2158
|
-
const displaceItem = isSorting &&
|
|
2753
|
+
const displaceItem = isSorting && !disableTransforms && isValidIndex(activeIndex) && isValidIndex(overIndex);
|
|
2159
2754
|
const shouldDisplaceDragSource = !useDragOverlay && isDragging;
|
|
2160
2755
|
const dragSourceDisplacement = shouldDisplaceDragSource && displaceItem ? transform : null;
|
|
2161
2756
|
const finalTransform = displaceItem ? dragSourceDisplacement != null ? dragSourceDisplacement : (localStrategy != null ? localStrategy : globalStrategy)({
|
|
2162
|
-
|
|
2757
|
+
rects: sortedRects,
|
|
2163
2758
|
activeNodeRect,
|
|
2164
2759
|
activeIndex,
|
|
2165
2760
|
overIndex,
|
|
@@ -2171,10 +2766,14 @@ function useSortable({ animateLayoutChanges = defaultAnimateLayoutChanges, attri
|
|
|
2171
2766
|
activeIndex,
|
|
2172
2767
|
overIndex
|
|
2173
2768
|
}) : index;
|
|
2174
|
-
const
|
|
2175
|
-
const
|
|
2176
|
-
|
|
2177
|
-
|
|
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;
|
|
2178
2777
|
const shouldAnimateLayoutChanges = animateLayoutChanges({
|
|
2179
2778
|
active,
|
|
2180
2779
|
containerId,
|
|
@@ -2183,11 +2782,11 @@ function useSortable({ animateLayoutChanges = defaultAnimateLayoutChanges, attri
|
|
|
2183
2782
|
id,
|
|
2184
2783
|
index,
|
|
2185
2784
|
items,
|
|
2186
|
-
newIndex:
|
|
2187
|
-
previousItems:
|
|
2188
|
-
previousContainerId:
|
|
2785
|
+
newIndex: previous.current.newIndex,
|
|
2786
|
+
previousItems: previous.current.items,
|
|
2787
|
+
previousContainerId: previous.current.containerId,
|
|
2189
2788
|
transition,
|
|
2190
|
-
wasDragging:
|
|
2789
|
+
wasDragging: previous.current.activeId != null
|
|
2191
2790
|
});
|
|
2192
2791
|
const derivedTransform = useDerivedTransform({
|
|
2193
2792
|
disabled: !shouldAnimateLayoutChanges,
|
|
@@ -2196,21 +2795,36 @@ function useSortable({ animateLayoutChanges = defaultAnimateLayoutChanges, attri
|
|
|
2196
2795
|
rect
|
|
2197
2796
|
});
|
|
2198
2797
|
(0, import_react.useEffect)(() => {
|
|
2199
|
-
if (isSorting &&
|
|
2200
|
-
if (containerId !==
|
|
2201
|
-
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;
|
|
2202
2801
|
}, [
|
|
2203
2802
|
isSorting,
|
|
2204
2803
|
newIndex,
|
|
2205
2804
|
containerId,
|
|
2206
2805
|
items
|
|
2207
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]);
|
|
2208
2818
|
return {
|
|
2209
2819
|
active,
|
|
2820
|
+
activeIndex,
|
|
2210
2821
|
attributes,
|
|
2211
|
-
|
|
2822
|
+
data,
|
|
2212
2823
|
rect,
|
|
2213
2824
|
index,
|
|
2825
|
+
newIndex,
|
|
2826
|
+
items,
|
|
2827
|
+
isOver,
|
|
2214
2828
|
isSorting,
|
|
2215
2829
|
isDragging,
|
|
2216
2830
|
listeners,
|
|
@@ -2218,46 +2832,69 @@ function useSortable({ animateLayoutChanges = defaultAnimateLayoutChanges, attri
|
|
|
2218
2832
|
overIndex,
|
|
2219
2833
|
over,
|
|
2220
2834
|
setNodeRef,
|
|
2835
|
+
setActivatorNodeRef,
|
|
2221
2836
|
setDroppableNodeRef,
|
|
2222
2837
|
setDraggableNodeRef,
|
|
2223
2838
|
transform: derivedTransform != null ? derivedTransform : finalTransform,
|
|
2224
2839
|
transition: getTransition()
|
|
2225
2840
|
};
|
|
2226
2841
|
function getTransition() {
|
|
2227
|
-
if (derivedTransform || itemsHaveChanged &&
|
|
2228
|
-
if (shouldDisplaceDragSource || !transition) return;
|
|
2842
|
+
if (derivedTransform || itemsHaveChanged && previous.current.newIndex === index) return disabledTransition;
|
|
2843
|
+
if (shouldDisplaceDragSource && !isKeyboardEvent(activatorEvent) || !transition) return;
|
|
2229
2844
|
if (isSorting || shouldAnimateLayoutChanges) return CSS.Transition.toString({
|
|
2230
2845
|
...transition,
|
|
2231
2846
|
property: transitionProperty
|
|
2232
2847
|
});
|
|
2233
2848
|
}
|
|
2234
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
|
+
}
|
|
2235
2861
|
KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left;
|
|
2236
2862
|
//#endregion
|
|
2237
2863
|
//#region ~icons/lucide/gauge.jsx
|
|
2238
2864
|
var import_jsx_runtime = require_jsx_runtime();
|
|
2239
|
-
var lucideGauge = (props) => /* @__PURE__ */ (0, import_jsx_runtime.
|
|
2865
|
+
var lucideGauge = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
|
|
2240
2866
|
viewBox: "0 0 24 24",
|
|
2241
2867
|
width: "1.2em",
|
|
2242
2868
|
height: "1.2em",
|
|
2869
|
+
ref,
|
|
2870
|
+
"aria-labelledby": titleId,
|
|
2243
2871
|
...props,
|
|
2244
|
-
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", {
|
|
2245
2876
|
fill: "none",
|
|
2246
2877
|
stroke: "currentColor",
|
|
2247
2878
|
strokeLinecap: "round",
|
|
2248
2879
|
strokeLinejoin: "round",
|
|
2249
2880
|
strokeWidth: 2,
|
|
2250
2881
|
d: "m12 14l4-4M3.34 19a10 10 0 1 1 17.32 0"
|
|
2251
|
-
})
|
|
2882
|
+
})]
|
|
2252
2883
|
});
|
|
2884
|
+
var ForwardRef$1 = (0, import_react.forwardRef)(lucideGauge);
|
|
2253
2885
|
//#endregion
|
|
2254
2886
|
//#region ~icons/lucide/grip-vertical.jsx
|
|
2255
|
-
var lucideGripVertical = (props) => /* @__PURE__ */ (0, import_jsx_runtime.
|
|
2887
|
+
var lucideGripVertical = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
|
|
2256
2888
|
viewBox: "0 0 24 24",
|
|
2257
2889
|
width: "1.2em",
|
|
2258
2890
|
height: "1.2em",
|
|
2891
|
+
ref,
|
|
2892
|
+
"aria-labelledby": titleId,
|
|
2259
2893
|
...props,
|
|
2260
|
-
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", {
|
|
2261
2898
|
fill: "none",
|
|
2262
2899
|
stroke: "currentColor",
|
|
2263
2900
|
strokeLinecap: "round",
|
|
@@ -2295,11 +2932,12 @@ var lucideGripVertical = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
|
2295
2932
|
r: 1
|
|
2296
2933
|
})
|
|
2297
2934
|
]
|
|
2298
|
-
})
|
|
2935
|
+
})]
|
|
2299
2936
|
});
|
|
2937
|
+
var ForwardRef = (0, import_react.forwardRef)(lucideGripVertical);
|
|
2300
2938
|
//#endregion
|
|
2301
2939
|
//#region src/components/qgrid/UsageCard.tsx
|
|
2302
|
-
var QUOTA_THRESHOLD_PROVIDERS = new Set([
|
|
2940
|
+
var QUOTA_THRESHOLD_PROVIDERS = /* @__PURE__ */ new Set([
|
|
2303
2941
|
"anthropic",
|
|
2304
2942
|
"openai",
|
|
2305
2943
|
"grok"
|
|
@@ -2399,10 +3037,10 @@ function formatPeriodType(periodType) {
|
|
|
2399
3037
|
const label = periodType.replace(/^USAGE_PERIOD_TYPE_/, "").toLowerCase();
|
|
2400
3038
|
return label && label !== "unspecified" ? label : null;
|
|
2401
3039
|
}
|
|
2402
|
-
/** Grok 등 provider별 상태 표시(on-demand 제외,
|
|
3040
|
+
/** Grok 등 provider별 상태 표시(on-demand 제외, 과금 주기, 티어). */
|
|
2403
3041
|
function UsageStateNotes({ usage }) {
|
|
2404
3042
|
const period = formatPeriodType(usage.periodType);
|
|
2405
|
-
if (!(usage.onDemandExcluded === true ||
|
|
3043
|
+
if (!(usage.onDemandExcluded === true || period !== null || !!usage.tier)) return null;
|
|
2406
3044
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2407
3045
|
className: "flex flex-wrap items-center gap-1 text-[10px]",
|
|
2408
3046
|
children: [
|
|
@@ -2411,11 +3049,6 @@ function UsageStateNotes({ usage }) {
|
|
|
2411
3049
|
title: "xAI에서 on-demand 과금을 끄면 다시 라우팅됩니다",
|
|
2412
3050
|
children: "excluded: on-demand billing enabled"
|
|
2413
3051
|
}),
|
|
2414
|
-
usage.zdrVideoExcluded === true && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2415
|
-
className: "px-1.5 py-0.5 rounded-full bg-amber-50 text-amber-700",
|
|
2416
|
-
title: "xAI에서 data-retention opt-out(Zero Data Retention)을 끄면 비디오가 다시 라우팅됩니다",
|
|
2417
|
-
children: "video unavailable: zero data retention"
|
|
2418
|
-
}),
|
|
2419
3052
|
period !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2420
3053
|
className: "px-1.5 py-0.5 rounded-full bg-sand-100 text-sand-600",
|
|
2421
3054
|
children: period
|
|
@@ -2423,11 +3056,6 @@ function UsageStateNotes({ usage }) {
|
|
|
2423
3056
|
usage.tier && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2424
3057
|
className: "px-1.5 py-0.5 rounded-full bg-sand-100 text-sand-600",
|
|
2425
3058
|
children: usage.tier
|
|
2426
|
-
}),
|
|
2427
|
-
usage.keepaliveApplicable === false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2428
|
-
className: "px-1.5 py-0.5 rounded-full bg-sand-100 text-sand-400",
|
|
2429
|
-
title: "이 provider는 토큰 윈도 keepalive 대상이 아닙니다",
|
|
2430
|
-
children: "keepalive n/a"
|
|
2431
3059
|
})
|
|
2432
3060
|
]
|
|
2433
3061
|
});
|
|
@@ -2467,13 +3095,10 @@ function UsageRow({ label, utilization, resetsAt, windowDurationMins, theme, thr
|
|
|
2467
3095
|
function TokenUsage({ token, theme }) {
|
|
2468
3096
|
const queryClient = useQueryClient();
|
|
2469
3097
|
const { data, isLoading, dataUpdatedAt } = QgridService.useUsage(token.id);
|
|
3098
|
+
const failedLookupAt = data?.error ? dataUpdatedAt : void 0;
|
|
2470
3099
|
(0, import_react.useEffect)(() => {
|
|
2471
|
-
if (
|
|
2472
|
-
}, [
|
|
2473
|
-
data?.error,
|
|
2474
|
-
dataUpdatedAt,
|
|
2475
|
-
queryClient
|
|
2476
|
-
]);
|
|
3100
|
+
if (failedLookupAt !== void 0) queryClient.invalidateQueries({ queryKey: ["Token"] });
|
|
3101
|
+
}, [failedLookupAt, queryClient]);
|
|
2477
3102
|
if (token.reauth_required) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2478
3103
|
className: "py-1",
|
|
2479
3104
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
@@ -2548,9 +3173,10 @@ function ThresholdControl({ token }) {
|
|
|
2548
3173
|
const left = Math.min(Math.max(rect.right - POPOVER_WIDTH, MARGIN), Math.max(window.innerWidth - POPOVER_WIDTH - MARGIN, MARGIN));
|
|
2549
3174
|
const above = rect.top - GAP - POPOVER_EST_HEIGHT;
|
|
2550
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));
|
|
2551
3177
|
setPos({
|
|
2552
3178
|
left,
|
|
2553
|
-
top:
|
|
3179
|
+
top: clampedTop
|
|
2554
3180
|
});
|
|
2555
3181
|
setValue(String(token.quota_threshold ?? 100));
|
|
2556
3182
|
};
|
|
@@ -2558,7 +3184,7 @@ function ThresholdControl({ token }) {
|
|
|
2558
3184
|
if (!supported) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
2559
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",
|
|
2560
3186
|
title: "Quota threshold는 이 provider에서 지원되지 않습니다",
|
|
2561
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3187
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$1, { className: "size-3" }), "n/a"]
|
|
2562
3188
|
});
|
|
2563
3189
|
const adjust = (delta) => {
|
|
2564
3190
|
const current = /^\d+$/.test(value.trim()) ? Number(value.trim()) : 0;
|
|
@@ -2582,7 +3208,7 @@ function ThresholdControl({ token }) {
|
|
|
2582
3208
|
title: "사용률 제한 설정",
|
|
2583
3209
|
onClick: open ? close : openPopover,
|
|
2584
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",
|
|
2585
|
-
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3211
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$1, { className: "size-3" }), "Set limit"]
|
|
2586
3212
|
}), open && pos && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
2587
3213
|
className: "fixed inset-0 z-40",
|
|
2588
3214
|
onPointerDown: close
|
|
@@ -2823,14 +3449,15 @@ function SortableTokenCard({ token }) {
|
|
|
2823
3449
|
if (token.name) totalCostParams.token_name = token.name;
|
|
2824
3450
|
const { data: costData } = QgridService.useTotalCost(totalCostParams, { enabled: !!token.name });
|
|
2825
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
|
+
};
|
|
2826
3458
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2827
3459
|
ref: setNodeRef,
|
|
2828
|
-
style
|
|
2829
|
-
transform: CSS.Translate.toString(transform),
|
|
2830
|
-
transition,
|
|
2831
|
-
opacity: isDragging ? .5 : 1,
|
|
2832
|
-
zIndex: isDragging ? 10 : void 0
|
|
2833
|
-
},
|
|
3460
|
+
style,
|
|
2834
3461
|
className: "relative rounded-lg bg-white border border-sand-200/80 overflow-hidden shadow-sm hover:shadow-md transition-shadow duration-200",
|
|
2835
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", {
|
|
2836
3463
|
className: "pl-4 pr-3 py-3",
|
|
@@ -2845,18 +3472,14 @@ function SortableTokenCard({ token }) {
|
|
|
2845
3472
|
...attributes,
|
|
2846
3473
|
...listeners,
|
|
2847
3474
|
className: "shrink-0 -m-1 p-1 text-sand-300 hover:text-sand-500 cursor-grab active:cursor-grabbing touch-none",
|
|
2848
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3475
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef, { className: "size-3.5" })
|
|
2849
3476
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2850
3477
|
className: "text-[13px] font-medium text-sand-800 truncate select-none",
|
|
2851
3478
|
children: token.name ?? "Unnamed"
|
|
2852
3479
|
})]
|
|
2853
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.
|
|
3480
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
2854
3481
|
className: `text-[11px] tabular-nums font-medium shrink-0 ${theme.cost}`,
|
|
2855
|
-
children:
|
|
2856
|
-
className: "ml-1 font-normal text-sand-400",
|
|
2857
|
-
title: unpricedRequestTitle(costData) ?? void 0,
|
|
2858
|
-
children: unpricedRequestLabel(costData)
|
|
2859
|
-
}) : null]
|
|
3482
|
+
children: formatUsd(costData?.usd ?? 0)
|
|
2860
3483
|
})]
|
|
2861
3484
|
}),
|
|
2862
3485
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
@@ -2914,11 +3537,10 @@ function UsageCard() {
|
|
|
2914
3537
|
const { data, isLoading } = TokenService.useTokens("A", { orderBy: "ord-asc" });
|
|
2915
3538
|
const queryClient = useQueryClient();
|
|
2916
3539
|
const reorderMutation = TokenService.useReorderMutation();
|
|
2917
|
-
const [
|
|
3540
|
+
const [reorder, setReorder] = (0, import_react.useState)(null);
|
|
2918
3541
|
const [providerFilter, setProviderFilter] = (0, import_react.useState)("all");
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
}, [data?.rows]);
|
|
3542
|
+
const serverTokens = data?.rows ?? [];
|
|
3543
|
+
const localTokens = reorder !== null && reorder.from === data?.rows ? reorder.tokens : serverTokens;
|
|
2922
3544
|
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));
|
|
2923
3545
|
const handleDragEnd = (event) => {
|
|
2924
3546
|
const { active, over } = event;
|
|
@@ -2929,7 +3551,10 @@ function UsageCard() {
|
|
|
2929
3551
|
const newIndex = localTokens.findIndex((t) => t.id === overId);
|
|
2930
3552
|
if (oldIndex === -1 || newIndex === -1) return;
|
|
2931
3553
|
const reordered = arrayMove(localTokens, oldIndex, newIndex);
|
|
2932
|
-
|
|
3554
|
+
setReorder({
|
|
3555
|
+
from: serverTokens,
|
|
3556
|
+
tokens: reordered
|
|
3557
|
+
});
|
|
2933
3558
|
const queryKey = TokenService.getTokensQueryOptions("A", { orderBy: "ord-asc" }).queryKey;
|
|
2934
3559
|
const prev = queryClient.getQueryData(queryKey);
|
|
2935
3560
|
queryClient.setQueryData(queryKey, (old) => old ? {
|
|
@@ -2939,7 +3564,7 @@ function UsageCard() {
|
|
|
2939
3564
|
reorderMutation.mutate({ ids: reordered.map((t) => t.id) }, {
|
|
2940
3565
|
onError: () => {
|
|
2941
3566
|
queryClient.setQueryData(queryKey, prev);
|
|
2942
|
-
|
|
3567
|
+
setReorder(null);
|
|
2943
3568
|
},
|
|
2944
3569
|
onSettled: () => {
|
|
2945
3570
|
Promise.all([queryClient.invalidateQueries({ queryKey: ["Token"] }), queryClient.invalidateQueries({ queryKey: ["Qgrid"] })]);
|