@wix/patterns-fields 1.108.0 → 1.109.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.
- package/dist/cjs/components/address/input/address-input.st.css.js +3 -3
- package/dist/cjs/components/address/input/address-input.st.css.js.map +1 -1
- package/dist/cjs/components/audio/actions/actions-menu/actions-menu.st.css.js +3 -3
- package/dist/cjs/components/audio/actions/actions-menu/actions-menu.st.css.js.map +1 -1
- package/dist/cjs/components/audio/audio-field/form-audio-field.st.css.js +4 -4
- package/dist/cjs/components/audio/audio-field/form-audio-field.st.css.js.map +1 -1
- package/dist/cjs/components/audio/audio-player/audio-player.st.css.js +2 -2
- package/dist/cjs/components/audio/audio-player/audio-player.st.css.js.map +1 -1
- package/dist/cjs/components/color-view/cell-color-view.st.css.js +3 -3
- package/dist/cjs/components/color-view/cell-color-view.st.css.js.map +1 -1
- package/dist/cjs/components/color-view/color-view.st.css.js +4 -4
- package/dist/cjs/components/color-view/color-view.st.css.js.map +1 -1
- package/dist/cjs/components/date-input/cell-date-input.js +21 -2
- package/dist/cjs/components/date-input/cell-date-input.js.map +1 -1
- package/dist/cjs/components/date-input/date-picker-internals.js +93 -3
- package/dist/cjs/components/date-input/date-picker-internals.js.map +1 -1
- package/dist/cjs/components/date-input/form-date-input.driver.js +2 -0
- package/dist/cjs/components/date-input/form-date-input.driver.js.map +1 -1
- package/dist/cjs/components/date-input/form-date-input.js +23 -6
- package/dist/cjs/components/date-input/form-date-input.js.map +1 -1
- package/dist/cjs/components/date-input/use-field-value-replacement.js +48 -0
- package/dist/cjs/components/date-input/use-field-value-replacement.js.map +1 -0
- package/dist/cjs/components/datetime-input/form-date-time.driver.js +3 -0
- package/dist/cjs/components/datetime-input/form-date-time.driver.js.map +1 -1
- package/dist/cjs/components/datetime-input/form-date-time.js +61 -24
- package/dist/cjs/components/datetime-input/form-date-time.js.map +1 -1
- package/dist/cjs/components/delete-dialog/delete-dialog.st.css.js +3 -3
- package/dist/cjs/components/delete-dialog/delete-dialog.st.css.js.map +1 -1
- package/dist/cjs/components/document/form-document-field.st.css.js +7 -7
- package/dist/cjs/components/document/form-document-field.st.css.js.map +1 -1
- package/dist/cjs/components/exclamation/exclamation.st.css.js +5 -5
- package/dist/cjs/components/exclamation/exclamation.st.css.js.map +1 -1
- package/dist/cjs/components/highlighted-text/highlighted-text.st.css.js +5 -5
- package/dist/cjs/components/highlighted-text/highlighted-text.st.css.js.map +1 -1
- package/dist/cjs/components/image/thumbnail-replace-overlay.st.css.js +3 -3
- package/dist/cjs/components/image/thumbnail-replace-overlay.st.css.js.map +1 -1
- package/dist/cjs/components/media-control/cell-media-edit-shell.st.css.js +2 -2
- package/dist/cjs/components/media-control/cell-media-edit-shell.st.css.js.map +1 -1
- package/dist/cjs/components/media-control/paste-url-button.st.css.js +4 -4
- package/dist/cjs/components/media-control/paste-url-button.st.css.js.map +1 -1
- package/dist/cjs/components/media-gallery/form-media-gallery-field.st.css.js +10 -10
- package/dist/cjs/components/media-gallery/form-media-gallery-field.st.css.js.map +1 -1
- package/dist/cjs/components/media-image/media-image.st.css.js +4 -4
- package/dist/cjs/components/media-image/media-image.st.css.js.map +1 -1
- package/dist/cjs/components/media-image/overlays/overlay.st.css.js +3 -3
- package/dist/cjs/components/media-image/overlays/overlay.st.css.js.map +1 -1
- package/dist/cjs/components/media-tag/web-media-tag/media-tag.st.css.js +2 -2
- package/dist/cjs/components/media-tag/web-media-tag/media-tag.st.css.js.map +1 -1
- package/dist/cjs/components/multi-document/cell-multi-document-edit.st.css.js +3 -3
- package/dist/cjs/components/multi-document/cell-multi-document-edit.st.css.js.map +1 -1
- package/dist/cjs/components/multi-document/multi-document-input/form-multi-document.st.css.js +5 -5
- package/dist/cjs/components/multi-document/multi-document-input/form-multi-document.st.css.js.map +1 -1
- package/dist/cjs/components/reference/cell-multi-reference-input.st.css.js +2 -2
- package/dist/cjs/components/reference/cell-multi-reference-input.st.css.js.map +1 -1
- package/dist/cjs/components/reference/cell-reference-input.st.css.js +3 -3
- package/dist/cjs/components/reference/cell-reference-input.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/default-value-input/rich-content-default-value-input.st.css.js +4 -4
- package/dist/cjs/components/rich-content/rich-content-input/default-value-input/rich-content-default-value-input.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/form-input/rich-content-form-input.st.css.js +3 -3
- package/dist/cjs/components/rich-content/rich-content-input/form-input/rich-content-form-input.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/form-read-only-input/rich-content-form-read-only-input.st.css.js +2 -2
- package/dist/cjs/components/rich-content/rich-content-input/form-read-only-input/rich-content-form-read-only-input.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.js +3 -3
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/publish-loader/publish-loader.st.css.js +3 -3
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/publish-loader/publish-loader.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/toggle-fullscreen-button/toggle-fullscreen-button.st.css.js +2 -2
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-common/toggle-fullscreen-button/toggle-fullscreen-button.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.st.css.js +7 -7
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css.js +5 -5
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css.js.map +1 -1
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.st.css.js +4 -4
- package/dist/cjs/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.st.css.js.map +1 -1
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/rich-editor.st.css.js +18 -18
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/rich-editor.st.css.js.map +1 -1
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/rich-text-editor.st.css.js +4 -4
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/rich-text-editor.st.css.js.map +1 -1
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/toolbar/toolbar.st.css.js +18 -18
- package/dist/cjs/components/rich-text/rich-text-input/rich-text-editor/toolbar/toolbar.st.css.js.map +1 -1
- package/dist/cjs/components/text/form-short-text.js +1 -1
- package/dist/cjs/components/text/form-short-text.js.map +1 -1
- package/dist/cjs/components/text/text-view.st.css.js +3 -3
- package/dist/cjs/components/text/text-view.st.css.js.map +1 -1
- package/dist/cjs/styles.global.css +1 -1
- package/dist/esm/components/address/input/address-input.st.css.js +2 -2
- package/dist/esm/components/address/input/address-input.st.css.js.map +1 -1
- package/dist/esm/components/audio/actions/actions-menu/actions-menu.st.css.js +2 -2
- package/dist/esm/components/audio/actions/actions-menu/actions-menu.st.css.js.map +1 -1
- package/dist/esm/components/audio/audio-field/form-audio-field.st.css.js +2 -2
- package/dist/esm/components/audio/audio-field/form-audio-field.st.css.js.map +1 -1
- package/dist/esm/components/audio/audio-player/audio-player.st.css.js +2 -2
- package/dist/esm/components/color-view/cell-color-view.st.css.js +2 -2
- package/dist/esm/components/color-view/color-view.st.css.js +2 -2
- package/dist/esm/components/date-input/cell-date-input.js +21 -2
- package/dist/esm/components/date-input/cell-date-input.js.map +1 -1
- package/dist/esm/components/date-input/date-picker-internals.js +67 -0
- package/dist/esm/components/date-input/date-picker-internals.js.map +1 -1
- package/dist/esm/components/date-input/form-date-input.driver.js +2 -0
- package/dist/esm/components/date-input/form-date-input.driver.js.map +1 -1
- package/dist/esm/components/date-input/form-date-input.js +25 -4
- package/dist/esm/components/date-input/form-date-input.js.map +1 -1
- package/dist/esm/components/date-input/use-field-value-replacement.js +48 -0
- package/dist/esm/components/date-input/use-field-value-replacement.js.map +1 -0
- package/dist/esm/components/datetime-input/form-date-time.driver.js +3 -0
- package/dist/esm/components/datetime-input/form-date-time.driver.js.map +1 -1
- package/dist/esm/components/datetime-input/form-date-time.js +51 -21
- package/dist/esm/components/datetime-input/form-date-time.js.map +1 -1
- package/dist/esm/components/delete-dialog/delete-dialog.st.css.js +2 -2
- package/dist/esm/components/delete-dialog/delete-dialog.st.css.js.map +1 -1
- package/dist/esm/components/document/form-document-field.st.css.js +2 -2
- package/dist/esm/components/exclamation/exclamation.st.css.js +2 -2
- package/dist/esm/components/highlighted-text/highlighted-text.st.css.js +3 -3
- package/dist/esm/components/image/thumbnail-replace-overlay.st.css.js +2 -2
- package/dist/esm/components/media-control/cell-media-edit-shell.st.css.js +2 -2
- package/dist/esm/components/media-control/cell-media-edit-shell.st.css.js.map +1 -1
- package/dist/esm/components/media-control/paste-url-button.st.css.js +2 -2
- package/dist/esm/components/media-gallery/form-media-gallery-field.st.css.js +2 -2
- package/dist/esm/components/media-gallery/form-media-gallery-field.st.css.js.map +1 -1
- package/dist/esm/components/media-image/media-image.st.css.js +3 -3
- package/dist/esm/components/media-image/overlays/overlay.st.css.js +2 -2
- package/dist/esm/components/media-image/overlays/overlay.st.css.js.map +1 -1
- package/dist/esm/components/media-tag/web-media-tag/media-tag.st.css.js +2 -2
- package/dist/esm/components/multi-document/cell-multi-document-edit.st.css.js +2 -2
- package/dist/esm/components/multi-document/multi-document-input/form-multi-document.st.css.js +2 -2
- package/dist/esm/components/multi-document/multi-document-input/form-multi-document.st.css.js.map +1 -1
- package/dist/esm/components/reference/cell-multi-reference-input.st.css.js +2 -2
- package/dist/esm/components/reference/cell-reference-input.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/default-value-input/rich-content-default-value-input.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/default-value-input/rich-content-default-value-input.st.css.js.map +1 -1
- package/dist/esm/components/rich-content/rich-content-input/form-input/rich-content-form-input.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/form-read-only-input/rich-content-form-read-only-input.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.js.map +1 -1
- package/dist/esm/components/rich-content/rich-content-input/rich-content-common/publish-loader/publish-loader.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-common/publish-loader/publish-loader.st.css.js.map +1 -1
- package/dist/esm/components/rich-content/rich-content-input/rich-content-common/toggle-fullscreen-button/toggle-fullscreen-button.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css.js +2 -2
- package/dist/esm/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.st.css.js +2 -2
- package/dist/esm/components/rich-text/rich-text-input/rich-text-editor/rich-editor.st.css.js +2 -2
- package/dist/esm/components/rich-text/rich-text-input/rich-text-editor/rich-text-editor.st.css.js +2 -2
- package/dist/esm/components/rich-text/rich-text-input/rich-text-editor/toolbar/toolbar.st.css.js +2 -2
- package/dist/esm/components/rich-text/rich-text-input/rich-text-editor/toolbar/toolbar.st.css.js.map +1 -1
- package/dist/esm/components/text/form-short-text.js +1 -1
- package/dist/esm/components/text/form-short-text.js.map +1 -1
- package/dist/esm/components/text/text-view.st.css.js +2 -2
- package/dist/esm/components/text/text-view.st.css.js.map +1 -1
- package/dist/esm/styles.global.css +1 -1
- package/dist/types/components/address/input/address-input.st.css.d.ts.map +1 -1
- package/dist/types/components/audio/actions/actions-menu/actions-menu.st.css.d.ts.map +1 -1
- package/dist/types/components/audio/audio-field/form-audio-field.st.css.d.ts.map +1 -1
- package/dist/types/components/date-input/cell-date-input.d.ts +4 -0
- package/dist/types/components/date-input/cell-date-input.d.ts.map +1 -1
- package/dist/types/components/date-input/date-picker-internals.d.ts +11 -1
- package/dist/types/components/date-input/date-picker-internals.d.ts.map +1 -1
- package/dist/types/components/date-input/form-date-input.d.ts.map +1 -1
- package/dist/types/components/date-input/form-date-input.driver.d.ts +2 -0
- package/dist/types/components/date-input/form-date-input.driver.d.ts.map +1 -1
- package/dist/types/components/date-input/use-field-value-replacement.d.ts +3 -0
- package/dist/types/components/date-input/use-field-value-replacement.d.ts.map +1 -0
- package/dist/types/components/datetime-input/form-date-time.d.ts.map +1 -1
- package/dist/types/components/datetime-input/form-date-time.driver.d.ts +3 -0
- package/dist/types/components/datetime-input/form-date-time.driver.d.ts.map +1 -1
- package/dist/types/components/delete-dialog/delete-dialog.st.css.d.ts.map +1 -1
- package/dist/types/components/media-control/cell-media-edit-shell.st.css.d.ts.map +1 -1
- package/dist/types/components/media-gallery/form-media-gallery-field.st.css.d.ts.map +1 -1
- package/dist/types/components/media-image/overlays/overlay.st.css.d.ts.map +1 -1
- package/dist/types/components/multi-document/multi-document-input/form-multi-document.st.css.d.ts.map +1 -1
- package/dist/types/components/rich-content/rich-content-input/default-value-input/rich-content-default-value-input.st.css.d.ts.map +1 -1
- package/dist/types/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.d.ts.map +1 -1
- package/dist/types/components/rich-content/rich-content-input/rich-content-common/publish-loader/publish-loader.st.css.d.ts.map +1 -1
- package/dist/types/components/rich-text/rich-text-input/rich-text-editor/toolbar/toolbar.st.css.d.ts.map +1 -1
- package/dist/types/components/text/text-view.st.css.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/components/date-input/cell-date-input.spec.tsx +100 -0
- package/src/__tests__/components/date-input/date-picker-internals.spec.tsx +69 -0
- package/src/__tests__/components/date-input/form-date-input.spec.tsx +141 -0
- package/src/__tests__/components/datetime-input/form-date-time.spec.tsx +194 -0
- package/src/__tests__/components/text/form-short-text.spec.tsx +27 -0
- package/src/__tests__/form-field.driver.tsx +31 -3
- package/src/__tests__/hooks/use-field-value-replacement.spec.tsx +68 -0
- package/src/components/address/input/address-input.st.css.ts +2 -2
- package/src/components/audio/actions/actions-menu/actions-menu.st.css.ts +2 -2
- package/src/components/audio/audio-field/form-audio-field.st.css.ts +2 -2
- package/src/components/audio/audio-player/audio-player.st.css.ts +2 -2
- package/src/components/color-view/cell-color-view.st.css.ts +2 -2
- package/src/components/color-view/color-view.st.css.ts +2 -2
- package/src/components/date-input/cell-date-input.tsx +28 -0
- package/src/components/date-input/date-picker-internals.ts +104 -3
- package/src/components/date-input/form-date-input.driver.ts +2 -0
- package/src/components/date-input/form-date-input.tsx +25 -3
- package/src/components/date-input/use-field-value-replacement.ts +63 -0
- package/src/components/datetime-input/form-date-time.driver.ts +3 -0
- package/src/components/datetime-input/form-date-time.tsx +55 -33
- package/src/components/delete-dialog/delete-dialog.st.css.ts +2 -2
- package/src/components/document/form-document-field.st.css.ts +2 -2
- package/src/components/exclamation/exclamation.st.css.ts +2 -2
- package/src/components/highlighted-text/highlighted-text.st.css.ts +3 -3
- package/src/components/image/thumbnail-replace-overlay.st.css.ts +2 -2
- package/src/components/media-control/cell-media-edit-shell.st.css.ts +2 -2
- package/src/components/media-control/paste-url-button.st.css.ts +2 -2
- package/src/components/media-gallery/form-media-gallery-field.st.css.ts +2 -2
- package/src/components/media-image/media-image.st.css.ts +3 -3
- package/src/components/media-image/overlays/overlay.st.css.ts +2 -2
- package/src/components/media-tag/web-media-tag/media-tag.st.css.ts +2 -2
- package/src/components/multi-document/cell-multi-document-edit.st.css.ts +2 -2
- package/src/components/multi-document/multi-document-input/form-multi-document.st.css.ts +2 -2
- package/src/components/reference/cell-multi-reference-input.st.css.ts +2 -2
- package/src/components/reference/cell-reference-input.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/default-value-input/rich-content-default-value-input.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/form-input/rich-content-form-input.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/form-read-only-input/rich-content-form-read-only-input.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-common/fullscreen-modal/fullscreen-modal.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-common/publish-loader/publish-loader.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-common/toggle-fullscreen-button/toggle-fullscreen-button.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-editor/rich-content-editor.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-editor/rich-content-toolbar.st.css.ts +2 -2
- package/src/components/rich-content/rich-content-input/rich-content-viewer/rich-content-viewer.st.css.ts +2 -2
- package/src/components/rich-text/rich-text-input/rich-text-editor/rich-editor.st.css.ts +2 -2
- package/src/components/rich-text/rich-text-input/rich-text-editor/rich-text-editor.st.css.ts +2 -2
- package/src/components/rich-text/rich-text-input/rich-text-editor/toolbar/toolbar.st.css.ts +2 -2
- package/src/components/text/form-short-text.tsx +1 -1
- package/src/components/text/text-view.st.css.ts +2 -2
- package/src/styles.global.css +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import '../../testkit/test-polyfills';
|
|
2
|
+
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
import { useForm } from '@wix/bex-core/form';
|
|
6
|
+
import type { Control } from '@wix/bex-core/form';
|
|
7
|
+
|
|
8
|
+
import { FormDateInput } from '../../components/date-input/form-date-input';
|
|
9
|
+
import { FormDateTime } from '../../components/datetime-input/form-date-time';
|
|
10
|
+
import { useFieldValueReplacement } from '../../components/date-input/use-field-value-replacement';
|
|
11
|
+
import { PatternsFieldsTestProvider } from '../../testkit/patterns-fields-test-provider';
|
|
12
|
+
import { makeField } from '../form-field.driver';
|
|
13
|
+
|
|
14
|
+
describe('useFieldValueReplacement compatibility', () => {
|
|
15
|
+
it.each([
|
|
16
|
+
['Date', FormDateInput, 'DATE'],
|
|
17
|
+
['DateTime', FormDateTime, 'DATETIME'],
|
|
18
|
+
] as const)(
|
|
19
|
+
'renders %s without exposed subjects',
|
|
20
|
+
(_name, Component, type) => {
|
|
21
|
+
const field = makeField({ type });
|
|
22
|
+
const Example = () => {
|
|
23
|
+
const form = useForm();
|
|
24
|
+
const control = useMemo(() => {
|
|
25
|
+
const { _subjects, ...rest } = form.control;
|
|
26
|
+
return rest as Control;
|
|
27
|
+
}, [form.control]);
|
|
28
|
+
return (
|
|
29
|
+
<Component
|
|
30
|
+
field={field}
|
|
31
|
+
value={null}
|
|
32
|
+
onChange={() => {}}
|
|
33
|
+
data={{}}
|
|
34
|
+
formControl={control}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const result = render(<Example />, {
|
|
40
|
+
wrapper: PatternsFieldsTestProvider,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
expect(result.getByText(field.displayName)).toBeTruthy();
|
|
44
|
+
result.unmount();
|
|
45
|
+
},
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
it.each([
|
|
49
|
+
undefined,
|
|
50
|
+
{},
|
|
51
|
+
{ state: {}, array: {} },
|
|
52
|
+
{ state: { subscribe: jest.fn() } },
|
|
53
|
+
{ array: { subscribe: jest.fn() } },
|
|
54
|
+
])('skips cleanup for an unsupported subject shape: %p', (subjects) => {
|
|
55
|
+
const onReplace = jest.fn();
|
|
56
|
+
const control = { _subjects: subjects } as unknown as Control;
|
|
57
|
+
const Example = () => {
|
|
58
|
+
const revision = useFieldValueReplacement(control, 'date', onReplace);
|
|
59
|
+
return <span>{revision}</span>;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const result = render(<Example />);
|
|
63
|
+
|
|
64
|
+
expect(result.getByText('0')).toBeTruthy();
|
|
65
|
+
expect(onReplace).not.toHaveBeenCalled();
|
|
66
|
+
result.unmount();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -5,7 +5,7 @@ import { classesRuntime, statesRuntime } from "../../../stylable-esm-runtime.js"
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var _namespace_ = "
|
|
8
|
+
var _namespace_ = "addressinput310286819";
|
|
9
9
|
var _style_ = classesRuntime.bind(null, _namespace_);
|
|
10
10
|
|
|
11
11
|
export var cssStates = statesRuntime.bind(null, _namespace_);
|
|
@@ -13,7 +13,7 @@ export var style: import("@stylable/runtime").STFunction = _style_;
|
|
|
13
13
|
export var st: import("@stylable/runtime").STFunction = _style_;
|
|
14
14
|
|
|
15
15
|
export var namespace = _namespace_;
|
|
16
|
-
export var classes = {"root":"
|
|
16
|
+
export var classes = {"root":"addressinput310286819__root","tableAddressInput":"addressinput310286819__tableAddressInput"};
|
|
17
17
|
export var keyframes = {};
|
|
18
18
|
export var layers = {};
|
|
19
19
|
export var containers = {};
|
|
@@ -5,7 +5,7 @@ import { classesRuntime, statesRuntime } from "../../../../stylable-esm-runtime.
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var _namespace_ = "
|
|
8
|
+
var _namespace_ = "actionsmenu2642433213";
|
|
9
9
|
var _style_ = classesRuntime.bind(null, _namespace_);
|
|
10
10
|
|
|
11
11
|
export var cssStates = statesRuntime.bind(null, _namespace_);
|
|
@@ -13,7 +13,7 @@ export var style: import("@stylable/runtime").STFunction = _style_;
|
|
|
13
13
|
export var st: import("@stylable/runtime").STFunction = _style_;
|
|
14
14
|
|
|
15
15
|
export var namespace = _namespace_;
|
|
16
|
-
export var classes = {"root":"
|
|
16
|
+
export var classes = {"root":"actionsmenu2642433213__root","action":"actionsmenu2642433213__action"};
|
|
17
17
|
export var keyframes = {};
|
|
18
18
|
export var layers = {};
|
|
19
19
|
export var containers = {};
|
|
@@ -5,7 +5,7 @@ import { classesRuntime, statesRuntime } from "../../../stylable-esm-runtime.js"
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var _namespace_ = "
|
|
8
|
+
var _namespace_ = "formaudiofield793983115";
|
|
9
9
|
var _style_ = classesRuntime.bind(null, _namespace_);
|
|
10
10
|
|
|
11
11
|
export var cssStates = statesRuntime.bind(null, _namespace_);
|
|
@@ -13,7 +13,7 @@ export var style: import("@stylable/runtime").STFunction = _style_;
|
|
|
13
13
|
export var st: import("@stylable/runtime").STFunction = _style_;
|
|
14
14
|
|
|
15
15
|
export var namespace = _namespace_;
|
|
16
|
-
export var classes = {"root":"
|
|
16
|
+
export var classes = {"root":"formaudiofield793983115__root","addItem":"formaudiofield793983115__addItem","mediaTitle":"formaudiofield793983115__mediaTitle"};
|
|
17
17
|
export var keyframes = {};
|
|
18
18
|
export var layers = {};
|
|
19
19
|
export var containers = {};
|
|
@@ -5,7 +5,7 @@ import { classesRuntime, statesRuntime } from "../../../stylable-esm-runtime.js"
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var _namespace_ = "
|
|
8
|
+
var _namespace_ = "audioplayer1089993499";
|
|
9
9
|
var _style_ = classesRuntime.bind(null, _namespace_);
|
|
10
10
|
|
|
11
11
|
export var cssStates = statesRuntime.bind(null, _namespace_);
|
|
@@ -13,7 +13,7 @@ export var style: import("@stylable/runtime").STFunction = _style_;
|
|
|
13
13
|
export var st: import("@stylable/runtime").STFunction = _style_;
|
|
14
14
|
|
|
15
15
|
export var namespace = _namespace_;
|
|
16
|
-
export var classes = {"root":"
|
|
16
|
+
export var classes = {"root":"audioplayer1089993499__root"};
|
|
17
17
|
export var keyframes = {};
|
|
18
18
|
export var layers = {};
|
|
19
19
|
export var containers = {};
|
|
@@ -5,7 +5,7 @@ import { classesRuntime, statesRuntime } from "../../stylable-esm-runtime.js";
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var _namespace_ = "
|
|
8
|
+
var _namespace_ = "cellcolorview2172636651";
|
|
9
9
|
var _style_ = classesRuntime.bind(null, _namespace_);
|
|
10
10
|
|
|
11
11
|
export var cssStates = statesRuntime.bind(null, _namespace_);
|
|
@@ -13,7 +13,7 @@ export var style: import("@stylable/runtime").STFunction = _style_;
|
|
|
13
13
|
export var st: import("@stylable/runtime").STFunction = _style_;
|
|
14
14
|
|
|
15
15
|
export var namespace = _namespace_;
|
|
16
|
-
export var classes = {"root":"
|
|
16
|
+
export var classes = {"root":"cellcolorview2172636651__root","hashPrefix":"cellcolorview2172636651__hashPrefix"};
|
|
17
17
|
export var keyframes = {};
|
|
18
18
|
export var layers = {};
|
|
19
19
|
export var containers = {};
|
|
@@ -5,7 +5,7 @@ import { classesRuntime, statesRuntime } from "../../stylable-esm-runtime.js";
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var _namespace_ = "
|
|
8
|
+
var _namespace_ = "colorview2743015308";
|
|
9
9
|
var _style_ = classesRuntime.bind(null, _namespace_);
|
|
10
10
|
|
|
11
11
|
export var cssStates = statesRuntime.bind(null, _namespace_);
|
|
@@ -13,7 +13,7 @@ export var style: import("@stylable/runtime").STFunction = _style_;
|
|
|
13
13
|
export var st: import("@stylable/runtime").STFunction = _style_;
|
|
14
14
|
|
|
15
15
|
export var namespace = _namespace_;
|
|
16
|
-
export var classes = {"root":"
|
|
16
|
+
export var classes = {"root":"colorview2743015308__root","view":"colorview2743015308__view","fillPreview":"colorview2743015308__fillPreview"};
|
|
17
17
|
export var keyframes = {};
|
|
18
18
|
export var layers = {};
|
|
19
19
|
export var containers = {};
|
|
@@ -7,6 +7,7 @@ import React, {
|
|
|
7
7
|
import { DatePicker } from '@wix/design-system';
|
|
8
8
|
import {
|
|
9
9
|
closeDatePickerCalendar,
|
|
10
|
+
typedDateInputProps,
|
|
10
11
|
getDatePickerInputElement,
|
|
11
12
|
} from './date-picker-internals';
|
|
12
13
|
|
|
@@ -29,6 +30,10 @@ export interface CellDateInputProps {
|
|
|
29
30
|
* after a date pick).
|
|
30
31
|
*/
|
|
31
32
|
onChange?: (date: Date) => void;
|
|
33
|
+
/** Fires when the user empties the input. */
|
|
34
|
+
onEmpty?: () => void;
|
|
35
|
+
/** Fires on Enter in the input with the typed date, or `null` when empty. */
|
|
36
|
+
onEnter?: (date: Date | null) => void;
|
|
32
37
|
/** When set, renders the clear (X) suffix and calls this on click. */
|
|
33
38
|
onClear?: () => void;
|
|
34
39
|
/** Ref object that receives the underlying `<input>` element. Consumers
|
|
@@ -62,6 +67,8 @@ export const CellDateInput = forwardRef<
|
|
|
62
67
|
{
|
|
63
68
|
value,
|
|
64
69
|
onChange,
|
|
70
|
+
onEmpty,
|
|
71
|
+
onEnter,
|
|
65
72
|
onClear,
|
|
66
73
|
inputRef,
|
|
67
74
|
dataHook,
|
|
@@ -73,6 +80,7 @@ export const CellDateInput = forwardRef<
|
|
|
73
80
|
forwardedRef,
|
|
74
81
|
) => {
|
|
75
82
|
const datePickerRef = useRef<DatePicker | null>(null);
|
|
83
|
+
const inputElementRef = useRef<HTMLInputElement | null>(null);
|
|
76
84
|
|
|
77
85
|
useImperativeHandle(
|
|
78
86
|
forwardedRef,
|
|
@@ -91,6 +99,16 @@ export const CellDateInput = forwardRef<
|
|
|
91
99
|
[onChange],
|
|
92
100
|
);
|
|
93
101
|
|
|
102
|
+
const handleEmptyEnter = useCallback(() => {
|
|
103
|
+
if (onEnter) {
|
|
104
|
+
onEnter(null);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
onEmpty?.();
|
|
108
|
+
}, [onEnter, onEmpty]);
|
|
109
|
+
|
|
110
|
+
const handlesTypedInput = Boolean(onEmpty || onEnter);
|
|
111
|
+
|
|
94
112
|
const validValue =
|
|
95
113
|
value instanceof Date && !isNaN(value.getTime()) ? value : undefined;
|
|
96
114
|
|
|
@@ -110,7 +128,17 @@ export const CellDateInput = forwardRef<
|
|
|
110
128
|
border: 'none',
|
|
111
129
|
...(hidePrefix ? { prefix: <span /> } : {}),
|
|
112
130
|
...(ariaLabel ? { ariaLabel } : {}),
|
|
131
|
+
...(handlesTypedInput
|
|
132
|
+
? typedDateInputProps({
|
|
133
|
+
picker: datePickerRef,
|
|
134
|
+
input: inputElementRef,
|
|
135
|
+
onEmpty,
|
|
136
|
+
onEmptyEnter: handleEmptyEnter,
|
|
137
|
+
onEnter,
|
|
138
|
+
})
|
|
139
|
+
: {}),
|
|
113
140
|
inputRef: (el: HTMLInputElement | null) => {
|
|
141
|
+
inputElementRef.current = el;
|
|
114
142
|
if (inputRef) {
|
|
115
143
|
inputRef.current = el ?? undefined;
|
|
116
144
|
}
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { KeyboardEvent, RefObject } from 'react';
|
|
2
|
+
import type { DatePicker, InputProps } from '@wix/design-system';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
* WDS `DatePicker` exposes
|
|
5
|
+
* WDS `DatePicker` exposes operations we need that aren't part of its
|
|
5
6
|
* public type surface:
|
|
6
7
|
*
|
|
7
8
|
* - `state.inputRef` — the underlying `HTMLInputElement` (used to focus
|
|
8
9
|
* the input and to programmatically seed it for type-to-edit).
|
|
9
10
|
* - `_closeCalendar()` — WDS declares `closeCalendar` in its types but
|
|
10
11
|
* only the underscored form exists at runtime.
|
|
12
|
+
* - `_handleInputChange()` / `_handleKeyDown()` — its handlers for typed
|
|
13
|
+
* text and keys.
|
|
11
14
|
*
|
|
12
|
-
*
|
|
15
|
+
* These reaches live behind this helper so the cast happens in exactly one
|
|
13
16
|
* place. If WDS adds a public surface for these, swap the implementation
|
|
14
17
|
* here and every consumer picks it up automatically.
|
|
15
18
|
*/
|
|
16
19
|
type DatePickerWithInternals = DatePicker & {
|
|
17
20
|
state?: { inputRef?: HTMLInputElement };
|
|
18
21
|
_closeCalendar?: () => void;
|
|
22
|
+
_handleInputChange?: (change: { dateVal: Date }) => void;
|
|
23
|
+
_handleKeyDown?: (event: KeyboardEvent, date: Date | null) => void;
|
|
24
|
+
_handleChange?: (date: Date, modifiers?: { disabled?: boolean }) => void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// The handlers DatePicker's inner DateInput calls. `InputProps` types
|
|
28
|
+
// `onChange` and `onKeyDown` as DOM event handlers, so it can't hold these.
|
|
29
|
+
type DateInputHandlers = {
|
|
30
|
+
onChange: (change: { dateVal: Date }) => void;
|
|
31
|
+
onKeyDown: (event: KeyboardEvent, date: Date | null) => void;
|
|
19
32
|
};
|
|
20
33
|
|
|
21
34
|
export const getDatePickerInputElement = (
|
|
@@ -28,3 +41,91 @@ export const closeDatePickerCalendar = (
|
|
|
28
41
|
): void => {
|
|
29
42
|
(picker as DatePickerWithInternals | null | undefined)?._closeCalendar?.();
|
|
30
43
|
};
|
|
44
|
+
|
|
45
|
+
// WDS skips `onChange` when the picked day is the day of its `value` prop.
|
|
46
|
+
// This reports that pick through `onPick` and returns a function that undoes it.
|
|
47
|
+
export const onSameDayCalendarPick = (
|
|
48
|
+
picker: DatePicker | null | undefined,
|
|
49
|
+
onPick: (date: Date) => void,
|
|
50
|
+
): (() => void) => {
|
|
51
|
+
const internals = picker as DatePickerWithInternals | null | undefined;
|
|
52
|
+
const handleChange = internals?._handleChange;
|
|
53
|
+
if (!internals || !handleChange) {
|
|
54
|
+
return () => {};
|
|
55
|
+
}
|
|
56
|
+
internals._handleChange = (date, modifiers) => {
|
|
57
|
+
handleChange(date, modifiers);
|
|
58
|
+
const { value } = internals.props;
|
|
59
|
+
// Same guard as WDS `_saveNewValue`.
|
|
60
|
+
if (value?.toDateString() === date.toDateString() && !modifiers?.disabled) {
|
|
61
|
+
onPick(date);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return () => {
|
|
65
|
+
internals._handleChange = handleChange;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const isValidDate = (date: Date | null): date is Date =>
|
|
70
|
+
date !== null && !isNaN(date.getTime());
|
|
71
|
+
|
|
72
|
+
// WDS parses empty input text as today. These `inputProps` handlers report an
|
|
73
|
+
// emptied input through `onEmpty` and Enter on it through `onEmptyEnter`
|
|
74
|
+
// instead, send typed dates to `onType` when it is given (the picker's
|
|
75
|
+
// `onChange` otherwise), and Enter on a typed date to `onEnter`. An event
|
|
76
|
+
// without its callback goes to the picker as before. Calendar picks don't go
|
|
77
|
+
// through them.
|
|
78
|
+
// WDS thread: https://wix.slack.com/archives/C39FTGUBZ/p1790691851370229
|
|
79
|
+
export const typedDateInputProps = ({
|
|
80
|
+
picker,
|
|
81
|
+
input,
|
|
82
|
+
onEmpty,
|
|
83
|
+
onEmptyEnter,
|
|
84
|
+
onType,
|
|
85
|
+
onEnter,
|
|
86
|
+
}: {
|
|
87
|
+
picker: RefObject<DatePicker | null>;
|
|
88
|
+
input: RefObject<HTMLInputElement | null>;
|
|
89
|
+
onEmpty?: () => void;
|
|
90
|
+
onEmptyEnter?: () => void;
|
|
91
|
+
onType?: (date: Date) => void;
|
|
92
|
+
onEnter?: (date: Date) => void;
|
|
93
|
+
}): Partial<InputProps> => {
|
|
94
|
+
const internals = () => picker.current as DatePickerWithInternals | null;
|
|
95
|
+
const isEmpty = () => input.current?.value === '';
|
|
96
|
+
const takeOverEnter = (event: KeyboardEvent) => {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
closeDatePickerCalendar(picker.current);
|
|
99
|
+
};
|
|
100
|
+
const handlers: DateInputHandlers = {
|
|
101
|
+
onChange: (change) => {
|
|
102
|
+
if (onEmpty && isEmpty()) {
|
|
103
|
+
onEmpty();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (onType) {
|
|
107
|
+
onType(change.dateVal);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
internals()?._handleInputChange?.(change);
|
|
111
|
+
},
|
|
112
|
+
onKeyDown: (event, date) => {
|
|
113
|
+
if (event.key === 'Enter') {
|
|
114
|
+
const isInputEmpty = isEmpty();
|
|
115
|
+
if (isInputEmpty && onEmptyEnter) {
|
|
116
|
+
takeOverEnter(event);
|
|
117
|
+
onEmptyEnter();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!isInputEmpty && onEnter && isValidDate(date)) {
|
|
121
|
+
takeOverEnter(event);
|
|
122
|
+
onEnter(date);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
internals()?._handleKeyDown?.(event, date);
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
// DatePicker passes `inputProps` to its inner DateInput, not to `<Input>`.
|
|
130
|
+
return handlers as unknown as Partial<InputProps>;
|
|
131
|
+
};
|
|
@@ -25,7 +25,9 @@ export function FormDateInputDriver(
|
|
|
25
25
|
getLabel: () => getFormFieldLabelText(formField),
|
|
26
26
|
datePickerExists: () => datePickerBase.exists(),
|
|
27
27
|
enterText: (text: string) => datePicker.inputDriver.enterText(text),
|
|
28
|
+
getValue: () => datePicker.inputDriver.getValue(),
|
|
28
29
|
blur: () => datePicker.inputDriver.blur(),
|
|
30
|
+
selectDate: (date: Date) => datePicker.calendarDriver.clickDay(date),
|
|
29
31
|
hasError: () => datePicker.inputDriver.hasStatus('error'),
|
|
30
32
|
getErrorMessage: () => datePicker.inputDriver.getStatusMessage(),
|
|
31
33
|
isRequired: () => formField.isRequired(),
|
|
@@ -8,6 +8,7 @@ import { BaseInputProps, BaseInputRef } from '../../types/base-input';
|
|
|
8
8
|
import { useTranslations } from '../../hooks';
|
|
9
9
|
import { isEmpty } from '../../validations/string';
|
|
10
10
|
import { calendarPopoverDefaults } from '../popover-defaults';
|
|
11
|
+
import { useFieldValueReplacement } from './use-field-value-replacement';
|
|
11
12
|
import {
|
|
12
13
|
getDateWithoutTimezone,
|
|
13
14
|
getISODateStringWithFixedTimezone,
|
|
@@ -19,14 +20,17 @@ const _FormDateInput = (props: FormDateInputProps) => {
|
|
|
19
20
|
const { field, dataHook, inputRef, formControl, data } = props;
|
|
20
21
|
const { translate: t } = useWixPatternsContainer();
|
|
21
22
|
const { t: tFields } = useTranslations();
|
|
23
|
+
const inputError = useRef('');
|
|
22
24
|
|
|
23
25
|
const computeError = (
|
|
24
26
|
value: string | null | undefined,
|
|
25
27
|
format?: string,
|
|
26
28
|
validationType?: 'outOfBoundsError' | 'formatError' | 'valid',
|
|
27
29
|
): string => {
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
30
|
+
if (isEmpty(value)) {
|
|
31
|
+
return field.validation?.required
|
|
32
|
+
? t('cairo.fieldValidation.requiredField')
|
|
33
|
+
: '';
|
|
30
34
|
}
|
|
31
35
|
if (validationType === 'formatError' && format) {
|
|
32
36
|
return t('cairo.customFields.fieldType.date.invalid.value', {
|
|
@@ -42,7 +46,7 @@ const _FormDateInput = (props: FormDateInputProps) => {
|
|
|
42
46
|
defaultValue: data?.[field?.id ?? ''],
|
|
43
47
|
rules: {
|
|
44
48
|
validate: (value) => {
|
|
45
|
-
const error = computeError(value);
|
|
49
|
+
const error = inputError.current || computeError(value);
|
|
46
50
|
return error || true;
|
|
47
51
|
},
|
|
48
52
|
},
|
|
@@ -59,6 +63,16 @@ const _FormDateInput = (props: FormDateInputProps) => {
|
|
|
59
63
|
|
|
60
64
|
const ref = useRef<BaseInputRef>({});
|
|
61
65
|
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
66
|
+
const revision = useFieldValueReplacement(formControl, field.id, (value) => {
|
|
67
|
+
inputError.current = '';
|
|
68
|
+
setErrorMessage('');
|
|
69
|
+
ref.current.invalid = false;
|
|
70
|
+
const iso =
|
|
71
|
+
typeof value === 'string'
|
|
72
|
+
? getISODateStringWithFixedTimezone(value)
|
|
73
|
+
: undefined;
|
|
74
|
+
setDate(iso ? getDateWithoutTimezone(iso) : undefined);
|
|
75
|
+
});
|
|
62
76
|
|
|
63
77
|
return (
|
|
64
78
|
<FormField
|
|
@@ -68,6 +82,7 @@ const _FormDateInput = (props: FormDateInputProps) => {
|
|
|
68
82
|
dataHook={dataHook}
|
|
69
83
|
>
|
|
70
84
|
<DatePicker
|
|
85
|
+
key={revision}
|
|
71
86
|
ref={(internalRef) => {
|
|
72
87
|
inputRef?.(ref.current);
|
|
73
88
|
const inputEl =
|
|
@@ -84,6 +99,9 @@ const _FormDateInput = (props: FormDateInputProps) => {
|
|
|
84
99
|
placeholderText={tFields('CMS.formDate.placeholder')}
|
|
85
100
|
value={date}
|
|
86
101
|
onChange={(newValue: Date) => {
|
|
102
|
+
inputError.current = '';
|
|
103
|
+
setErrorMessage('');
|
|
104
|
+
ref.current.invalid = false;
|
|
87
105
|
setDate(newValue);
|
|
88
106
|
const formattedDate = newValue
|
|
89
107
|
? getISODateStringWithFixedTimezone(newValue)
|
|
@@ -92,12 +110,16 @@ const _FormDateInput = (props: FormDateInputProps) => {
|
|
|
92
110
|
}}
|
|
93
111
|
onValidate={({ validationType, value: newValue, format }) => {
|
|
94
112
|
const error = computeError(newValue, format, validationType);
|
|
113
|
+
inputError.current = error;
|
|
95
114
|
setErrorMessage(error);
|
|
96
115
|
ref.current.invalid = !!error;
|
|
97
116
|
|
|
98
117
|
if (validationType === 'formatError' && newValue === '') {
|
|
99
118
|
setDate(undefined);
|
|
100
119
|
controller.field.onChange(null);
|
|
120
|
+
} else {
|
|
121
|
+
// Invalid text does not change the stored date, but must revalidate it.
|
|
122
|
+
controller.field.onChange(controller.field.value);
|
|
101
123
|
}
|
|
102
124
|
}}
|
|
103
125
|
status={errorMessage ? 'error' : undefined}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { get } from '@wix/bex-core/form';
|
|
3
|
+
import type { Control } from '@wix/bex-core/form';
|
|
4
|
+
|
|
5
|
+
export function useFieldValueReplacement(
|
|
6
|
+
control: Control,
|
|
7
|
+
name: string,
|
|
8
|
+
onReplace: (value: unknown) => void,
|
|
9
|
+
) {
|
|
10
|
+
const callback = useRef(onReplace);
|
|
11
|
+
callback.current = onReplace;
|
|
12
|
+
// A new key discards the picker's draft even when its saved value is unchanged.
|
|
13
|
+
const [revision, setRevision] = useState(0);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
// Control has no public reset listener. Input edits carry a type; setValue
|
|
17
|
+
// does not. Older RHF releases have a separate values subject.
|
|
18
|
+
const subjects:
|
|
19
|
+
| (Partial<Control['_subjects']> & {
|
|
20
|
+
values?: Pick<Control['_subjects']['state'], 'subscribe'>;
|
|
21
|
+
})
|
|
22
|
+
| undefined = control._subjects;
|
|
23
|
+
const values = subjects?.values ?? subjects?.state;
|
|
24
|
+
const array = subjects?.array;
|
|
25
|
+
// Reset cleanup is optional; an incompatible RHF version must not crash the field.
|
|
26
|
+
if (
|
|
27
|
+
typeof values?.subscribe !== 'function' ||
|
|
28
|
+
typeof array?.subscribe !== 'function'
|
|
29
|
+
) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const subscription = values.subscribe({
|
|
33
|
+
next: (update) => {
|
|
34
|
+
if (
|
|
35
|
+
!update.values ||
|
|
36
|
+
!update.name ||
|
|
37
|
+
update.type ||
|
|
38
|
+
(update.name !== name && !name.startsWith(`${update.name}.`))
|
|
39
|
+
) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
callback.current(get(update.values, name));
|
|
43
|
+
setRevision((value) => value + 1);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
// Reset broadcasts here even for unchanged values. Unlike the state
|
|
47
|
+
// subject, this does not fire when an unrelated field unregisters.
|
|
48
|
+
const resets = array.subscribe({
|
|
49
|
+
next: (update) => {
|
|
50
|
+
if (!update.name && update.values) {
|
|
51
|
+
callback.current(get(update.values, name));
|
|
52
|
+
setRevision((value) => value + 1);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return () => {
|
|
57
|
+
subscription?.unsubscribe?.();
|
|
58
|
+
resets?.unsubscribe?.();
|
|
59
|
+
};
|
|
60
|
+
}, [control, name]);
|
|
61
|
+
|
|
62
|
+
return revision;
|
|
63
|
+
}
|
|
@@ -32,7 +32,10 @@ export function FormDateTimeDriver(
|
|
|
32
32
|
dateExists: () => dateBase.exists(),
|
|
33
33
|
timeExists: () => timeBase.exists(),
|
|
34
34
|
enterDateText: (text: string) => datePicker.inputDriver.enterText(text),
|
|
35
|
+
getDateText: () => datePicker.inputDriver.getValue(),
|
|
35
36
|
blurDate: () => datePicker.inputDriver.blur(),
|
|
37
|
+
enterTimeText: (text: string) => timeInput.setValue(text),
|
|
38
|
+
blurTime: () => timeInput.confirmValue(),
|
|
36
39
|
dateHasError: () => datePicker.inputDriver.hasStatus('error'),
|
|
37
40
|
getDateErrorMessage: () => datePicker.inputDriver.getStatusMessage(),
|
|
38
41
|
timeHasError: () =>
|