tiun 0.0.2.1 → 0.1.0
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.
- checksums.yaml +4 -4
- data/.forgejo/workflows/codeberg-tests.yml +226 -0
- data/.gitignore +7 -3
- data/.prettierrc.json +5 -0
- data/.rubocop.yml +221 -0
- data/AGENTS.md +132 -0
- data/Appraisals +18 -0
- data/CONTRIBUTING.md +80 -0
- data/CONTRIBUTING.ru.md +326 -0
- data/Gemfile +20 -1
- data/README.md +52 -23
- data/README.ru.md +72 -0
- data/Rakefile +10 -4
- data/TODO +2 -6
- data/bin/console +4 -3
- data/config/cucumber.yml +1 -0
- data/cucumber.mjs +6 -0
- data/docs/backend.md +73 -0
- data/docs/backend.ru.md +73 -0
- data/docs/components/approved.md +39 -0
- data/docs/components/approved.ru.md +39 -0
- data/docs/components/attachment-field.md +7 -0
- data/docs/components/attachment-field.ru.md +8 -0
- data/docs/components/attachment.md +48 -0
- data/docs/components/attachment.ru.md +48 -0
- data/docs/components/avatar.md +39 -0
- data/docs/components/avatar.ru.md +37 -0
- data/docs/components/chip.md +119 -0
- data/docs/components/chip.ru.md +99 -0
- data/docs/components/configuration.md +137 -0
- data/docs/components/configuration.ru.md +138 -0
- data/docs/components/daylight.md +41 -0
- data/docs/components/daylight.ru.md +41 -0
- data/docs/components/defaults.md +148 -0
- data/docs/components/defaults.ru.md +149 -0
- data/docs/components/documents.md +64 -0
- data/docs/components/documents.ru.md +64 -0
- data/docs/components/external-form-fields.ru.md +137 -0
- data/docs/components/external-renderers.md +50 -0
- data/docs/components/external-renderers.ru.md +51 -0
- data/docs/components/feedback.md +76 -0
- data/docs/components/feedback.ru.md +76 -0
- data/docs/components/footer.md +49 -0
- data/docs/components/footer.ru.md +49 -0
- data/docs/components/forms.md +177 -0
- data/docs/components/forms.ru.md +177 -0
- data/docs/components/images.md +111 -0
- data/docs/components/images.ru.md +111 -0
- data/docs/components/index.md +140 -0
- data/docs/components/index.ru.md +140 -0
- data/docs/components/intro.md +150 -0
- data/docs/components/intro.ru.md +150 -0
- data/docs/components/login.md +600 -0
- data/docs/components/login.ru.md +602 -0
- data/docs/components/methods.md +59 -0
- data/docs/components/methods.ru.md +59 -0
- data/docs/components/player.md +72 -0
- data/docs/components/player.ru.md +69 -0
- data/docs/components/profile.md +82 -0
- data/docs/components/profile.ru.md +82 -0
- data/docs/components/record-manager.md +69 -0
- data/docs/components/record-manager.ru.md +69 -0
- data/docs/components/row-column.ru.md +51 -0
- data/docs/components/rtfer.md +76 -0
- data/docs/components/rtfer.ru.md +76 -0
- data/docs/components/schema-calendar.md +86 -0
- data/docs/components/schema-calendar.ru.md +84 -0
- data/docs/components/schema-records.md +166 -0
- data/docs/components/schema-records.ru.md +166 -0
- data/docs/components/signup.md +194 -0
- data/docs/components/signup.ru.md +194 -0
- data/docs/components/slug-flow.md +97 -0
- data/docs/components/slug-flow.ru.md +59 -0
- data/docs/components/stockee.md +21 -0
- data/docs/components/stockee.ru.md +21 -0
- data/docs/components/text-views.md +64 -0
- data/docs/components/text-views.ru.md +57 -0
- data/docs/components/theme.md +212 -0
- data/docs/components/theme.ru.md +212 -0
- data/docs/components/tooltip.md +37 -0
- data/docs/components/tooltip.ru.md +30 -0
- data/docs/components/validation.md +153 -0
- data/docs/components/validation.ru.md +154 -0
- data/docs/components.md +31 -0
- data/docs/components.ru.md +31 -0
- data/docs/controller-names.md +23 -0
- data/docs/controller-names.ru.md +23 -0
- data/docs/examples/dneslov-frontend.md +38 -0
- data/docs/examples/dneslov-frontend.ru.md +39 -0
- data/docs/examples/dneslov-frontend.yaml +266 -0
- data/docs/frontend.md +316 -0
- data/docs/frontend.ru.md +332 -0
- data/docs/migrations/component-configuration.md +48 -0
- data/docs/migrations/component-configuration.ru.md +40 -0
- data/docs/migrations/component-shell-proposal.md +108 -0
- data/docs/migrations/component-shell-proposal.ru.md +150 -0
- data/docs/migrations/theme-layout.md +83 -0
- data/docs/migrations/theme-layout.ru.md +97 -0
- data/docs/reference.md +45 -0
- data/docs/reference.ru.md +1763 -0
- data/docs/resources.md +348 -0
- data/docs/resources.ru.md +349 -0
- data/docs/tasks/DNE-542.md +11 -0
- data/docs/tasks/DNE-566.md +8 -0
- data/docs/tasks/chip-segments.md +54 -0
- data/docs/tasks/configured-profile.md +73 -0
- data/docs/tasks/frontend/auth-form.md +7 -0
- data/docs/tasks/frontend/avatar.md +5 -0
- data/docs/tasks/frontend/component-removal.md +11 -0
- data/docs/tasks/frontend/dynamic-field.md +6 -0
- data/docs/tasks/frontend/field-caption.md +38 -0
- data/docs/tasks/frontend/form-core.md +65 -0
- data/docs/tasks/frontend/form-field-context.md +16 -0
- data/docs/tasks/frontend/form-session-renewal.md +58 -0
- data/docs/tasks/frontend/frontend-components.md +7 -0
- data/docs/tasks/frontend/frontend-docs.md +6 -0
- data/docs/tasks/frontend/frontend-layout.md +13 -0
- data/docs/tasks/frontend/frontend-methods.md +15 -0
- data/docs/tasks/frontend/frontend-other.md +13 -0
- data/docs/tasks/frontend/frontend-services.md +7 -0
- data/docs/tasks/frontend/fusion.md +22 -0
- data/docs/tasks/frontend/heading-core.md +5 -0
- data/docs/tasks/frontend/i18n-scope.md +37 -0
- data/docs/tasks/frontend/index-runtime.md +48 -0
- data/docs/tasks/frontend/inline-form.md +7 -0
- data/docs/tasks/frontend/intro-core.md +11 -0
- data/docs/tasks/frontend/login.md +8 -0
- data/docs/tasks/frontend/menu-branch.md +5 -0
- data/docs/tasks/frontend/paginator.md +7 -0
- data/docs/tasks/frontend/records-core.md +35 -0
- data/docs/tasks/frontend/resource-source-core.md +12 -0
- data/docs/tasks/frontend/signup.md +8 -0
- data/docs/tasks/frontend/span-body.md +16 -0
- data/docs/tasks/frontend/text-commonee.md +48 -0
- data/docs/tasks/frontend/theme-field.md +31 -0
- data/docs/tasks/frontend/theme-menu.md +8 -0
- data/docs/tasks/frontend/theme-settings.md +10 -0
- data/docs/tasks/frontend/view-content-core.md +12 -0
- data/docs/tasks/frontend/view-source-core.md +12 -0
- data/docs/tasks/ruby-extension-compatibility.ru.md +74 -0
- data/docs/tasks/todo-code-climate.md +8 -0
- data/docs/tasks/todo-compatibility.md +50 -0
- data/docs/tasks/todo-reek.md +5 -0
- data/docs/tasks/todo-yard-inch.md +7 -0
- data/eslint.config.mjs +15 -0
- data/exe/tiun +1 -0
- data/gemfiles/rails_7_0.gemfile +16 -0
- data/gemfiles/rails_7_2.gemfile +17 -0
- data/lib/config/locale/browser.en.yml +43 -0
- data/lib/config/locale/browser.ru.yml +35 -0
- data/lib/config/locale/confirmation.en.yml +16 -0
- data/lib/config/locale/confirmation.ru.yml +16 -0
- data/lib/config/locale/errors.en.yml +57 -0
- data/lib/config/locale/errors.ru.yml +47 -0
- data/lib/config/locale/form_delay.en.yml +11 -0
- data/lib/config/locale/form_delay.ru.yml +11 -0
- data/lib/config/locale/recovery.en.yml +14 -0
- data/lib/config/locale/ru.yml +272 -6
- data/lib/config/routes.rb +5 -11
- data/lib/tasks/tiun/translations.rake +12 -0
- data/lib/tiun/actor/validate.rb +3 -2
- data/lib/tiun/actor.rb +13 -10
- data/lib/tiun/api_not_found.rb +16 -0
- data/lib/tiun/attributes.rb +8 -7
- data/lib/tiun/auth/attribute_models.rb +32 -0
- data/lib/tiun/auth/controller/discord.rb +26 -0
- data/lib/tiun/auth/controller/facebook.rb +62 -0
- data/lib/tiun/auth/controller/github.rb +37 -0
- data/lib/tiun/auth/controller/kakao.rb +33 -0
- data/lib/tiun/auth/controller/oauth.rb +167 -0
- data/lib/tiun/auth/controller/ok.rb +8 -0
- data/lib/tiun/auth/controller/telegram.rb +188 -0
- data/lib/tiun/auth/controller/vk.rb +85 -0
- data/lib/tiun/auth/controller/wechat.rb +58 -0
- data/lib/tiun/auth/controller/weibo.rb +28 -0
- data/lib/tiun/auth/controller.rb +467 -150
- data/lib/tiun/auth/json_session.rb +19 -0
- data/lib/tiun/auth/token_identity.rb +37 -0
- data/lib/tiun/auth/user_identity.rb +27 -0
- data/lib/tiun/auth/views/oauth_address.html.erb +23 -0
- data/lib/tiun/auth.rb +184 -45
- data/lib/tiun/carrier_wave_store.rb +59 -0
- data/lib/tiun/cli.rb +52 -32
- data/lib/tiun/concern/resources.rb +85 -0
- data/lib/tiun/config_source.rb +52 -0
- data/lib/tiun/content_range.rb +123 -0
- data/lib/tiun/context/merge.rb +117 -0
- data/lib/tiun/context.rb +39 -0
- data/lib/tiun/controller/auth/identity.rb +201 -0
- data/lib/tiun/controller/auth/registration.rb +23 -0
- data/lib/tiun/controller/auth.rb +198 -0
- data/lib/tiun/controller/auto.rb.erb +10 -0
- data/lib/tiun/controller/base/actions.rb +156 -0
- data/lib/tiun/controller/base/assignment.rb +101 -0
- data/lib/tiun/controller/base/parameters.rb +198 -0
- data/lib/tiun/controller/base/params.rb +166 -0
- data/lib/tiun/controller/base/records.rb +107 -0
- data/lib/tiun/controller/base/representation.rb +97 -0
- data/lib/tiun/controller/base/scopes.rb +132 -0
- data/lib/tiun/controller/base.rb +52 -0
- data/lib/tiun/controller/component_assets.rb +96 -0
- data/lib/tiun/controller/meta.rb +248 -0
- data/lib/tiun/controller/translations.rb +22 -0
- data/lib/tiun/controller.rb +13 -0
- data/lib/tiun/core/boot.rb +210 -0
- data/lib/tiun/core/contexts.rb +53 -0
- data/lib/tiun/core/controller_contexts.rb +42 -0
- data/lib/tiun/core/defaults.rb +215 -0
- data/lib/tiun/core/evaluation.rb +105 -0
- data/lib/tiun/core/field_attributes.rb +78 -0
- data/lib/tiun/core/files.rb +153 -0
- data/lib/tiun/core/generation.rb +234 -0
- data/lib/tiun/core/methods.rb +104 -0
- data/lib/tiun/core/names.rb +140 -0
- data/lib/tiun/core/registry.rb +97 -0
- data/lib/tiun/core/reloading.rb +77 -0
- data/lib/tiun/core/resources.rb +308 -0
- data/lib/tiun/core/routing/forward.rb +206 -0
- data/lib/tiun/core/routing.rb +323 -0
- data/lib/tiun/core/types.rb +88 -0
- data/lib/tiun/core.rb +26 -0
- data/lib/tiun/core_helper.rb +85 -13
- data/lib/tiun/engine.rb +64 -20
- data/lib/tiun/error_handling.rb +121 -0
- data/lib/tiun/hooks.rb +131 -0
- data/lib/tiun/mailer/confirmation.rb +37 -0
- data/lib/tiun/mailer/recovery.rb +16 -0
- data/lib/tiun/migration.rb +72 -50
- data/lib/tiun/mixins.rb +128 -19
- data/lib/tiun/model/account/identity.rb +93 -0
- data/lib/tiun/model/account.rb +180 -7
- data/lib/tiun/model/auth/bcrypt.rb +47 -0
- data/lib/tiun/model/auth.rb +162 -36
- data/lib/tiun/model/auto.rb.erb +12 -0
- data/lib/tiun/model/me.rb +133 -0
- data/lib/tiun/model/settings.rb +186 -0
- data/lib/tiun/model/token/recovery.rb +48 -0
- data/lib/tiun/model/token.rb +37 -3
- data/lib/tiun/model.rb +82 -69
- data/lib/tiun/notification/service.rb +18 -0
- data/lib/tiun/notification.rb +6 -0
- data/lib/tiun/policy/default.rb +7 -0
- data/lib/tiun/policy.rb +84 -8
- data/lib/tiun/proceed/allowed_errors.rb +217 -0
- data/lib/tiun/proceed/auth.rb +50 -0
- data/lib/tiun/proceed/description.rb +89 -0
- data/lib/tiun/proceed/enums.rb +225 -0
- data/lib/tiun/proceed/hooks.rb +51 -0
- data/lib/tiun/proceed/pass_over_paths.rb +40 -0
- data/lib/tiun/proceed/policy.rb +172 -0
- data/lib/tiun/proceed/registration.rb +69 -0
- data/lib/tiun/proceed/schemas/component_nodes.rb +436 -0
- data/lib/tiun/proceed/schemas/constants.rb +116 -0
- data/lib/tiun/proceed/schemas/content.rb +68 -0
- data/lib/tiun/proceed/schemas/definitions.rb +181 -0
- data/lib/tiun/proceed/schemas/dictionary.rb +144 -0
- data/lib/tiun/proceed/schemas/fields.rb +182 -0
- data/lib/tiun/proceed/schemas/models.rb +50 -0
- data/lib/tiun/proceed/schemas/spans.rb +86 -0
- data/lib/tiun/proceed/schemas/values.rb +94 -0
- data/lib/tiun/proceed/schemas/view_paths.rb +86 -0
- data/lib/tiun/proceed/schemas/view_readiness.rb +51 -0
- data/lib/tiun/proceed/schemas/views.rb +192 -0
- data/lib/tiun/proceed/schemas.rb +137 -0
- data/lib/tiun/proceed/services.rb +79 -0
- data/lib/tiun/proceed/token_lifetimes.rb +49 -0
- data/lib/tiun/proceed/translations.rb +45 -0
- data/lib/tiun/proceed/versions.rb +315 -0
- data/lib/tiun/proceed.rb +23 -0
- data/lib/tiun/router.rb +40 -0
- data/lib/tiun/routes/mounts.rb +277 -0
- data/lib/tiun/routes.rb +150 -0
- data/lib/tiun/service/auto.rb.erb +5 -0
- data/lib/tiun/service/email_confirmation.rb +36 -0
- data/lib/tiun/service/job.rb +16 -0
- data/lib/tiun/service.rb +82 -0
- data/lib/tiun/services/translation.rb +297 -0
- data/lib/tiun/themes.rb +98 -0
- data/lib/tiun/translations/database.rb +72 -0
- data/lib/tiun/translations.rb +279 -0
- data/lib/tiun/version.rb +3 -3
- data/lib/tiun.rb +79 -486
- data/package-lock.json +4836 -0
- data/package.json +103 -0
- data/scripts/build-application.mjs +39 -0
- data/scripts/build-css.mjs +21 -0
- data/scripts/ci-badges.mjs +54 -0
- data/scripts/ci-badges.test.mjs +46 -0
- data/scripts/ci-coverage.mjs +26 -0
- data/scripts/ci-quality.mjs +80 -0
- data/scripts/ci-quality.sh +21 -0
- data/scripts/ci-quality.test.mjs +59 -0
- data/scripts/clean.mjs +3 -0
- data/scripts/publish-ci-badges.sh +45 -0
- data/src/auth/configuration.ts +50 -0
- data/src/browser/contracts.js +7 -0
- data/src/browser/mount.d.ts +26 -0
- data/src/browser/mount.jsx +1 -0
- data/src/browser/styles.js +17 -0
- data/src/browser/tiun.scss +23 -0
- data/src/browser/tiun.ts +1 -0
- data/src/calendar/configuration.ts +98 -0
- data/src/components/Avatar.tsx +45 -0
- data/src/components/Calendar.tsx +441 -0
- data/src/components/CatchWrapper.tsx +55 -0
- data/src/components/Chip.tsx +267 -0
- data/src/components/Column.tsx +13 -0
- data/src/components/Component.tsx +1039 -0
- data/src/components/Enum.tsx +142 -0
- data/src/components/Figure.tsx +11 -0
- data/src/components/FlexText.tsx +101 -0
- data/src/components/Footer.tsx +13 -0
- data/src/components/Grid.tsx +36 -0
- data/src/components/Heading.tsx +64 -0
- data/src/components/Image.tsx +168 -0
- data/src/components/Index.tsx +391 -0
- data/src/components/Intro.tsx +536 -0
- data/src/components/Loader.tsx +116 -0
- data/src/components/Lorem.tsx +379 -0
- data/src/components/Markdown.d.ts +17 -0
- data/src/components/Markdown.jsx +118 -0
- data/src/components/Menu.tsx +50 -0
- data/src/components/Modal.tsx +143 -0
- data/src/components/Paginator.tsx +265 -0
- data/src/components/Player.tsx +269 -0
- data/src/components/Records.tsx +1063 -0
- data/src/components/Row.tsx +193 -0
- data/src/components/Span.tsx +122 -0
- data/src/components/Step.tsx +19 -0
- data/src/components/Stockee.tsx +50 -0
- data/src/components/Toast.tsx +125 -0
- data/src/components/Tooltip.tsx +214 -0
- data/src/components/View.tsx +278 -0
- data/src/components/_palette.scss +26 -0
- data/src/components/calendar-browser.scss +133 -0
- data/src/components/calendar.scss +217 -0
- data/src/components/chip-browser.scss +270 -0
- data/src/components/chips.scss +95 -0
- data/src/components/column.scss +4 -0
- data/src/components/dashboard-browser.scss +81 -0
- data/src/components/dashboard.scss +117 -0
- data/src/components/description-browser.scss +112 -0
- data/src/components/document.scss +43 -0
- data/src/components/enum-browser.scss +33 -0
- data/src/components/enums.scss +56 -0
- data/src/components/footer.scss +51 -0
- data/src/components/form/ActionButton.tsx +66 -0
- data/src/components/form/Attachment.tsx +200 -0
- data/src/components/form/Block.tsx +55 -0
- data/src/components/form/BooleanBox.tsx +58 -0
- data/src/components/form/Collection.tsx +89 -0
- data/src/components/form/DynamicInput.tsx +806 -0
- data/src/components/form/ErrorSpan.tsx +17 -0
- data/src/components/form/ExternalField.tsx +554 -0
- data/src/components/form/FieldCaption.tsx +35 -0
- data/src/components/form/Form.tsx +407 -0
- data/src/components/form/HiddenField.tsx +10 -0
- data/src/components/form/JsonEditor.tsx +443 -0
- data/src/components/form/Login.tsx +381 -0
- data/src/components/form/NumberField.tsx +75 -0
- data/src/components/form/Pressee.tsx +101 -0
- data/src/components/form/RtferField.tsx +94 -0
- data/src/components/form/SelectField.tsx +73 -0
- data/src/components/form/SlugFlow.tsx +296 -0
- data/src/components/form/TextArea.tsx +5 -0
- data/src/components/form/TextField.tsx +6 -0
- data/src/components/form/Wye.tsx +67 -0
- data/src/components/form/auth.scss +366 -0
- data/src/components/form/changes.ts +239 -0
- data/src/components/form/context.ts +31 -0
- data/src/components/form/createForm.tsx +109 -0
- data/src/components/form/dynamic-field.scss +20 -0
- data/src/components/form/dynamicMatching.ts +44 -0
- data/src/components/form/form-browser.scss +106 -0
- data/src/components/form/forms.scss +1570 -0
- data/src/components/form/formsLib.ts +76 -0
- data/src/components/form/identity.ts +10 -0
- data/src/components/form/input.scss +37 -0
- data/src/components/form/layout.ts +72 -0
- data/src/components/form/login-browser.scss +30 -0
- data/src/components/form/render.tsx +94 -0
- data/src/components/form/resourceFields.ts +87 -0
- data/src/components/form/types.ts +214 -0
- data/src/components/form/values.ts +266 -0
- data/src/components/image.scss +67 -0
- data/src/components/intro-browser.scss +106 -0
- data/src/components/intro.scss +158 -0
- data/src/components/loader.scss +86 -0
- data/src/components/menu.scss +24 -0
- data/src/components/player.scss +48 -0
- data/src/components/records-browser.scss +62 -0
- data/src/components/records.scss +181 -0
- data/src/components/row.scss +31 -0
- data/src/components/stockee.scss +26 -0
- data/src/components/theme-palettes/compat.scss +15 -0
- data/src/components/theme-palettes/dark.scss +237 -0
- data/src/components/theme-palettes/light.scss +21 -0
- data/src/components/theme.scss +34 -0
- data/src/components/tiun_core.scss +9 -0
- data/src/components/toast.scss +63 -0
- data/src/components/tooltip.scss +22 -0
- data/src/components/view-browser.scss +321 -0
- data/src/components/view-controls.scss +385 -0
- data/src/concern/application.ts +56 -0
- data/src/concern/calendarViewProps.ts +28 -0
- data/src/concern/chipViewProps.ts +60 -0
- data/src/concern/documentHead.ts +66 -0
- data/src/concern/i18n.ts +70 -0
- data/src/concern/resourceRequest.ts +25 -0
- data/src/concern/schemaText.ts +6 -0
- data/src/concern/slugFlowProps.ts +76 -0
- data/src/concern/spanOptions.ts +37 -0
- data/src/concern/spansViewProps.tsx +103 -0
- data/src/concern/useFormAccess.ts +324 -0
- data/src/concern/useRecordsResource.ts +60 -0
- data/src/config/application.ts +57 -0
- data/src/config/componentDefaults.ts +106 -0
- data/src/config/components.ts +436 -0
- data/src/config/names.ts +72 -0
- data/src/config/records.ts +34 -0
- data/src/decorators/buttonBehaviours.tsx +46 -0
- data/src/decorators/configuration.ts +104 -0
- data/src/decorators/validation.ts +52 -0
- data/src/decorators/withAppearance.tsx +45 -0
- data/src/decorators/withCaption.tsx +21 -0
- data/src/decorators/withChildren.tsx +31 -0
- data/src/decorators/withClose.scss +37 -0
- data/src/decorators/withClose.tsx +44 -0
- data/src/decorators/withColumn.tsx +111 -0
- data/src/decorators/withDiscordAuth.tsx +4 -0
- data/src/decorators/withExternalAuth.tsx +50 -0
- data/src/decorators/withFacebookAuth.tsx +4 -0
- data/src/decorators/withField.tsx +91 -0
- data/src/decorators/withForm.tsx +365 -0
- data/src/decorators/withGithubAuth.tsx +4 -0
- data/src/decorators/withKakaoAuth.tsx +4 -0
- data/src/decorators/withMenuBranch.scss +45 -0
- data/src/decorators/withMenuBranch.tsx +109 -0
- data/src/decorators/withOkAuth.tsx +4 -0
- data/src/decorators/withPlayerList.tsx +77 -0
- data/src/decorators/withQuickLinkMark.ts +57 -0
- data/src/decorators/withRecordForm.tsx +561 -0
- data/src/decorators/withRequestActivity.scss +7 -0
- data/src/decorators/withRequestActivity.tsx +21 -0
- data/src/decorators/withRouter.tsx +395 -0
- data/src/decorators/withRouterLink.tsx +54 -0
- data/src/decorators/withTelegramAuth.tsx +4 -0
- data/src/decorators/withTextControl.tsx +194 -0
- data/src/decorators/withUnique.scss +39 -0
- data/src/decorators/withUnique.tsx +172 -0
- data/src/decorators/withUnsavedChanges.scss +39 -0
- data/src/decorators/withUnsavedChanges.tsx +312 -0
- data/src/decorators/withValidation.ts +38 -0
- data/src/decorators/withVkAuth.tsx +4 -0
- data/src/decorators/withWechatAuth.tsx +4 -0
- data/src/decorators/withWeiboAuth.tsx +4 -0
- data/src/intro/config.ts +72 -0
- data/src/intro/position.ts +70 -0
- data/src/layout/units.ts +21 -0
- data/src/records/types.ts +67 -0
- data/src/routing/nativePaths.ts +16 -0
- data/src/routing/routes.ts +337 -0
- data/src/schema/Schema.ts +2034 -0
- data/src/schema/dates.ts +17 -0
- data/src/schema.ts +274 -0
- data/src/services/Meta.ts +64 -0
- data/src/services/Resource.ts +480 -0
- data/src/services/Stock.ts +156 -0
- data/src/services/browser/requestActivity.d.ts +7 -0
- data/src/services/browser/requestActivity.js +119 -0
- data/src/services/browser/slugColor.js +13 -0
- data/src/services/calendar/clock.ts +169 -0
- data/src/services/calendar/dates.ts +127 -0
- data/src/services/calendar/daylight.ts +301 -0
- data/src/services/calendar/useCalendarDaylight.ts +76 -0
- data/src/services/calendar/utcTimeSource.ts +41 -0
- data/src/services/enumLookup.ts +96 -0
- data/src/services/form/blankCondition.ts +61 -0
- data/src/services/form/hoardValidation.ts +84 -0
- data/src/services/i18n/I18n.ts +227 -0
- data/src/services/i18n/messages.ts +185 -0
- data/src/services/load.ts +60 -0
- data/src/services/methods/aboutData.d.ts +9 -0
- data/src/services/methods/aboutData.js +32 -0
- data/src/services/methods/calendarChoices.d.ts +1 -0
- data/src/services/methods/calendarChoices.js +9 -0
- data/src/services/methods/eventDates.ts +96 -0
- data/src/services/methods/forms.ts +22 -0
- data/src/services/methods/mount.jsx +34 -0
- data/src/services/methods/paschal.ts +45 -0
- data/src/services/methods/prepared.ts +193 -0
- data/src/services/methods/query.ts +30 -0
- data/src/services/methods/registry.ts +22 -0
- data/src/services/methods/resolveReadResource.ts +57 -0
- data/src/services/methods.ts +156 -0
- data/src/services/records/range.ts +39 -0
- data/src/services/records/resource.ts +90 -0
- data/src/services/records/useRecordPages.ts +266 -0
- data/src/services/session/renewal.ts +394 -0
- data/src/services/textLink.ts +11 -0
- data/src/services/timer.ts +25 -0
- data/src/services/useAppearance.ts +496 -0
- data/src/services/useSwitch.ts +146 -0
- data/src/theme/cache.ts +88 -0
- data/src/theme/configuration.ts +261 -0
- data/src/theme/context.ts +48 -0
- data/src/theme/resource.ts +106 -0
- data/tiun.gemspec +53 -45
- data/tools/rubocop/compact_block_braces.rb +39 -0
- data/tools/rubocop/i18n_decorators.rb +15 -0
- data/tools/rubocop/spacing.rb +96 -0
- data/tsconfig.build.json +26 -0
- data/tsconfig.json +27 -0
- metadata +628 -72
- data/.rspec +0 -3
- data/.travis.yml +0 -7
- data/lib/tiun/autocontroller.rb.erb +0 -20
- data/lib/tiun/autolistserializer.rb.erb +0 -9
- data/lib/tiun/automodel.rb.erb +0 -10
- data/lib/tiun/autoserializer.rb.erb +0 -9
- data/lib/tiun/base.rb +0 -405
- data/lib/tiun/core_controller.rb +0 -6
- data/lib/tiun/list_serializer.rb +0 -20
- data/lib/tiun/meta_controller.rb +0 -13
- data/lib/tiun/serializer.rb +0 -31
- /data/lib/tiun/{automigration.rb.erb → migration/auto.rb.erb} +0 -0
- /data/lib/tiun/{autopolicy.rb.erb → policy/auto.rb.erb} +0 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Children, cloneElement, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import type { HTMLAttributes, ReactElement, ReactNode, Ref } from "react";
|
|
4
|
+
import { rootRem, toRem } from "../layout/units.js";
|
|
5
|
+
import { createPortal } from "react-dom";
|
|
6
|
+
|
|
7
|
+
export interface TooltipProps {
|
|
8
|
+
readonly children: ReactElement;
|
|
9
|
+
readonly content: ReactNode;
|
|
10
|
+
readonly timeoutMs?: number;
|
|
11
|
+
readonly whenClipped?: boolean;
|
|
12
|
+
readonly placement?: "top" | "bottom" | "left" | "right";
|
|
13
|
+
readonly className?: string;
|
|
14
|
+
}
|
|
15
|
+
let sequence = 0;
|
|
16
|
+
const closers = new Set<() => void>();
|
|
17
|
+
|
|
18
|
+
/** Lets integrations with another router close all currently mounted tooltips. */
|
|
19
|
+
export function closeTooltips(): void {
|
|
20
|
+
for (const close of closers) {
|
|
21
|
+
close();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Shows a tooltip next to a focusable control or text.
|
|
27
|
+
* - With whenClipped, reveal the tooltip only when the trigger overflows horizontally.
|
|
28
|
+
* @param props {TooltipProps} Trigger, content, position, lifetime and overflow preference.
|
|
29
|
+
* @returns {ReactElement} The trigger and the tooltip portal.
|
|
30
|
+
*/
|
|
31
|
+
export function Tooltip({
|
|
32
|
+
children,
|
|
33
|
+
content,
|
|
34
|
+
timeoutMs = 20000,
|
|
35
|
+
whenClipped = false,
|
|
36
|
+
placement = "top",
|
|
37
|
+
className = "",
|
|
38
|
+
}: TooltipProps): ReactElement {
|
|
39
|
+
const child = Children.only(children) as ReactElement<HTMLAttributes<HTMLElement>>,
|
|
40
|
+
[id] = useState(() => `tiun-tooltip-${++sequence}`),
|
|
41
|
+
[open, setOpen] = useState(false),
|
|
42
|
+
[position, setPosition] = useState<{ left: number; top: number }>(),
|
|
43
|
+
controlRef = useRef<HTMLElement | null>(null),
|
|
44
|
+
floatingRef = useRef<HTMLDivElement>(null),
|
|
45
|
+
hideTooltip = useCallback(() => {
|
|
46
|
+
setOpen(false);
|
|
47
|
+
}, []),
|
|
48
|
+
isContentEnabled = content !== undefined && content !== null && content !== false && content !== "",
|
|
49
|
+
isShown = open && isContentEnabled,
|
|
50
|
+
portalDocument =
|
|
51
|
+
controlRef.current?.ownerDocument ??
|
|
52
|
+
(typeof globalThis.document === "undefined" ? undefined : globalThis.document);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
closers.add(hideTooltip);
|
|
56
|
+
return () => {
|
|
57
|
+
closers.delete(hideTooltip);
|
|
58
|
+
};
|
|
59
|
+
}, [hideTooltip]);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!isShown) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const timer = setTimeout(hideTooltip, Math.max(0, timeoutMs));
|
|
66
|
+
return () => {
|
|
67
|
+
clearTimeout(timer);
|
|
68
|
+
};
|
|
69
|
+
}, [isShown, timeoutMs, hideTooltip]);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (!isShown || !portalDocument?.defaultView) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const hostWindow = portalDocument.defaultView,
|
|
76
|
+
onAnchorClick = (event: Event) => {
|
|
77
|
+
if ((event.target as Element | null)?.closest?.("a[href]")) {
|
|
78
|
+
hideTooltip();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
for (const name of ["popstate", "hashchange", "tiun-route-change", "resize"]) {
|
|
83
|
+
hostWindow.addEventListener(name, hideTooltip);
|
|
84
|
+
}
|
|
85
|
+
hostWindow.addEventListener("scroll", hideTooltip, true);
|
|
86
|
+
portalDocument.addEventListener("click", onAnchorClick, true);
|
|
87
|
+
return () => {
|
|
88
|
+
for (const name of ["popstate", "hashchange", "tiun-route-change", "resize"]) {
|
|
89
|
+
hostWindow.removeEventListener(name, hideTooltip);
|
|
90
|
+
}
|
|
91
|
+
hostWindow.removeEventListener("scroll", hideTooltip, true);
|
|
92
|
+
portalDocument.removeEventListener("click", onAnchorClick, true);
|
|
93
|
+
};
|
|
94
|
+
}, [isShown, portalDocument, hideTooltip]);
|
|
95
|
+
|
|
96
|
+
useLayoutEffect(() => {
|
|
97
|
+
const element = floatingRef.current,
|
|
98
|
+
target = controlRef.current;
|
|
99
|
+
if (!isShown || !element || !target) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const view = target.ownerDocument.defaultView;
|
|
103
|
+
if (!view) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (typeof element.showPopover === "function") {
|
|
107
|
+
element.showPopover();
|
|
108
|
+
}
|
|
109
|
+
const anchorBounds = target.getBoundingClientRect(),
|
|
110
|
+
panelBounds = element.getBoundingClientRect(),
|
|
111
|
+
viewportPadding = rootRem(target) * 0.5;
|
|
112
|
+
let left = anchorBounds.left + (anchorBounds.width - panelBounds.width) / 2,
|
|
113
|
+
top = anchorBounds.top - panelBounds.height - viewportPadding;
|
|
114
|
+
if (placement === "bottom" || (placement === "top" && top < viewportPadding)) {
|
|
115
|
+
top = anchorBounds.bottom + viewportPadding;
|
|
116
|
+
}
|
|
117
|
+
if (placement === "left" || placement === "right") {
|
|
118
|
+
left =
|
|
119
|
+
placement === "left"
|
|
120
|
+
? anchorBounds.left - panelBounds.width - viewportPadding
|
|
121
|
+
: anchorBounds.right + viewportPadding;
|
|
122
|
+
top = anchorBounds.top + (anchorBounds.height - panelBounds.height) / 2;
|
|
123
|
+
}
|
|
124
|
+
setPosition({
|
|
125
|
+
left: Math.max(viewportPadding, Math.min(left, view.innerWidth - panelBounds.width - viewportPadding)),
|
|
126
|
+
top: Math.max(viewportPadding, Math.min(top, view.innerHeight - panelBounds.height - viewportPadding)),
|
|
127
|
+
});
|
|
128
|
+
return () => {
|
|
129
|
+
if (typeof element.hidePopover === "function" && element.matches(":popover-open")) {
|
|
130
|
+
element.hidePopover();
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}, [isShown, content, placement]);
|
|
134
|
+
|
|
135
|
+
const originalRef = (Object.getOwnPropertyDescriptor(child.props, "ref")?.value ??
|
|
136
|
+
Object.getOwnPropertyDescriptor(child, "ref")?.value) as Ref<HTMLElement> | undefined,
|
|
137
|
+
registerTrigger = useCallback(
|
|
138
|
+
(element: HTMLElement | null) => {
|
|
139
|
+
controlRef.current = element;
|
|
140
|
+
if (typeof originalRef === "function") {
|
|
141
|
+
originalRef(element);
|
|
142
|
+
} else if (originalRef) {
|
|
143
|
+
originalRef.current = element;
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
[originalRef],
|
|
147
|
+
),
|
|
148
|
+
{ props } = child,
|
|
149
|
+
target = cloneElement(child, {
|
|
150
|
+
"aria-describedby": [props["aria-describedby"], isShown ? id : null].filter(Boolean).join(" ") || undefined,
|
|
151
|
+
onBlur: (event) => {
|
|
152
|
+
props.onBlur?.(event);
|
|
153
|
+
hideTooltip();
|
|
154
|
+
},
|
|
155
|
+
onFocus: (event) => {
|
|
156
|
+
props.onFocus?.(event);
|
|
157
|
+
if (!whenClipped || event.currentTarget.scrollWidth > event.currentTarget.clientWidth) {
|
|
158
|
+
setOpen(true);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
onKeyDown: (event) => {
|
|
162
|
+
props.onKeyDown?.(event);
|
|
163
|
+
if (isShown && event.key === "Escape") {
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
event.stopPropagation();
|
|
166
|
+
hideTooltip();
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
onMouseEnter: (event) => {
|
|
170
|
+
props.onMouseEnter?.(event);
|
|
171
|
+
if (!whenClipped || event.currentTarget.scrollWidth > event.currentTarget.clientWidth) {
|
|
172
|
+
setOpen(true);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
onMouseLeave: (event) => {
|
|
176
|
+
props.onMouseLeave?.(event);
|
|
177
|
+
hideTooltip();
|
|
178
|
+
},
|
|
179
|
+
ref: registerTrigger,
|
|
180
|
+
tabIndex:
|
|
181
|
+
props.tabIndex ??
|
|
182
|
+
(typeof child.type === "string" && ["a", "button", "input", "select", "textarea"].includes(child.type)
|
|
183
|
+
? undefined
|
|
184
|
+
: 0),
|
|
185
|
+
} as HTMLAttributes<HTMLElement> & { ref: Ref<HTMLElement> });
|
|
186
|
+
return !isContentEnabled ? (
|
|
187
|
+
child
|
|
188
|
+
) : (
|
|
189
|
+
<>
|
|
190
|
+
{target}
|
|
191
|
+
{portalDocument &&
|
|
192
|
+
(!whenClipped || isShown) &&
|
|
193
|
+
createPortal(
|
|
194
|
+
<div
|
|
195
|
+
id={id}
|
|
196
|
+
ref={floatingRef}
|
|
197
|
+
role="tooltip"
|
|
198
|
+
popover="manual"
|
|
199
|
+
className={`tiun-tooltip ${className}`}
|
|
200
|
+
hidden={!isShown}
|
|
201
|
+
data-placement={placement}
|
|
202
|
+
style={{
|
|
203
|
+
left: toRem(position?.left ?? 0, controlRef.current),
|
|
204
|
+
top: toRem(position?.top ?? 0, controlRef.current),
|
|
205
|
+
visibility: isShown && position ? "visible" : "hidden",
|
|
206
|
+
}}
|
|
207
|
+
>
|
|
208
|
+
{content}
|
|
209
|
+
</div>,
|
|
210
|
+
portalDocument.body,
|
|
211
|
+
)}
|
|
212
|
+
</>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ApplicationContextCore, type ApplicationState, useMessages } from "../concern/application.js";
|
|
3
|
+
import type { ComponentDefinition } from "../config/components.js";
|
|
4
|
+
import type { Layout, Schema } from "../schema/Schema.js";
|
|
5
|
+
import { type RouteViewProps, RouterContext } from "../decorators/withRouter.js";
|
|
6
|
+
import { configuredHead, useDocumentHead } from "../concern/documentHead.js";
|
|
7
|
+
import { decorateComponent } from "../decorators/configuration.js";
|
|
8
|
+
import type { ChildrenRenderer } from "../decorators/withChildren.js";
|
|
9
|
+
import { Component } from "./Component.js";
|
|
10
|
+
import { Loader } from "./Loader.js";
|
|
11
|
+
import type { ViewContextMethod } from "../services/methods.js";
|
|
12
|
+
import { bindingValue } from "../config/components.js";
|
|
13
|
+
import { configuredLabel } from "../config/application.js";
|
|
14
|
+
import { useEffect } from "react";
|
|
15
|
+
import { useI18n } from "../concern/i18n.js";
|
|
16
|
+
|
|
17
|
+
export interface ViewProps<T> extends RouteViewProps<T> {
|
|
18
|
+
readonly pending?: boolean;
|
|
19
|
+
readonly pendingHeading?: boolean;
|
|
20
|
+
readonly headerOnly?: boolean;
|
|
21
|
+
readonly renderConfiguredChildren?: ChildrenRenderer;
|
|
22
|
+
readonly filter?: Readonly<Record<string, unknown>> | undefined;
|
|
23
|
+
readonly data?: unknown;
|
|
24
|
+
readonly onClick?: React.MouseEventHandler<HTMLDivElement> | undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const EMPTY = Object.freeze({}),
|
|
28
|
+
/** @returns Empty data for a view without a context method. */
|
|
29
|
+
emptyViewData: ViewContextMethod = (): ReturnType<ViewContextMethod> => ({ data: EMPTY });
|
|
30
|
+
/**
|
|
31
|
+
* Applies the page document settings and renders the configured children.
|
|
32
|
+
* @param props The route, page definition, loading state, filters, prepared data and link handler.
|
|
33
|
+
* - A pending administrative view renders headings and the empty record lists.
|
|
34
|
+
* - A guest administrative view renders only the configured apphead.
|
|
35
|
+
* @returns The page container and its children with a loading indicator while pending.
|
|
36
|
+
*/
|
|
37
|
+
// eslint-disable-next-line one-var -- Keep the component separate from its empty data constant.
|
|
38
|
+
const viewComponent = <T,>(
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- A view shares the existing schema and router.
|
|
40
|
+
{
|
|
41
|
+
schema,
|
|
42
|
+
view,
|
|
43
|
+
router,
|
|
44
|
+
pending = false,
|
|
45
|
+
pendingHeading = false,
|
|
46
|
+
headerOnly = false,
|
|
47
|
+
filter,
|
|
48
|
+
data = EMPTY,
|
|
49
|
+
onClick,
|
|
50
|
+
renderConfiguredChildren,
|
|
51
|
+
}: ViewProps<T>,
|
|
52
|
+
): React.ReactElement => {
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- A standalone view can omit the application context.
|
|
54
|
+
const application = React.useContext(ApplicationContextCore) as ApplicationState | null,
|
|
55
|
+
labels = useMessages({ view: view.name }),
|
|
56
|
+
language = useI18n(),
|
|
57
|
+
owner = String(application?.user?.id ?? application?.user?.uid ?? "");
|
|
58
|
+
const definition = schema.pageDefinitions[view.name];
|
|
59
|
+
const children = definition ? (schema.configuredComponent(definition).node.children ?? []) : [];
|
|
60
|
+
/**
|
|
61
|
+
* Recognizes a record list in the initial administrative layout.
|
|
62
|
+
* @param child A direct child declaration, including a named list reference.
|
|
63
|
+
* @returns Whether the child renders Records.
|
|
64
|
+
*/
|
|
65
|
+
function isRecordsChild(child: ComponentDefinition): boolean {
|
|
66
|
+
return child.of === "records" || schema.componentDefinitions[child.of ?? ""]?.of === "records";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let viewChildren = children;
|
|
70
|
+
if (headerOnly) {
|
|
71
|
+
viewChildren = children.filter((child) => child.name === "apphead");
|
|
72
|
+
} else if (pending) {
|
|
73
|
+
viewChildren = [];
|
|
74
|
+
if (pendingHeading) {
|
|
75
|
+
viewChildren = children.filter((child) => {
|
|
76
|
+
const { node } = schema.configuredComponent(child);
|
|
77
|
+
return (
|
|
78
|
+
child.name === "apphead" ||
|
|
79
|
+
isRecordsChild(child) ||
|
|
80
|
+
node.of === "heading" ||
|
|
81
|
+
(node.of === "lorem" && (node.tag === "h1" || child.name === "heading"))
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const parentProps = { ...router.params, ...(filter === undefined ? {} : { filter }) };
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define, @typescript-eslint/no-unsafe-type-assertion -- Document bindings accept runtime page data.
|
|
88
|
+
usePageDocument(schema as Schema<unknown>, view.layout, data);
|
|
89
|
+
return (
|
|
90
|
+
<RouterContext.Provider value={router}>
|
|
91
|
+
<div className={view.className ?? ""} data-tiun-view={view.name} onClick={onClick}>
|
|
92
|
+
{renderConfiguredChildren?.(viewChildren, (child) => {
|
|
93
|
+
let key = child.name;
|
|
94
|
+
if (key !== "apphead") {
|
|
95
|
+
key = `${owner}:${key}`;
|
|
96
|
+
}
|
|
97
|
+
return (
|
|
98
|
+
<Component
|
|
99
|
+
key={key}
|
|
100
|
+
schema={schema}
|
|
101
|
+
definition={child}
|
|
102
|
+
data={data}
|
|
103
|
+
parentProps={parentProps}
|
|
104
|
+
parents={[view.name]}
|
|
105
|
+
{...(pending && isRecordsChild(child) && { state: "loading" as const })}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
})}
|
|
109
|
+
{pending && !headerOnly && !viewChildren.some(isRecordsChild) && (
|
|
110
|
+
<Loader
|
|
111
|
+
label={
|
|
112
|
+
configuredLabel(labels, "loading") ?? view.labels?.loading ?? language.t("tiun.common.loading")
|
|
113
|
+
}
|
|
114
|
+
/>
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
</RouterContext.Provider>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Renders a view with its configured children outside the route dispatcher.
|
|
123
|
+
* @param props View definition, schema and router state.
|
|
124
|
+
* @returns The view with the decorators enabled by its definition.
|
|
125
|
+
*/
|
|
126
|
+
export function View<T>(props: ViewProps<T>): React.ReactElement {
|
|
127
|
+
const definition = props.schema.pageDefinitions[props.view.name],
|
|
128
|
+
node = definition && props.schema.configuredComponent(definition).node;
|
|
129
|
+
let declaration: unknown;
|
|
130
|
+
if (props.pending !== true && props.headerOnly !== true) {
|
|
131
|
+
declaration = node?.with;
|
|
132
|
+
}
|
|
133
|
+
// eslint-disable-next-line one-var -- Decorators depend on the view's loading and access state.
|
|
134
|
+
const decorated = decorateComponent<T, ViewProps<T>>(viewComponent<T>, props.schema, declaration, node);
|
|
135
|
+
return React.createElement(decorated, props);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Selects a configured view's data, scoped registry and optional link handler.
|
|
140
|
+
* - The routed view uses the method name as its key before invoking the hook.
|
|
141
|
+
* @param props The current view, router and schema.
|
|
142
|
+
* @returns The properties to pass to the standard view.
|
|
143
|
+
*/
|
|
144
|
+
// eslint-disable-next-line one-var -- Separate the hook from the view it configures.
|
|
145
|
+
const useViewBindings = <T,>(
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- A view shares the schema and router.
|
|
147
|
+
props: ViewProps<T>,
|
|
148
|
+
): Pick<ViewProps<T>, "data" | "onClick" | "schema"> => {
|
|
149
|
+
const name = props.view.contextMethod,
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Named methods prepare the runtime shape of view data.
|
|
151
|
+
schema = props.schema as Schema<unknown>;
|
|
152
|
+
let scopedSchema = props.schema,
|
|
153
|
+
selected: ViewContextMethod | undefined;
|
|
154
|
+
if (props.pending !== true && props.headerOnly !== true && typeof name === "string" && name !== "") {
|
|
155
|
+
selected = props.schema.viewContext(name);
|
|
156
|
+
if (typeof selected === "undefined") {
|
|
157
|
+
throw new TypeError(props.schema.i18n.t("tiun.errors.view.context_method", { name }));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// eslint-disable-next-line one-var -- Resolve and validate the method before calling it.
|
|
161
|
+
const context = (selected ?? emptyViewData)({ router: props.router, schema });
|
|
162
|
+
if (context.registry) {
|
|
163
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- The registry extends the view's own schema.
|
|
164
|
+
scopedSchema = schema.withRegistry(context.registry) as Schema<T>;
|
|
165
|
+
}
|
|
166
|
+
return { data: context.data, onClick: context.onClick ?? props.onClick, schema: scopedSchema };
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Converts URL query values into the filter shape accepted by configured components.
|
|
171
|
+
* @param query Current URL query parameters.
|
|
172
|
+
* @returns Query fields with repeated values preserved as arrays, or undefined when empty.
|
|
173
|
+
*/
|
|
174
|
+
function urlFilter(query: URLSearchParams): Readonly<Record<string, unknown>> | undefined {
|
|
175
|
+
const values = new Map<string, string[]>();
|
|
176
|
+
query.forEach((value, key) => values.set(key, [...(values.get(key) ?? []), value]));
|
|
177
|
+
return values.size
|
|
178
|
+
? Object.fromEntries([...values].map(([key, entries]) => [key, entries.length === 1 ? entries[0] : entries]))
|
|
179
|
+
: undefined;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Renders a configured page with the current query and the bindings prepared by its method.
|
|
184
|
+
* - The router mounts a new instance when the method name changes.
|
|
185
|
+
* @param props Matched view, schema and router state.
|
|
186
|
+
* @returns The standard View with its properties and scoped schema.
|
|
187
|
+
*/
|
|
188
|
+
export function RoutedView<T>(props: ViewProps<T>) {
|
|
189
|
+
let declaration: unknown;
|
|
190
|
+
if (props.pending !== true && props.headerOnly !== true) {
|
|
191
|
+
declaration = props.view.with;
|
|
192
|
+
}
|
|
193
|
+
const bindings = useViewBindings(props),
|
|
194
|
+
definition = props.schema.pageDefinitions[props.view.name],
|
|
195
|
+
node = definition && props.schema.configuredComponent(definition).node,
|
|
196
|
+
decorated = decorateComponent<T, ViewProps<T>>(viewComponent<T>, props.schema, declaration, node),
|
|
197
|
+
filter = urlFilter(props.router.query);
|
|
198
|
+
return React.createElement<ViewProps<T>>(decorated, { ...props, ...bindings, filter: filter ?? props.filter });
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Applies the current page properties and uses the selected i18n locale for HTML language.
|
|
203
|
+
* @param schema Schema holding the document bindings and current locale.
|
|
204
|
+
* @param layout Effective page layout.
|
|
205
|
+
* @param data Current page data used by document bindings.
|
|
206
|
+
* @param enabled Whether this view owns document metadata.
|
|
207
|
+
* @returns Nothing. Applies page metadata through document effects.
|
|
208
|
+
*/
|
|
209
|
+
export function usePageDocument<T>(schema: Schema<T>, layout: Layout | undefined, data: T, enabled = true): void {
|
|
210
|
+
const lang = layout?.lang ?? schema.i18n.selection.locale?.replaceAll("_", "-");
|
|
211
|
+
useDocumentHead(enabled ? configuredHead(schema, layout?.head, data) : {});
|
|
212
|
+
useDocumentAttributes("documentElement", enabled ? attributes(schema, { dir: layout?.dir, lang }, data) : {});
|
|
213
|
+
useDocumentAttributes("body", enabled ? attributes(schema, layout?.body ?? {}, data) : {});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const documentAttribute = /^(?:class|id|dir|lang|role|title|tabindex|(?:aria|data)-[a-z0-9-]+)$/;
|
|
217
|
+
|
|
218
|
+
function attributes<T>(
|
|
219
|
+
schema: Schema<T>,
|
|
220
|
+
properties: Readonly<Record<string, unknown>>,
|
|
221
|
+
data: T,
|
|
222
|
+
): Record<string, string> {
|
|
223
|
+
return Object.fromEntries(
|
|
224
|
+
Object.entries(properties).flatMap(([name, binding]) => {
|
|
225
|
+
if (!documentAttribute.test(name)) {
|
|
226
|
+
return [];
|
|
227
|
+
}
|
|
228
|
+
const value = bindingValue(binding, data, schema.i18n.t, false);
|
|
229
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
230
|
+
? [[name, String(value)]]
|
|
231
|
+
: [];
|
|
232
|
+
}),
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function useDocumentAttributes(target: "documentElement" | "body", values: Record<string, string>): void {
|
|
237
|
+
const signature = JSON.stringify(values);
|
|
238
|
+
useEffect(() => {
|
|
239
|
+
const element = document[target],
|
|
240
|
+
restore = Object.entries(values).map(([name, value]) => {
|
|
241
|
+
if (name === "class") {
|
|
242
|
+
return addClasses(element, value);
|
|
243
|
+
}
|
|
244
|
+
const previous = element.getAttribute(name);
|
|
245
|
+
element.setAttribute(name, value);
|
|
246
|
+
return () => {
|
|
247
|
+
if (element.getAttribute(name) !== value) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (previous === null) {
|
|
251
|
+
element.removeAttribute(name);
|
|
252
|
+
} else {
|
|
253
|
+
element.setAttribute(name, previous);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
return () => {
|
|
258
|
+
restore.forEach((reset) => {
|
|
259
|
+
reset();
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
}, [target, signature]);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function addClasses(element: HTMLElement, value: string): () => void {
|
|
266
|
+
const existingClasses = element.getAttribute("class"),
|
|
267
|
+
newClasses = value.split(/\s+/).filter((name) => name && !element.classList.contains(name));
|
|
268
|
+
if (!newClasses.length) {
|
|
269
|
+
return () => {};
|
|
270
|
+
}
|
|
271
|
+
element.classList.add(...newClasses);
|
|
272
|
+
return () => {
|
|
273
|
+
element.classList.remove(...newClasses);
|
|
274
|
+
if (existingClasses === null && element.classList.length === 0) {
|
|
275
|
+
element.removeAttribute("class");
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
$dark: #122a32;
|
|
2
|
+
$smooth_dark: #405a63;
|
|
3
|
+
$terracota: #0f766e;
|
|
4
|
+
$background: #f8fafc;
|
|
5
|
+
$ink: #122a32;
|
|
6
|
+
$inverted_ink: #f0f0f0;
|
|
7
|
+
$gold: #d4af37;
|
|
8
|
+
$book: #ffffff; //TODO make real book color
|
|
9
|
+
$lighten_terracota: #2a9d8f;
|
|
10
|
+
$darken_terracota: #075985;
|
|
11
|
+
$grayed_terracota: #c7e8e4;
|
|
12
|
+
$lighten_gold: #fcc200;
|
|
13
|
+
$darken_gold: #cfb53b;
|
|
14
|
+
$soft_blue: #075985;
|
|
15
|
+
$small_height: 30rem;
|
|
16
|
+
$medium_height: 45rem;
|
|
17
|
+
$large_height: 60rem;
|
|
18
|
+
$small_width: 40rem;
|
|
19
|
+
$medium_width: 60rem;
|
|
20
|
+
$large_width: 80rem;
|
|
21
|
+
$xlarge_width: 100rem;
|
|
22
|
+
$today_color: #0369a1;
|
|
23
|
+
$selected_color: #0f766e;
|
|
24
|
+
$lighten_selected_color: #bae6fd;
|
|
25
|
+
$error_color: Red;
|
|
26
|
+
$mooncolor: #a8aeb3;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
.tiun-calendar {
|
|
2
|
+
container-type: inline-size;
|
|
3
|
+
|
|
4
|
+
button:hover:not(:disabled) {
|
|
5
|
+
filter: brightness(0.96);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.tiun-calendar[data-style="round"] {
|
|
10
|
+
.tiun-calendar-types button {
|
|
11
|
+
border: 0;
|
|
12
|
+
font-size: 1rem;
|
|
13
|
+
font-size: min(0.9rem, 5.5cqi);
|
|
14
|
+
letter-spacing: normal;
|
|
15
|
+
line-height: 2rem;
|
|
16
|
+
transition:
|
|
17
|
+
background-color 0.3s,
|
|
18
|
+
box-shadow 0.3s;
|
|
19
|
+
|
|
20
|
+
&[aria-pressed="true"] {
|
|
21
|
+
background-color: var(--tiun-calendar-active-type);
|
|
22
|
+
color: #fff;
|
|
23
|
+
box-shadow:
|
|
24
|
+
0 0.2rem 0.8rem rgba(0, 0, 0, 0.2),
|
|
25
|
+
inset 0 -0.1rem rgba(0, 0, 0, 0.22);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.tiun-calendar-types button:first-child {
|
|
30
|
+
flex: 42;
|
|
31
|
+
}
|
|
32
|
+
.tiun-calendar-types button:last-child {
|
|
33
|
+
flex: 58;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.tiun-calendar-day {
|
|
37
|
+
border: 0;
|
|
38
|
+
max-width: 100%;
|
|
39
|
+
margin: 0;
|
|
40
|
+
padding: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.tiun-calendar-primary,
|
|
44
|
+
.tiun-calendar-secondary {
|
|
45
|
+
line-height: 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.tiun-calendar-primary {
|
|
49
|
+
font-size: 1.2rem;
|
|
50
|
+
font-size: min(1.2rem, 7.5cqi);
|
|
51
|
+
|
|
52
|
+
&:has(+ .tiun-calendar-secondary) {
|
|
53
|
+
transform: translateY(1px);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.tiun-calendar-secondary {
|
|
58
|
+
font-size: calc(0.5375rem + 0.5px);
|
|
59
|
+
font-size: calc(min(0.6rem, 3.75cqi) - 0.0625rem + 0.5px);
|
|
60
|
+
transform: translateY(-0.5px);
|
|
61
|
+
}
|
|
62
|
+
.tiun-calendar-day:is([data-today="true"], [data-selected="true"]) {
|
|
63
|
+
color: var(--tiun-calendar-on-selected, #fff);
|
|
64
|
+
text-decoration: none;
|
|
65
|
+
box-shadow: none;
|
|
66
|
+
}
|
|
67
|
+
.tiun-calendar-day[data-today="true"][data-selected="true"] {
|
|
68
|
+
box-shadow: inset 0 0 0 0.15rem var(--tiun-calendar-selected, DeepSkyBlue);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.tiun-calendar[data-style="ortho"] {
|
|
73
|
+
--tiun-calendar-on-selected: #fff;
|
|
74
|
+
.tiun-calendar-types button {
|
|
75
|
+
font-size: min(1rem, 5cqi);
|
|
76
|
+
&[aria-pressed="true"] {
|
|
77
|
+
color: #fff;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.calendar-style-switch {
|
|
83
|
+
position: relative;
|
|
84
|
+
display: inline-flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
gap: 0.5rem;
|
|
87
|
+
margin-block: 0.75rem;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
border: 0;
|
|
90
|
+
padding: 0;
|
|
91
|
+
background: transparent;
|
|
92
|
+
color: inherit;
|
|
93
|
+
font: inherit;
|
|
94
|
+
letter-spacing: normal;
|
|
95
|
+
text-transform: none;
|
|
96
|
+
.calendar-style-track {
|
|
97
|
+
position: relative;
|
|
98
|
+
width: 2.5rem;
|
|
99
|
+
height: 1.4rem;
|
|
100
|
+
border: 1px solid currentColor;
|
|
101
|
+
border-radius: 1rem;
|
|
102
|
+
background: #d1ded9;
|
|
103
|
+
}
|
|
104
|
+
.calendar-style-track::after {
|
|
105
|
+
content: "";
|
|
106
|
+
position: absolute;
|
|
107
|
+
top: 0.15rem;
|
|
108
|
+
left: 0.15rem;
|
|
109
|
+
width: 1rem;
|
|
110
|
+
height: 1rem;
|
|
111
|
+
border-radius: 50%;
|
|
112
|
+
background: #fff;
|
|
113
|
+
transition: transform 160ms ease;
|
|
114
|
+
}
|
|
115
|
+
&[aria-checked="true"] .calendar-style-track {
|
|
116
|
+
background: #007d73;
|
|
117
|
+
}
|
|
118
|
+
&[aria-checked="true"] .calendar-style-track::after {
|
|
119
|
+
transform: translateX(1.1rem);
|
|
120
|
+
}
|
|
121
|
+
&:focus-visible .calendar-style-track {
|
|
122
|
+
outline: 2px solid #007d73;
|
|
123
|
+
outline-offset: 3px;
|
|
124
|
+
}
|
|
125
|
+
&:disabled span {
|
|
126
|
+
opacity: 0.6;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
@media (prefers-reduced-motion: reduce) {
|
|
130
|
+
.calendar-style-track::after {
|
|
131
|
+
transition: none;
|
|
132
|
+
}
|
|
133
|
+
}
|