@cerberus-design/react 0.25.0 → 0.25.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/combobox/combobox.cjs +1 -2
- package/dist/components/combobox/combobox.d.cts +1 -3
- package/dist/components/combobox/combobox.d.ts +1 -3
- package/dist/components/combobox/combobox.js +1 -2
- package/dist/components/cta-dialog/provider.cjs +3 -1
- package/dist/components/cta-dialog/provider.d.cts +2 -1
- package/dist/components/cta-dialog/provider.d.ts +2 -1
- package/dist/components/cta-dialog/provider.js +3 -1
- package/dist/components/date-picker/calendar.cjs +3 -1
- package/dist/components/date-picker/calendar.d.cts +4 -8
- package/dist/components/date-picker/calendar.d.ts +4 -8
- package/dist/components/date-picker/calendar.js +3 -1
- package/dist/components/date-picker/content.cjs +1 -3
- package/dist/components/date-picker/content.d.cts +1 -2
- package/dist/components/date-picker/content.d.ts +1 -2
- package/dist/components/date-picker/content.js +1 -3
- package/dist/components/date-picker/date-picker.cjs +47 -2
- package/dist/components/date-picker/date-picker.d.cts +1 -6
- package/dist/components/date-picker/date-picker.d.ts +1 -6
- package/dist/components/date-picker/date-picker.js +47 -2
- package/dist/components/date-picker/index.cjs +3 -3
- package/dist/components/date-picker/index.js +3 -3
- package/dist/components/date-picker/input.cjs +1 -1
- package/dist/components/date-picker/input.js +1 -1
- package/dist/components/date-picker/primitives.cjs +4 -1
- package/dist/components/date-picker/primitives.d.cts +1 -4
- package/dist/components/date-picker/primitives.d.ts +1 -4
- package/dist/components/date-picker/primitives.js +4 -1
- package/dist/components/date-picker/range-input.cjs +2 -2
- package/dist/components/date-picker/range-input.js +2 -2
- package/dist/components/field/status-indicator.cjs +1 -2
- package/dist/components/field/status-indicator.d.cts +1 -1
- package/dist/components/field/status-indicator.d.ts +1 -1
- package/dist/components/field/status-indicator.js +1 -2
- package/dist/components/file-upload/file-status.cjs +26 -43
- package/dist/components/file-upload/file-status.js +27 -44
- package/dist/components/file-upload/file-uploader.cjs +21 -47
- package/dist/components/file-upload/file-uploader.d.cts +7 -10
- package/dist/components/file-upload/file-uploader.d.ts +7 -10
- package/dist/components/file-upload/file-uploader.js +22 -48
- package/dist/components/file-upload/helpers.cjs +17 -0
- package/dist/components/file-upload/helpers.d.cts +16 -0
- package/dist/components/file-upload/helpers.d.ts +16 -0
- package/dist/components/file-upload/helpers.js +13 -0
- package/dist/components/file-upload/img-preview.cjs +30 -0
- package/dist/components/file-upload/img-preview.d.cts +2 -0
- package/dist/components/file-upload/img-preview.d.ts +2 -0
- package/dist/components/file-upload/img-preview.js +26 -0
- package/dist/components/file-upload/index.cjs +24 -0
- package/dist/components/file-upload/index.d.cts +4 -0
- package/dist/components/file-upload/index.d.ts +4 -0
- package/dist/components/file-upload/index.js +4 -0
- package/dist/components/file-upload/parts.cjs +28 -0
- package/dist/components/file-upload/parts.d.cts +86 -0
- package/dist/components/file-upload/parts.d.ts +86 -0
- package/dist/components/file-upload/parts.js +24 -0
- package/dist/components/file-upload/primitives.cjs +81 -0
- package/dist/components/file-upload/primitives.d.cts +45 -0
- package/dist/components/file-upload/primitives.d.ts +45 -0
- package/dist/components/file-upload/primitives.js +61 -0
- package/dist/components/file-upload/utils.cjs +18 -0
- package/dist/components/file-upload/utils.d.cts +7 -0
- package/dist/components/file-upload/utils.d.ts +7 -0
- package/dist/components/file-upload/utils.js +14 -0
- package/dist/components/select/select.cjs +6 -3
- package/dist/components/select/select.d.cts +1 -3
- package/dist/components/select/select.d.ts +1 -3
- package/dist/components/select/select.js +6 -3
- package/dist/context/confirm-modal.cjs +3 -1
- package/dist/context/confirm-modal.d.cts +2 -1
- package/dist/context/confirm-modal.d.ts +2 -1
- package/dist/context/confirm-modal.js +3 -1
- package/dist/context/prompt-modal.cjs +4 -2
- package/dist/context/prompt-modal.d.cts +2 -1
- package/dist/context/prompt-modal.d.ts +2 -1
- package/dist/context/prompt-modal.js +5 -3
- package/dist/index.cjs +163 -131
- package/dist/index.client.d.cts +1 -1
- package/dist/index.client.d.ts +1 -1
- package/dist/index.js +8 -4
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-clear-trigger.cjs +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-clear-trigger.js +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-context.cjs +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-context.js +6 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-dropzone.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-dropzone.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-hidden-input.cjs +21 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-hidden-input.js +17 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-delete-trigger.cjs +23 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-delete-trigger.js +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-group.cjs +23 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-group.js +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-name.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-name.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview-image.cjs +28 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview-image.js +24 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-preview.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-size-text.cjs +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item-size-text.js +18 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item.cjs +26 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-item.js +22 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-label.cjs +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-label.js +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-root.cjs +47 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-root.js +43 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-trigger.cjs +19 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/file-upload-trigger.js +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-context.cjs +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-context.js +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-group-props-context.cjs +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-group-props-context.js +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-props-context.cjs +15 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload-item-props-context.js +10 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload.cjs +36 -0
- package/dist/node_modules/.pnpm/@ark-ui_react@5.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@ark-ui/react/dist/components/file-upload/use-file-upload.js +32 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.0/node_modules/@internationalized/date/src/CalendarDate.js +3 -3
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.0/node_modules/@internationalized/date/src/conversion.js +1 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.0/node_modules/@internationalized/date/src/queries.js +1 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/CalendarDate.cjs +218 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/CalendarDate.js +212 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/DateFormatter.cjs +135 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/DateFormatter.js +131 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/calendars/GregorianCalendar.cjs +101 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/calendars/GregorianCalendar.js +93 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/conversion.cjs +200 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/conversion.js +186 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/manipulation.cjs +352 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/manipulation.js +336 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/queries.cjs +39 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/queries.js +30 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/string.cjs +44 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/string.js +37 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/utils.cjs +10 -0
- package/dist/node_modules/.pnpm/@internationalized_date@3.10.1/node_modules/@internationalized/date/src/utils.js +6 -0
- package/dist/node_modules/.pnpm/@zag-js_file-upload@1.31.1/node_modules/@zag-js/file-upload/dist/index.cjs +649 -0
- package/dist/node_modules/.pnpm/@zag-js_file-upload@1.31.1/node_modules/@zag-js/file-upload/dist/index.js +643 -0
- package/dist/node_modules/.pnpm/@zag-js_file-utils@1.31.1/node_modules/@zag-js/file-utils/dist/index.cjs +147 -0
- package/dist/node_modules/.pnpm/@zag-js_file-utils@1.31.1/node_modules/@zag-js/file-utils/dist/index.js +138 -0
- package/dist/node_modules/.pnpm/@zag-js_i18n-utils@1.31.1/node_modules/@zag-js/i18n-utils/dist/index.cjs +53 -0
- package/dist/node_modules/.pnpm/@zag-js_i18n-utils@1.31.1/node_modules/@zag-js/i18n-utils/dist/index.js +48 -0
- package/dist/node_modules/.pnpm/@zag-js_utils@1.31.1/node_modules/@zag-js/utils/dist/index.cjs +9 -0
- package/dist/node_modules/.pnpm/@zag-js_utils@1.31.1/node_modules/@zag-js/utils/dist/index.js +9 -1
- package/package.json +7 -7
- package/src/components/combobox/combobox.tsx +7 -13
- package/src/components/cta-dialog/provider.tsx +8 -3
- package/src/components/date-picker/calendar.tsx +10 -9
- package/src/components/date-picker/content.tsx +4 -11
- package/src/components/date-picker/date-picker.tsx +55 -18
- package/src/components/date-picker/input.tsx +1 -1
- package/src/components/date-picker/primitives.tsx +4 -1
- package/src/components/date-picker/range-input.tsx +2 -2
- package/src/components/field/status-indicator.tsx +2 -5
- package/src/components/file-upload/file-status.tsx +14 -21
- package/src/components/file-upload/file-uploader.tsx +37 -49
- package/src/components/file-upload/helpers.ts +28 -0
- package/src/components/file-upload/img-preview.tsx +41 -0
- package/src/components/file-upload/index.ts +4 -0
- package/src/components/file-upload/parts.tsx +126 -0
- package/src/components/file-upload/primitives.ts +156 -0
- package/src/components/file-upload/utils.ts +20 -0
- package/src/components/select/select.tsx +11 -12
- package/src/context/confirm-modal.tsx +7 -2
- package/src/context/prompt-modal.tsx +9 -4
- package/src/index.client.ts +2 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const createContext = require('../../utils/create-context.cjs');
|
|
7
|
+
|
|
8
|
+
const [FileUploadItemPropsProvider, useFileUploadItemPropsContext] = createContext.createContext({
|
|
9
|
+
name: "FileUploadItemPropsContext",
|
|
10
|
+
hookName: "useFileUploadItemPropsContext",
|
|
11
|
+
providerName: "<FileUploadItemPropsProvider />"
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
exports.FileUploadItemPropsProvider = FileUploadItemPropsProvider;
|
|
15
|
+
exports.useFileUploadItemPropsContext = useFileUploadItemPropsContext;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext } from '../../utils/create-context.js';
|
|
3
|
+
|
|
4
|
+
const [FileUploadItemPropsProvider, useFileUploadItemPropsContext] = createContext({
|
|
5
|
+
name: "FileUploadItemPropsContext",
|
|
6
|
+
hookName: "useFileUploadItemPropsContext",
|
|
7
|
+
providerName: "<FileUploadItemPropsProvider />"
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { FileUploadItemPropsProvider, useFileUploadItemPropsContext };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const index$1 = require('../../../../../../../@zag-js_file-upload@1.31.1/node_modules/@zag-js/file-upload/dist/index.cjs');
|
|
7
|
+
const index = require('../../../../../../../@zag-js_react@1.31.1_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@zag-js/react/dist/index.cjs');
|
|
8
|
+
const React = require('react');
|
|
9
|
+
const useEnvironmentContext = require('../../providers/environment/use-environment-context.cjs');
|
|
10
|
+
const useLocaleContext = require('../../providers/locale/use-locale-context.cjs');
|
|
11
|
+
const useFieldContext = require('../field/use-field-context.cjs');
|
|
12
|
+
|
|
13
|
+
const useFileUpload = (props) => {
|
|
14
|
+
const id = React.useId();
|
|
15
|
+
const { getRootNode } = useEnvironmentContext.useEnvironmentContext();
|
|
16
|
+
const { dir, locale } = useLocaleContext.useLocaleContext();
|
|
17
|
+
const field = useFieldContext.useFieldContext();
|
|
18
|
+
const machineProps = {
|
|
19
|
+
id,
|
|
20
|
+
ids: {
|
|
21
|
+
label: field?.ids.label,
|
|
22
|
+
hiddenInput: field?.ids.control
|
|
23
|
+
},
|
|
24
|
+
dir,
|
|
25
|
+
disabled: field?.disabled,
|
|
26
|
+
locale,
|
|
27
|
+
required: field?.required,
|
|
28
|
+
invalid: field?.invalid,
|
|
29
|
+
getRootNode,
|
|
30
|
+
...props
|
|
31
|
+
};
|
|
32
|
+
const service = index.useMachine(index$1.machine, machineProps);
|
|
33
|
+
return index$1.connect(service, index.normalizeProps);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.useFileUpload = useFileUpload;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { machine, connect } from '../../../../../../../@zag-js_file-upload@1.31.1/node_modules/@zag-js/file-upload/dist/index.js';
|
|
3
|
+
import { useMachine, normalizeProps } from '../../../../../../../@zag-js_react@1.31.1_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@zag-js/react/dist/index.js';
|
|
4
|
+
import { useId } from 'react';
|
|
5
|
+
import { useEnvironmentContext } from '../../providers/environment/use-environment-context.js';
|
|
6
|
+
import { useLocaleContext } from '../../providers/locale/use-locale-context.js';
|
|
7
|
+
import { useFieldContext } from '../field/use-field-context.js';
|
|
8
|
+
|
|
9
|
+
const useFileUpload = (props) => {
|
|
10
|
+
const id = useId();
|
|
11
|
+
const { getRootNode } = useEnvironmentContext();
|
|
12
|
+
const { dir, locale } = useLocaleContext();
|
|
13
|
+
const field = useFieldContext();
|
|
14
|
+
const machineProps = {
|
|
15
|
+
id,
|
|
16
|
+
ids: {
|
|
17
|
+
label: field?.ids.label,
|
|
18
|
+
hiddenInput: field?.ids.control
|
|
19
|
+
},
|
|
20
|
+
dir,
|
|
21
|
+
disabled: field?.disabled,
|
|
22
|
+
locale,
|
|
23
|
+
required: field?.required,
|
|
24
|
+
invalid: field?.invalid,
|
|
25
|
+
getRootNode,
|
|
26
|
+
...props
|
|
27
|
+
};
|
|
28
|
+
const service = useMachine(machine, machineProps);
|
|
29
|
+
return connect(service, normalizeProps);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useFileUpload };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { constrain, add, subtract, set, cycleDate, addZoned, subtractZoned, setZoned, cycleZoned
|
|
2
|
+
import { constrain, add, subtract, set, cycleDate, setTime, cycleTime, addZoned, subtractZoned, setZoned, cycleZoned } from './manipulation.js';
|
|
3
3
|
import { compareDate, compareTime } from './queries.js';
|
|
4
|
-
import { dateToString,
|
|
4
|
+
import { dateToString, dateTimeToString, zonedDateTimeToString } from './string.js';
|
|
5
5
|
import { GregorianCalendar } from './calendars/GregorianCalendar.js';
|
|
6
|
-
import { toDate, zonedToDate, toZoned
|
|
6
|
+
import { toDate, toCalendarDateTime, zonedToDate, toZoned } from './conversion.js';
|
|
7
7
|
|
|
8
8
|
function shiftArgs(args) {
|
|
9
9
|
let calendar = typeof args[0] === "object" ? args.shift() : new GregorianCalendar();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { CalendarDate, ZonedDateTime
|
|
2
|
+
import { CalendarDateTime, CalendarDate, ZonedDateTime } from './CalendarDate.js';
|
|
3
3
|
import { constrain } from './manipulation.js';
|
|
4
4
|
import { getExtendedYear, GregorianCalendar } from './calendars/GregorianCalendar.js';
|
|
5
5
|
import { getLocalTimeZone, isEqualCalendar } from './queries.js';
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const manipulation = require('./manipulation.cjs');
|
|
7
|
+
const queries = require('./queries.cjs');
|
|
8
|
+
const string = require('./string.cjs');
|
|
9
|
+
const GregorianCalendar = require('./calendars/GregorianCalendar.cjs');
|
|
10
|
+
const conversion = require('./conversion.cjs');
|
|
11
|
+
|
|
12
|
+
function shiftArgs(args) {
|
|
13
|
+
let calendar = typeof args[0] === "object" ? args.shift() : new GregorianCalendar.GregorianCalendar();
|
|
14
|
+
let era;
|
|
15
|
+
if (typeof args[0] === "string") {
|
|
16
|
+
era = args.shift();
|
|
17
|
+
} else {
|
|
18
|
+
let eras = calendar.getEras();
|
|
19
|
+
era = eras[eras.length - 1];
|
|
20
|
+
}
|
|
21
|
+
let year = args.shift();
|
|
22
|
+
let month = args.shift();
|
|
23
|
+
let day = args.shift();
|
|
24
|
+
return [calendar, era, year, month, day];
|
|
25
|
+
}
|
|
26
|
+
class CalendarDate {
|
|
27
|
+
// This prevents TypeScript from allowing other types with the same fields to match.
|
|
28
|
+
// i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate.
|
|
29
|
+
// If that behavior is desired, use the AnyCalendarDate interface instead.
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
#type;
|
|
32
|
+
constructor(...args) {
|
|
33
|
+
let [calendar, era, year, month, day] = shiftArgs(args);
|
|
34
|
+
this.calendar = calendar;
|
|
35
|
+
this.era = era;
|
|
36
|
+
this.year = year;
|
|
37
|
+
this.month = month;
|
|
38
|
+
this.day = day;
|
|
39
|
+
manipulation.constrain(this);
|
|
40
|
+
}
|
|
41
|
+
/** Returns a copy of this date. */
|
|
42
|
+
copy() {
|
|
43
|
+
if (this.era) {
|
|
44
|
+
return new CalendarDate(this.calendar, this.era, this.year, this.month, this.day);
|
|
45
|
+
} else {
|
|
46
|
+
return new CalendarDate(this.calendar, this.year, this.month, this.day);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Returns a new `CalendarDate` with the given duration added to it. */
|
|
50
|
+
add(duration) {
|
|
51
|
+
return manipulation.add(this, duration);
|
|
52
|
+
}
|
|
53
|
+
/** Returns a new `CalendarDate` with the given duration subtracted from it. */
|
|
54
|
+
subtract(duration) {
|
|
55
|
+
return manipulation.subtract(this, duration);
|
|
56
|
+
}
|
|
57
|
+
/** Returns a new `CalendarDate` with the given fields set to the provided values. Other fields will be constrained accordingly. */
|
|
58
|
+
set(fields) {
|
|
59
|
+
return manipulation.set(this, fields);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns a new `CalendarDate` with the given field adjusted by a specified amount.
|
|
63
|
+
* When the resulting value reaches the limits of the field, it wraps around.
|
|
64
|
+
*/
|
|
65
|
+
cycle(field, amount, options) {
|
|
66
|
+
return manipulation.cycleDate(this, field, amount, options);
|
|
67
|
+
}
|
|
68
|
+
/** Converts the date to a native JavaScript Date object, with the time set to midnight in the given time zone. */
|
|
69
|
+
toDate(timeZone) {
|
|
70
|
+
return conversion.toDate(this, timeZone);
|
|
71
|
+
}
|
|
72
|
+
/** Converts the date to an ISO 8601 formatted string. */
|
|
73
|
+
toString() {
|
|
74
|
+
return string.dateToString(this);
|
|
75
|
+
}
|
|
76
|
+
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
|
|
77
|
+
compare(b) {
|
|
78
|
+
return queries.compareDate(this, b);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
class CalendarDateTime {
|
|
82
|
+
// This prevents TypeScript from allowing other types with the same fields to match.
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
#type;
|
|
85
|
+
constructor(...args) {
|
|
86
|
+
let [calendar, era, year, month, day] = shiftArgs(args);
|
|
87
|
+
this.calendar = calendar;
|
|
88
|
+
this.era = era;
|
|
89
|
+
this.year = year;
|
|
90
|
+
this.month = month;
|
|
91
|
+
this.day = day;
|
|
92
|
+
this.hour = args.shift() || 0;
|
|
93
|
+
this.minute = args.shift() || 0;
|
|
94
|
+
this.second = args.shift() || 0;
|
|
95
|
+
this.millisecond = args.shift() || 0;
|
|
96
|
+
manipulation.constrain(this);
|
|
97
|
+
}
|
|
98
|
+
/** Returns a copy of this date. */
|
|
99
|
+
copy() {
|
|
100
|
+
if (this.era) {
|
|
101
|
+
return new CalendarDateTime(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
102
|
+
} else {
|
|
103
|
+
return new CalendarDateTime(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** Returns a new `CalendarDateTime` with the given duration added to it. */
|
|
107
|
+
add(duration) {
|
|
108
|
+
return manipulation.add(this, duration);
|
|
109
|
+
}
|
|
110
|
+
/** Returns a new `CalendarDateTime` with the given duration subtracted from it. */
|
|
111
|
+
subtract(duration) {
|
|
112
|
+
return manipulation.subtract(this, duration);
|
|
113
|
+
}
|
|
114
|
+
/** Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */
|
|
115
|
+
set(fields) {
|
|
116
|
+
return manipulation.set(manipulation.setTime(this, fields), fields);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns a new `CalendarDateTime` with the given field adjusted by a specified amount.
|
|
120
|
+
* When the resulting value reaches the limits of the field, it wraps around.
|
|
121
|
+
*/
|
|
122
|
+
cycle(field, amount, options) {
|
|
123
|
+
switch (field) {
|
|
124
|
+
case "era":
|
|
125
|
+
case "year":
|
|
126
|
+
case "month":
|
|
127
|
+
case "day":
|
|
128
|
+
return manipulation.cycleDate(this, field, amount, options);
|
|
129
|
+
default:
|
|
130
|
+
return manipulation.cycleTime(this, field, amount, options);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** Converts the date to a native JavaScript Date object in the given time zone. */
|
|
134
|
+
toDate(timeZone, disambiguation) {
|
|
135
|
+
return conversion.toDate(this, timeZone, disambiguation);
|
|
136
|
+
}
|
|
137
|
+
/** Converts the date to an ISO 8601 formatted string. */
|
|
138
|
+
toString() {
|
|
139
|
+
return string.dateTimeToString(this);
|
|
140
|
+
}
|
|
141
|
+
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
|
|
142
|
+
compare(b) {
|
|
143
|
+
let res = queries.compareDate(this, b);
|
|
144
|
+
if (res === 0) {
|
|
145
|
+
return queries.compareTime(this, conversion.toCalendarDateTime(b));
|
|
146
|
+
}
|
|
147
|
+
return res;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
class ZonedDateTime {
|
|
151
|
+
// This prevents TypeScript from allowing other types with the same fields to match.
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
#type;
|
|
154
|
+
constructor(...args) {
|
|
155
|
+
let [calendar, era, year, month, day] = shiftArgs(args);
|
|
156
|
+
let timeZone = args.shift();
|
|
157
|
+
let offset = args.shift();
|
|
158
|
+
this.calendar = calendar;
|
|
159
|
+
this.era = era;
|
|
160
|
+
this.year = year;
|
|
161
|
+
this.month = month;
|
|
162
|
+
this.day = day;
|
|
163
|
+
this.timeZone = timeZone;
|
|
164
|
+
this.offset = offset;
|
|
165
|
+
this.hour = args.shift() || 0;
|
|
166
|
+
this.minute = args.shift() || 0;
|
|
167
|
+
this.second = args.shift() || 0;
|
|
168
|
+
this.millisecond = args.shift() || 0;
|
|
169
|
+
manipulation.constrain(this);
|
|
170
|
+
}
|
|
171
|
+
/** Returns a copy of this date. */
|
|
172
|
+
copy() {
|
|
173
|
+
if (this.era) {
|
|
174
|
+
return new ZonedDateTime(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
|
|
175
|
+
} else {
|
|
176
|
+
return new ZonedDateTime(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/** Returns a new `ZonedDateTime` with the given duration added to it. */
|
|
180
|
+
add(duration) {
|
|
181
|
+
return manipulation.addZoned(this, duration);
|
|
182
|
+
}
|
|
183
|
+
/** Returns a new `ZonedDateTime` with the given duration subtracted from it. */
|
|
184
|
+
subtract(duration) {
|
|
185
|
+
return manipulation.subtractZoned(this, duration);
|
|
186
|
+
}
|
|
187
|
+
/** Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */
|
|
188
|
+
set(fields, disambiguation) {
|
|
189
|
+
return manipulation.setZoned(this, fields, disambiguation);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns a new `ZonedDateTime` with the given field adjusted by a specified amount.
|
|
193
|
+
* When the resulting value reaches the limits of the field, it wraps around.
|
|
194
|
+
*/
|
|
195
|
+
cycle(field, amount, options) {
|
|
196
|
+
return manipulation.cycleZoned(this, field, amount, options);
|
|
197
|
+
}
|
|
198
|
+
/** Converts the date to a native JavaScript Date object. */
|
|
199
|
+
toDate() {
|
|
200
|
+
return conversion.zonedToDate(this);
|
|
201
|
+
}
|
|
202
|
+
/** Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone identifier. */
|
|
203
|
+
toString() {
|
|
204
|
+
return string.zonedDateTimeToString(this);
|
|
205
|
+
}
|
|
206
|
+
/** Converts the date to an ISO 8601 formatted string in UTC. */
|
|
207
|
+
toAbsoluteString() {
|
|
208
|
+
return this.toDate().toISOString();
|
|
209
|
+
}
|
|
210
|
+
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
|
|
211
|
+
compare(b) {
|
|
212
|
+
return this.toDate().getTime() - conversion.toZoned(b, this.timeZone).toDate().getTime();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
exports.CalendarDate = CalendarDate;
|
|
217
|
+
exports.CalendarDateTime = CalendarDateTime;
|
|
218
|
+
exports.ZonedDateTime = ZonedDateTime;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { constrain, add, subtract, set, cycleDate, addZoned, subtractZoned, setZoned, cycleZoned, setTime, cycleTime } from './manipulation.js';
|
|
3
|
+
import { compareDate, compareTime } from './queries.js';
|
|
4
|
+
import { dateToString, zonedDateTimeToString, dateTimeToString } from './string.js';
|
|
5
|
+
import { GregorianCalendar } from './calendars/GregorianCalendar.js';
|
|
6
|
+
import { toDate, zonedToDate, toZoned, toCalendarDateTime } from './conversion.js';
|
|
7
|
+
|
|
8
|
+
function shiftArgs(args) {
|
|
9
|
+
let calendar = typeof args[0] === "object" ? args.shift() : new GregorianCalendar();
|
|
10
|
+
let era;
|
|
11
|
+
if (typeof args[0] === "string") {
|
|
12
|
+
era = args.shift();
|
|
13
|
+
} else {
|
|
14
|
+
let eras = calendar.getEras();
|
|
15
|
+
era = eras[eras.length - 1];
|
|
16
|
+
}
|
|
17
|
+
let year = args.shift();
|
|
18
|
+
let month = args.shift();
|
|
19
|
+
let day = args.shift();
|
|
20
|
+
return [calendar, era, year, month, day];
|
|
21
|
+
}
|
|
22
|
+
class CalendarDate {
|
|
23
|
+
// This prevents TypeScript from allowing other types with the same fields to match.
|
|
24
|
+
// i.e. a ZonedDateTime should not be be passable to a parameter that expects CalendarDate.
|
|
25
|
+
// If that behavior is desired, use the AnyCalendarDate interface instead.
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
#type;
|
|
28
|
+
constructor(...args) {
|
|
29
|
+
let [calendar, era, year, month, day] = shiftArgs(args);
|
|
30
|
+
this.calendar = calendar;
|
|
31
|
+
this.era = era;
|
|
32
|
+
this.year = year;
|
|
33
|
+
this.month = month;
|
|
34
|
+
this.day = day;
|
|
35
|
+
constrain(this);
|
|
36
|
+
}
|
|
37
|
+
/** Returns a copy of this date. */
|
|
38
|
+
copy() {
|
|
39
|
+
if (this.era) {
|
|
40
|
+
return new CalendarDate(this.calendar, this.era, this.year, this.month, this.day);
|
|
41
|
+
} else {
|
|
42
|
+
return new CalendarDate(this.calendar, this.year, this.month, this.day);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Returns a new `CalendarDate` with the given duration added to it. */
|
|
46
|
+
add(duration) {
|
|
47
|
+
return add(this, duration);
|
|
48
|
+
}
|
|
49
|
+
/** Returns a new `CalendarDate` with the given duration subtracted from it. */
|
|
50
|
+
subtract(duration) {
|
|
51
|
+
return subtract(this, duration);
|
|
52
|
+
}
|
|
53
|
+
/** Returns a new `CalendarDate` with the given fields set to the provided values. Other fields will be constrained accordingly. */
|
|
54
|
+
set(fields) {
|
|
55
|
+
return set(this, fields);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns a new `CalendarDate` with the given field adjusted by a specified amount.
|
|
59
|
+
* When the resulting value reaches the limits of the field, it wraps around.
|
|
60
|
+
*/
|
|
61
|
+
cycle(field, amount, options) {
|
|
62
|
+
return cycleDate(this, field, amount, options);
|
|
63
|
+
}
|
|
64
|
+
/** Converts the date to a native JavaScript Date object, with the time set to midnight in the given time zone. */
|
|
65
|
+
toDate(timeZone) {
|
|
66
|
+
return toDate(this, timeZone);
|
|
67
|
+
}
|
|
68
|
+
/** Converts the date to an ISO 8601 formatted string. */
|
|
69
|
+
toString() {
|
|
70
|
+
return dateToString(this);
|
|
71
|
+
}
|
|
72
|
+
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
|
|
73
|
+
compare(b) {
|
|
74
|
+
return compareDate(this, b);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
class CalendarDateTime {
|
|
78
|
+
// This prevents TypeScript from allowing other types with the same fields to match.
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
#type;
|
|
81
|
+
constructor(...args) {
|
|
82
|
+
let [calendar, era, year, month, day] = shiftArgs(args);
|
|
83
|
+
this.calendar = calendar;
|
|
84
|
+
this.era = era;
|
|
85
|
+
this.year = year;
|
|
86
|
+
this.month = month;
|
|
87
|
+
this.day = day;
|
|
88
|
+
this.hour = args.shift() || 0;
|
|
89
|
+
this.minute = args.shift() || 0;
|
|
90
|
+
this.second = args.shift() || 0;
|
|
91
|
+
this.millisecond = args.shift() || 0;
|
|
92
|
+
constrain(this);
|
|
93
|
+
}
|
|
94
|
+
/** Returns a copy of this date. */
|
|
95
|
+
copy() {
|
|
96
|
+
if (this.era) {
|
|
97
|
+
return new CalendarDateTime(this.calendar, this.era, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
98
|
+
} else {
|
|
99
|
+
return new CalendarDateTime(this.calendar, this.year, this.month, this.day, this.hour, this.minute, this.second, this.millisecond);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** Returns a new `CalendarDateTime` with the given duration added to it. */
|
|
103
|
+
add(duration) {
|
|
104
|
+
return add(this, duration);
|
|
105
|
+
}
|
|
106
|
+
/** Returns a new `CalendarDateTime` with the given duration subtracted from it. */
|
|
107
|
+
subtract(duration) {
|
|
108
|
+
return subtract(this, duration);
|
|
109
|
+
}
|
|
110
|
+
/** Returns a new `CalendarDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */
|
|
111
|
+
set(fields) {
|
|
112
|
+
return set(setTime(this, fields), fields);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Returns a new `CalendarDateTime` with the given field adjusted by a specified amount.
|
|
116
|
+
* When the resulting value reaches the limits of the field, it wraps around.
|
|
117
|
+
*/
|
|
118
|
+
cycle(field, amount, options) {
|
|
119
|
+
switch (field) {
|
|
120
|
+
case "era":
|
|
121
|
+
case "year":
|
|
122
|
+
case "month":
|
|
123
|
+
case "day":
|
|
124
|
+
return cycleDate(this, field, amount, options);
|
|
125
|
+
default:
|
|
126
|
+
return cycleTime(this, field, amount, options);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/** Converts the date to a native JavaScript Date object in the given time zone. */
|
|
130
|
+
toDate(timeZone, disambiguation) {
|
|
131
|
+
return toDate(this, timeZone, disambiguation);
|
|
132
|
+
}
|
|
133
|
+
/** Converts the date to an ISO 8601 formatted string. */
|
|
134
|
+
toString() {
|
|
135
|
+
return dateTimeToString(this);
|
|
136
|
+
}
|
|
137
|
+
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
|
|
138
|
+
compare(b) {
|
|
139
|
+
let res = compareDate(this, b);
|
|
140
|
+
if (res === 0) {
|
|
141
|
+
return compareTime(this, toCalendarDateTime(b));
|
|
142
|
+
}
|
|
143
|
+
return res;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
class ZonedDateTime {
|
|
147
|
+
// This prevents TypeScript from allowing other types with the same fields to match.
|
|
148
|
+
// @ts-ignore
|
|
149
|
+
#type;
|
|
150
|
+
constructor(...args) {
|
|
151
|
+
let [calendar, era, year, month, day] = shiftArgs(args);
|
|
152
|
+
let timeZone = args.shift();
|
|
153
|
+
let offset = args.shift();
|
|
154
|
+
this.calendar = calendar;
|
|
155
|
+
this.era = era;
|
|
156
|
+
this.year = year;
|
|
157
|
+
this.month = month;
|
|
158
|
+
this.day = day;
|
|
159
|
+
this.timeZone = timeZone;
|
|
160
|
+
this.offset = offset;
|
|
161
|
+
this.hour = args.shift() || 0;
|
|
162
|
+
this.minute = args.shift() || 0;
|
|
163
|
+
this.second = args.shift() || 0;
|
|
164
|
+
this.millisecond = args.shift() || 0;
|
|
165
|
+
constrain(this);
|
|
166
|
+
}
|
|
167
|
+
/** Returns a copy of this date. */
|
|
168
|
+
copy() {
|
|
169
|
+
if (this.era) {
|
|
170
|
+
return new ZonedDateTime(this.calendar, this.era, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
|
|
171
|
+
} else {
|
|
172
|
+
return new ZonedDateTime(this.calendar, this.year, this.month, this.day, this.timeZone, this.offset, this.hour, this.minute, this.second, this.millisecond);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** Returns a new `ZonedDateTime` with the given duration added to it. */
|
|
176
|
+
add(duration) {
|
|
177
|
+
return addZoned(this, duration);
|
|
178
|
+
}
|
|
179
|
+
/** Returns a new `ZonedDateTime` with the given duration subtracted from it. */
|
|
180
|
+
subtract(duration) {
|
|
181
|
+
return subtractZoned(this, duration);
|
|
182
|
+
}
|
|
183
|
+
/** Returns a new `ZonedDateTime` with the given fields set to the provided values. Other fields will be constrained accordingly. */
|
|
184
|
+
set(fields, disambiguation) {
|
|
185
|
+
return setZoned(this, fields, disambiguation);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Returns a new `ZonedDateTime` with the given field adjusted by a specified amount.
|
|
189
|
+
* When the resulting value reaches the limits of the field, it wraps around.
|
|
190
|
+
*/
|
|
191
|
+
cycle(field, amount, options) {
|
|
192
|
+
return cycleZoned(this, field, amount, options);
|
|
193
|
+
}
|
|
194
|
+
/** Converts the date to a native JavaScript Date object. */
|
|
195
|
+
toDate() {
|
|
196
|
+
return zonedToDate(this);
|
|
197
|
+
}
|
|
198
|
+
/** Converts the date to an ISO 8601 formatted string, including the UTC offset and time zone identifier. */
|
|
199
|
+
toString() {
|
|
200
|
+
return zonedDateTimeToString(this);
|
|
201
|
+
}
|
|
202
|
+
/** Converts the date to an ISO 8601 formatted string in UTC. */
|
|
203
|
+
toAbsoluteString() {
|
|
204
|
+
return this.toDate().toISOString();
|
|
205
|
+
}
|
|
206
|
+
/** Compares this date with another. A negative result indicates that this date is before the given one, and a positive date indicates that it is after. */
|
|
207
|
+
compare(b) {
|
|
208
|
+
return this.toDate().getTime() - toZoned(b, this.timeZone).toDate().getTime();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export { CalendarDate, CalendarDateTime, ZonedDateTime };
|