pds-dev-kit-web 2.2.318 → 2.2.319-alpha.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/index.d.ts +6 -4
- package/dist/index.js +11 -2
- package/dist/src/core/pricing/hooks/useNewPriceTextField.d.ts +68 -0
- package/dist/src/core/pricing/hooks/useNewPriceTextField.js +210 -0
- package/dist/src/core/pricing/index.d.ts +4 -0
- package/dist/src/core/pricing/index.js +4 -0
- package/dist/src/core/pricing/input-utils.d.ts +32 -0
- package/dist/src/core/pricing/input-utils.js +119 -0
- package/dist/src/core/pricing/policy-context.d.ts +14 -0
- package/dist/src/core/pricing/policy-context.js +35 -0
- package/dist/src/core/pricing/policy-model.d.ts +39 -0
- package/dist/src/core/pricing/policy-model.js +77 -0
- package/dist/src/desktop/components/NewPriceTextField/NewPriceTextField.d.ts +8 -0
- package/dist/src/desktop/components/NewPriceTextField/NewPriceTextField.js +240 -0
- package/dist/src/desktop/components/NewPriceTextField/index.d.ts +1 -0
- package/dist/src/desktop/components/NewPriceTextField/index.js +8 -0
- package/dist/src/desktop/components/index.d.ts +2 -1
- package/dist/src/desktop/components/index.js +4 -2
- package/dist/src/desktop/index.d.ts +1 -1
- package/dist/src/desktop/index.js +2 -1
- package/dist/src/mobile/components/NewPriceTextField/NewPriceTextField.d.ts +8 -0
- package/dist/src/mobile/components/NewPriceTextField/NewPriceTextField.js +234 -0
- package/dist/src/mobile/components/NewPriceTextField/index.d.ts +1 -0
- package/dist/src/mobile/components/NewPriceTextField/index.js +8 -0
- package/dist/src/mobile/components/index.d.ts +2 -1
- package/dist/src/mobile/components/index.js +3 -1
- package/dist/src/mobile/index.d.ts +1 -1
- package/dist/src/mobile/index.js +2 -1
- package/dist/storybook-static/0.b73eaee9a88f178d62ed.manager.bundle.d.ts +0 -0
- package/dist/storybook-static/0.b73eaee9a88f178d62ed.manager.bundle.js +74 -0
- package/dist/storybook-static/1.f296d183a17268696d73.manager.bundle.d.ts +0 -0
- package/dist/storybook-static/1.f296d183a17268696d73.manager.bundle.js +190 -0
- package/dist/storybook-static/10.9998ba67d65d81d20896.manager.bundle.d.ts +0 -0
- package/dist/storybook-static/10.9998ba67d65d81d20896.manager.bundle.js +62 -0
- package/dist/storybook-static/11.49c687eaa6261f8b7be2.manager.bundle.d.ts +2 -0
- package/dist/storybook-static/11.49c687eaa6261f8b7be2.manager.bundle.js +534 -0
- package/dist/storybook-static/12.c9538ed3766c96f289e7.manager.bundle.d.ts +2 -0
- package/dist/storybook-static/12.c9538ed3766c96f289e7.manager.bundle.js +2 -0
- package/dist/storybook-static/5.fa71488e730c5c7f885f.manager.bundle.d.ts +18 -0
- package/dist/storybook-static/5.fa71488e730c5c7f885f.manager.bundle.js +527 -0
- package/dist/storybook-static/6.8096ae4aadde0743697b.manager.bundle.d.ts +3 -0
- package/dist/storybook-static/6.8096ae4aadde0743697b.manager.bundle.js +141 -0
- package/dist/storybook-static/7.b34baecbd082bc7b188d.manager.bundle.d.ts +0 -0
- package/dist/storybook-static/7.b34baecbd082bc7b188d.manager.bundle.js +8 -0
- package/dist/storybook-static/8.15577edffecf900a8de2.manager.bundle.d.ts +0 -0
- package/dist/storybook-static/8.15577edffecf900a8de2.manager.bundle.js +25 -0
- package/dist/storybook-static/9.d7d85aa0a49a98f17218.manager.bundle.d.ts +0 -0
- package/dist/storybook-static/9.d7d85aa0a49a98f17218.manager.bundle.js +94 -0
- package/dist/storybook-static/main.ce406c7e93b98325390e.manager.bundle.d.ts +2 -0
- package/dist/storybook-static/main.ce406c7e93b98325390e.manager.bundle.js +3824 -0
- package/dist/storybook-static/runtime~main.909d038f912f063e8837.manager.bundle.d.ts +1 -0
- package/dist/storybook-static/runtime~main.909d038f912f063e8837.manager.bundle.js +34 -0
- package/dist/storybook-static/vendors~main.d3455eed64b243c89325.manager.bundle.d.ts +3 -0
- package/dist/storybook-static/vendors~main.d3455eed64b243c89325.manager.bundle.js +11787 -0
- package/package.json +6 -2
- package/release-note.md +6 -0
- package/storybook-static/0.b73eaee9a88f178d62ed.manager.bundle.js +1 -0
- package/storybook-static/1.f296d183a17268696d73.manager.bundle.js +1 -0
- package/storybook-static/10.9998ba67d65d81d20896.manager.bundle.js +1 -0
- package/storybook-static/11.49c687eaa6261f8b7be2.manager.bundle.js +2 -0
- package/storybook-static/11.49c687eaa6261f8b7be2.manager.bundle.js.LICENSE.txt +12 -0
- package/storybook-static/12.c9538ed3766c96f289e7.manager.bundle.js +1 -0
- package/storybook-static/5.fa71488e730c5c7f885f.manager.bundle.js +2 -0
- package/storybook-static/5.fa71488e730c5c7f885f.manager.bundle.js.LICENSE.txt +8 -0
- package/storybook-static/6.8096ae4aadde0743697b.manager.bundle.js +1 -0
- package/storybook-static/7.b34baecbd082bc7b188d.manager.bundle.js +1 -0
- package/storybook-static/8.15577edffecf900a8de2.manager.bundle.js +1 -0
- package/storybook-static/9.d7d85aa0a49a98f17218.manager.bundle.js +1 -0
- package/storybook-static/favicon.ico +0 -0
- package/storybook-static/index.html +47 -0
- package/storybook-static/main.ce406c7e93b98325390e.manager.bundle.js +1 -0
- package/storybook-static/runtime~main.909d038f912f063e8837.manager.bundle.js +1 -0
- package/storybook-static/vendors~main.d3455eed64b243c89325.manager.bundle.js +2 -0
- package/storybook-static/vendors~main.d3455eed64b243c89325.manager.bundle.js.LICENSE.txt +88 -0
- package/vitest.config.ts +8 -0
package/dist/index.d.ts
CHANGED
|
@@ -8,23 +8,25 @@ export { AdminListItemTransition, InputTransition, ButtonTransition } from './sr
|
|
|
8
8
|
export { Form };
|
|
9
9
|
import { Divider, Icon, ImageView, LinearProgress, LottieIcon, Spacing, Switch } from './src/hybrid';
|
|
10
10
|
export { Divider, Icon, ImageView, LinearProgress, LottieIcon, Spacing, Switch };
|
|
11
|
-
import { LayoutWF, WFContainersBox, LayoutWH, WHContainersBox, LayoutWS, WSGlobalMenuContainer, WSContainersBox, LayoutWT, WTGlobalMenuContainer, WTContainersBox, D_AdminList, D_AdminListHeader, D_AdminListItem, D_BasicButtonGroup, D_BasicChatListItem, D_BasicFormGroup, D_BasicList, D_BasicListItem, D_BlogTextField, D_BodyTextGroup, D_BoxItem, D_Card, D_CardList, D_ChatBubbleListItem, D_ChatList, D_Checkbox, D_Chip, D_ComboBox, D_ContextMenu, D_ContextMenuItem, D_DesktopAlertDialog, D_DesktopHeaderBar, D_DesktopTabBar, D_Dropdown, D_DynamicDesktopNavBar, D_DynamicDesktopNavBarTemplates, D_EditApplyTextField, D_FilterBar, D_FloatingActionButton, D_Hero, D_HorizontalFormGroup, D_IconButton, D_ImageSlide, D_LottieReactionButton, D_MainButton, D_PageTitleTextGroup, D_Radio, D_ReactionButton, D_SegmentedButtonGroup, D_Select, D_Slider, D_Snackbar, D_StatusBlock, D_TextButton, D_PriceTextField, D_TextField, D_TextLabel, D_PriceTextLabel, D_UploadIconButton, D_UploadMainButton, D_UploadTextButton, D_UserDesktopNavBar, D_UserDesktopTabBar, D_UserDesktopSideTab, D_AnnotationSheet, D_ContentSheet, D_DesktopBasicModal, D_DesktopBasicModalWithTab, DesktopBasicModalWithTabInfoType, D_DesktopHeadlessModal, D_DesktopTutorialModal, DesktopTutorialModalInfoType, D_SectionSheet, D_Calendar, D_RichTextEditor, D_EmailRichTextEditor, D_LocalizedContentModal, LocalizedButton } from './src/desktop';
|
|
11
|
+
import { LayoutWF, WFContainersBox, LayoutWH, WHContainersBox, LayoutWS, WSGlobalMenuContainer, WSContainersBox, LayoutWT, WTGlobalMenuContainer, WTContainersBox, D_AdminList, D_AdminListHeader, D_AdminListItem, D_BasicButtonGroup, D_BasicChatListItem, D_BasicFormGroup, D_BasicList, D_BasicListItem, D_BlogTextField, D_BodyTextGroup, D_BoxItem, D_Card, D_CardList, D_ChatBubbleListItem, D_ChatList, D_Checkbox, D_Chip, D_ComboBox, D_ContextMenu, D_ContextMenuItem, D_DesktopAlertDialog, D_DesktopHeaderBar, D_DesktopTabBar, D_Dropdown, D_DynamicDesktopNavBar, D_DynamicDesktopNavBarTemplates, D_EditApplyTextField, D_FilterBar, D_FloatingActionButton, D_Hero, D_HorizontalFormGroup, D_IconButton, D_ImageSlide, D_LottieReactionButton, D_MainButton, D_PageTitleTextGroup, D_Radio, D_ReactionButton, D_SegmentedButtonGroup, D_Select, D_Slider, D_Snackbar, D_StatusBlock, D_TextButton, D_PriceTextField, D_NewPriceTextField, D_TextField, D_TextLabel, D_PriceTextLabel, D_UploadIconButton, D_UploadMainButton, D_UploadTextButton, D_UserDesktopNavBar, D_UserDesktopTabBar, D_UserDesktopSideTab, D_AnnotationSheet, D_ContentSheet, D_DesktopBasicModal, D_DesktopBasicModalWithTab, DesktopBasicModalWithTabInfoType, D_DesktopHeadlessModal, D_DesktopTutorialModal, DesktopTutorialModalInfoType, D_SectionSheet, D_Calendar, D_RichTextEditor, D_EmailRichTextEditor, D_LocalizedContentModal, LocalizedButton } from './src/desktop';
|
|
12
12
|
export { LayoutWF, WFContainersBox };
|
|
13
13
|
export { LayoutWH, WHContainersBox };
|
|
14
14
|
export { LayoutWS, WSGlobalMenuContainer, WSContainersBox };
|
|
15
15
|
export { LayoutWT, WTGlobalMenuContainer, WTContainersBox };
|
|
16
|
-
export { D_AdminList, D_AdminListHeader, D_AdminListItem, D_BasicButtonGroup, D_BasicChatListItem, D_BasicFormGroup, D_BasicList, D_BasicListItem, D_BlogTextField, D_BodyTextGroup, D_BoxItem, D_Card, D_CardList, D_ChatBubbleListItem, D_ChatList, D_Checkbox, D_Chip, D_ComboBox, D_ContextMenu, D_ContextMenuItem, D_DesktopAlertDialog, D_DesktopHeaderBar, D_DesktopTabBar, D_Dropdown, D_DynamicDesktopNavBar, D_DynamicDesktopNavBarTemplates, D_EditApplyTextField, D_FilterBar, D_FloatingActionButton, D_Hero, D_HorizontalFormGroup, D_IconButton, D_ImageSlide, D_LottieReactionButton, D_MainButton, D_PageTitleTextGroup, D_Radio, D_ReactionButton, D_SegmentedButtonGroup, D_Select, D_Slider, D_Snackbar, D_StatusBlock, D_TextButton, D_PriceTextField, D_TextField, D_TextLabel, D_PriceTextLabel, D_UploadIconButton, D_UploadMainButton, D_UploadTextButton, D_UserDesktopNavBar, D_UserDesktopTabBar, D_UserDesktopSideTab, D_Calendar, D_RichTextEditor, D_EmailRichTextEditor, LocalizedButton };
|
|
16
|
+
export { D_AdminList, D_AdminListHeader, D_AdminListItem, D_BasicButtonGroup, D_BasicChatListItem, D_BasicFormGroup, D_BasicList, D_BasicListItem, D_BlogTextField, D_BodyTextGroup, D_BoxItem, D_Card, D_CardList, D_ChatBubbleListItem, D_ChatList, D_Checkbox, D_Chip, D_ComboBox, D_ContextMenu, D_ContextMenuItem, D_DesktopAlertDialog, D_DesktopHeaderBar, D_DesktopTabBar, D_Dropdown, D_DynamicDesktopNavBar, D_DynamicDesktopNavBarTemplates, D_EditApplyTextField, D_FilterBar, D_FloatingActionButton, D_Hero, D_HorizontalFormGroup, D_IconButton, D_ImageSlide, D_LottieReactionButton, D_MainButton, D_PageTitleTextGroup, D_Radio, D_ReactionButton, D_SegmentedButtonGroup, D_Select, D_Slider, D_Snackbar, D_StatusBlock, D_TextButton, D_PriceTextField, D_NewPriceTextField, D_TextField, D_TextLabel, D_PriceTextLabel, D_UploadIconButton, D_UploadMainButton, D_UploadTextButton, D_UserDesktopNavBar, D_UserDesktopTabBar, D_UserDesktopSideTab, D_Calendar, D_RichTextEditor, D_EmailRichTextEditor, LocalizedButton };
|
|
17
17
|
export { D_AnnotationSheet, D_ContentSheet, D_DesktopBasicModal, D_DesktopBasicModalWithTab, D_DesktopHeadlessModal, D_DesktopTutorialModal, D_LocalizedContentModal, D_SectionSheet };
|
|
18
18
|
export type { DesktopBasicModalWithTabInfoType, DesktopTutorialModalInfoType };
|
|
19
|
-
import { LayoutMF, MFContainersBox, LayoutMM, MMNavigationContainer, MMContainersBox, LayoutMP, MPNavigationContainer, MPTabContainer, MPContainersBox, LayoutMS, MSNavigationContainer, MSContainersBox, M_BasicButtonGroup, M_BasicChatListItem, M_BasicFormGroup, M_BasicList, M_BasicListItem, M_BlogTextField, M_BodyTextGroup, M_BoxItem, M_Card, M_CardList, M_ChatBubbleListItem, M_ChatList, M_Checkbox, M_Chip, M_ComboBox, M_ContextMenu, M_ContextMenuItem, M_DatePicker, M_Dropdown, M_FloatingActionButton, M_HorizontalFormGroup, M_IconButton, M_ImageSlide, M_LottieReactionButton, M_MainButton, M_MobileAlertDialog, M_MobileHeaderBar, M_MobileTabBar, M_Radio, M_ReactionButton, M_SegmentedButtonGroup, M_Select, M_Slider, M_Snackbar, M_StatusBlock, M_TextButton, M_PriceTextField, M_TextField, M_TextLabel, M_PriceTextLabel, M_UploadIconButton, M_UploadMainButton, M_UploadTextButton, M_AnnotationSheet, M_ContentSheet, M_MobileBasicModal, M_SectionSheet, M_RichTextEditor } from './src/mobile';
|
|
19
|
+
import { LayoutMF, MFContainersBox, LayoutMM, MMNavigationContainer, MMContainersBox, LayoutMP, MPNavigationContainer, MPTabContainer, MPContainersBox, LayoutMS, MSNavigationContainer, MSContainersBox, M_BasicButtonGroup, M_BasicChatListItem, M_BasicFormGroup, M_BasicList, M_BasicListItem, M_BlogTextField, M_BodyTextGroup, M_BoxItem, M_Card, M_CardList, M_ChatBubbleListItem, M_ChatList, M_Checkbox, M_Chip, M_ComboBox, M_ContextMenu, M_ContextMenuItem, M_DatePicker, M_Dropdown, M_FloatingActionButton, M_HorizontalFormGroup, M_IconButton, M_ImageSlide, M_LottieReactionButton, M_MainButton, M_MobileAlertDialog, M_MobileHeaderBar, M_MobileTabBar, M_Radio, M_ReactionButton, M_SegmentedButtonGroup, M_Select, M_Slider, M_Snackbar, M_StatusBlock, M_TextButton, M_PriceTextField, M_NewPriceTextField, M_TextField, M_TextLabel, M_PriceTextLabel, M_UploadIconButton, M_UploadMainButton, M_UploadTextButton, M_AnnotationSheet, M_ContentSheet, M_MobileBasicModal, M_SectionSheet, M_RichTextEditor } from './src/mobile';
|
|
20
20
|
export { LayoutMF, MFContainersBox };
|
|
21
21
|
export { LayoutMM, MMNavigationContainer, MMContainersBox };
|
|
22
22
|
export { LayoutMP, MPNavigationContainer, MPTabContainer, MPContainersBox };
|
|
23
23
|
export { LayoutMS, MSNavigationContainer, MSContainersBox };
|
|
24
|
-
export { M_BasicButtonGroup, M_BasicChatListItem, M_BasicFormGroup, M_BasicList, M_BasicListItem, M_BlogTextField, M_BodyTextGroup, M_BoxItem, M_Card, M_CardList, M_ChatBubbleListItem, M_ChatList, M_Checkbox, M_Chip, M_ComboBox, M_ContextMenu, M_ContextMenuItem, M_DatePicker, M_Dropdown, M_FloatingActionButton, M_HorizontalFormGroup, M_IconButton, M_ImageSlide, M_LottieReactionButton, M_MainButton, M_MobileAlertDialog, M_MobileHeaderBar, M_MobileTabBar, M_Radio, M_ReactionButton, M_SegmentedButtonGroup, M_Select, M_Slider, M_Snackbar, M_StatusBlock, M_TextButton, M_PriceTextField, M_TextField, M_TextLabel, M_PriceTextLabel, M_UploadIconButton, M_UploadMainButton, M_UploadTextButton, M_RichTextEditor };
|
|
24
|
+
export { M_BasicButtonGroup, M_BasicChatListItem, M_BasicFormGroup, M_BasicList, M_BasicListItem, M_BlogTextField, M_BodyTextGroup, M_BoxItem, M_Card, M_CardList, M_ChatBubbleListItem, M_ChatList, M_Checkbox, M_Chip, M_ComboBox, M_ContextMenu, M_ContextMenuItem, M_DatePicker, M_Dropdown, M_FloatingActionButton, M_HorizontalFormGroup, M_IconButton, M_ImageSlide, M_LottieReactionButton, M_MainButton, M_MobileAlertDialog, M_MobileHeaderBar, M_MobileTabBar, M_Radio, M_ReactionButton, M_SegmentedButtonGroup, M_Select, M_Slider, M_Snackbar, M_StatusBlock, M_TextButton, M_PriceTextField, M_NewPriceTextField, M_TextField, M_TextLabel, M_PriceTextLabel, M_UploadIconButton, M_UploadMainButton, M_UploadTextButton, M_RichTextEditor };
|
|
25
25
|
export { M_AnnotationSheet, M_ContentSheet, M_MobileBasicModal, M_SectionSheet };
|
|
26
26
|
import { DynamicLayout } from './src/sub';
|
|
27
27
|
export { DynamicLayout };
|
|
28
28
|
import type { TypeOfSectionManifestSchema, TypeofSectionTemplate, TypeOfSectionContentMediaType, TypeOfSectionLinkType, TypeOfCarouselAutoplayMode, TypeOfCarouselInfiniteLoopMode, TypeOfBackgroundMediaType, TypeOfSectionButtonDesignType, TypeOfItemButtonDesignType, TypeOfItemManifestSchema, TypeOfItemLinkMethod, TypeOfItemLinkType, ISection, ISectionProperties, ISectionStyles, IItem, TypeOfSectionAction, TypeOfProgrammedItemActionButtonTextType, TypeOfItemToneType, IProgrammedSectionComponents } from './src/sub/DynamicLayout/types';
|
|
29
29
|
export { TypeOfSectionManifestSchema, TypeofSectionTemplate, TypeOfSectionContentMediaType, TypeOfSectionLinkType, TypeOfCarouselAutoplayMode, TypeOfCarouselInfiniteLoopMode, TypeOfBackgroundMediaType, TypeOfSectionButtonDesignType, TypeOfItemButtonDesignType, TypeOfItemManifestSchema, TypeOfItemLinkMethod, TypeOfItemLinkType, TypeOfSectionAction, ISection, ISectionProperties, ISectionStyles, IItem, TypeOfProgrammedItemActionButtonTextType, TypeOfItemToneType, IProgrammedSectionComponents };
|
|
30
30
|
export { AdminList, AdminListHeader, AdminListItem, BulkActionBar, ToolBar } from './src/sub';
|
|
31
|
+
export { PricingPolicyProvider, usePricingPolicy, createPricingPolicy, DEFAULT_PRICING_POLICY, CurrencyCode } from './src/core/pricing';
|
|
32
|
+
export type { PricingPolicy, PricingPolicyInput, CurrencyPolicy, NewPriceTextFieldProps, NewPriceTextFieldValidation } from './src/core/pricing';
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LayoutWF = exports.Switch = exports.Spacing = exports.LottieIcon = exports.LinearProgress = exports.ImageView = exports.Icon = exports.Divider = exports.Form = exports.ButtonTransition = exports.InputTransition = exports.AdminListItemTransition = exports.scaleBounceOutIncludeTranslate02 = exports.scaleBounceInIncludeTranslate02 = exports.scaleBounceOutIncludeTranslate = exports.scaleBounceInIncludeTranslate = exports.scaleBounceOut02 = exports.scaleBounceOut = exports.scaleBounceIn02 = exports.scaleBounceIn = exports.gelatine = exports.scaleDownIncludeTranslate = exports.scaleUpIncludeTranslate = exports.scaleDown = exports.scaleUp = exports.glow = exports.fadeOut = exports.fadeIn = exports.modalOverlayOffAni = exports.modalOverlayOnAni = exports.modalOffAni = exports.modalOnAni = exports.dialogOverlayOffAni = exports.dialogOverlayOnAni = exports.dialogOffAni = exports.dialogOnAni = exports.theme = exports.customTheme = exports.uiColors = exports.spacing = exports.boxShadow = exports.mobileEditorLineHeight = exports.mobileEditorFontSize = exports.mobileLineHeight = exports.mobileFontSize = exports.desktopEditorLineHeight = exports.desktopEditorFontSize = exports.desktopLineHeight = exports.desktopFontSize = exports.fontWeight = void 0;
|
|
4
4
|
exports.D_Slider = exports.D_Select = exports.D_SegmentedButtonGroup = exports.D_ReactionButton = exports.D_Radio = exports.D_PageTitleTextGroup = exports.D_MainButton = exports.D_LottieReactionButton = exports.D_ImageSlide = exports.D_IconButton = exports.D_HorizontalFormGroup = exports.D_Hero = exports.D_FloatingActionButton = exports.D_FilterBar = exports.D_EditApplyTextField = exports.D_DynamicDesktopNavBarTemplates = exports.D_DynamicDesktopNavBar = exports.D_Dropdown = exports.D_DesktopTabBar = exports.D_DesktopHeaderBar = exports.D_DesktopAlertDialog = exports.D_ContextMenuItem = exports.D_ContextMenu = exports.D_ComboBox = exports.D_Chip = exports.D_Checkbox = exports.D_ChatList = exports.D_ChatBubbleListItem = exports.D_CardList = exports.D_Card = exports.D_BoxItem = exports.D_BodyTextGroup = exports.D_BlogTextField = exports.D_BasicListItem = exports.D_BasicList = exports.D_BasicFormGroup = exports.D_BasicChatListItem = exports.D_BasicButtonGroup = exports.D_AdminListItem = exports.D_AdminListHeader = exports.D_AdminList = exports.WTContainersBox = exports.WTGlobalMenuContainer = exports.LayoutWT = exports.WSContainersBox = exports.WSGlobalMenuContainer = exports.LayoutWS = exports.WHContainersBox = exports.LayoutWH = exports.WFContainersBox = void 0;
|
|
5
|
-
exports.
|
|
6
|
-
exports.ToolBar = exports.BulkActionBar = exports.AdminListItem = exports.AdminListHeader = exports.AdminList = exports.DynamicLayout = exports.M_SectionSheet = exports.M_MobileBasicModal = exports.M_ContentSheet = exports.M_AnnotationSheet = exports.M_RichTextEditor = exports.M_UploadTextButton = exports.M_UploadMainButton = exports.M_UploadIconButton = exports.M_PriceTextLabel = exports.M_TextLabel = exports.M_TextField = exports.M_PriceTextField = exports.M_TextButton = exports.M_StatusBlock = exports.M_Snackbar = exports.M_Slider = exports.M_Select = exports.M_SegmentedButtonGroup = exports.M_ReactionButton = exports.M_Radio = exports.M_MobileTabBar = exports.M_MobileHeaderBar = exports.M_MobileAlertDialog = exports.M_MainButton = exports.M_LottieReactionButton = exports.M_ImageSlide = exports.M_IconButton = exports.M_HorizontalFormGroup = exports.M_FloatingActionButton = exports.M_Dropdown = exports.M_DatePicker = exports.M_ContextMenuItem = exports.M_ContextMenu = exports.M_ComboBox = exports.M_Chip = void 0;
|
|
5
|
+
exports.M_ChatList = exports.M_ChatBubbleListItem = exports.M_CardList = exports.M_Card = exports.M_BoxItem = exports.M_BodyTextGroup = exports.M_BlogTextField = exports.M_BasicListItem = exports.M_BasicList = exports.M_BasicFormGroup = exports.M_BasicChatListItem = exports.M_BasicButtonGroup = exports.MSContainersBox = exports.MSNavigationContainer = exports.LayoutMS = exports.MPContainersBox = exports.MPTabContainer = exports.MPNavigationContainer = exports.LayoutMP = exports.MMContainersBox = exports.MMNavigationContainer = exports.LayoutMM = exports.MFContainersBox = exports.LayoutMF = exports.D_SectionSheet = exports.D_LocalizedContentModal = exports.D_DesktopTutorialModal = exports.D_DesktopHeadlessModal = exports.D_DesktopBasicModalWithTab = exports.D_DesktopBasicModal = exports.D_ContentSheet = exports.D_AnnotationSheet = exports.LocalizedButton = exports.D_EmailRichTextEditor = exports.D_RichTextEditor = exports.D_Calendar = exports.D_UserDesktopSideTab = exports.D_UserDesktopTabBar = exports.D_UserDesktopNavBar = exports.D_UploadTextButton = exports.D_UploadMainButton = exports.D_UploadIconButton = exports.D_PriceTextLabel = exports.D_TextLabel = exports.D_TextField = exports.D_NewPriceTextField = exports.D_PriceTextField = exports.D_TextButton = exports.D_StatusBlock = exports.D_Snackbar = void 0;
|
|
6
|
+
exports.CurrencyCode = exports.DEFAULT_PRICING_POLICY = exports.createPricingPolicy = exports.usePricingPolicy = exports.PricingPolicyProvider = exports.ToolBar = exports.BulkActionBar = exports.AdminListItem = exports.AdminListHeader = exports.AdminList = exports.DynamicLayout = exports.M_SectionSheet = exports.M_MobileBasicModal = exports.M_ContentSheet = exports.M_AnnotationSheet = exports.M_RichTextEditor = exports.M_UploadTextButton = exports.M_UploadMainButton = exports.M_UploadIconButton = exports.M_PriceTextLabel = exports.M_TextLabel = exports.M_TextField = exports.M_NewPriceTextField = exports.M_PriceTextField = exports.M_TextButton = exports.M_StatusBlock = exports.M_Snackbar = exports.M_Slider = exports.M_Select = exports.M_SegmentedButtonGroup = exports.M_ReactionButton = exports.M_Radio = exports.M_MobileTabBar = exports.M_MobileHeaderBar = exports.M_MobileAlertDialog = exports.M_MainButton = exports.M_LottieReactionButton = exports.M_ImageSlide = exports.M_IconButton = exports.M_HorizontalFormGroup = exports.M_FloatingActionButton = exports.M_Dropdown = exports.M_DatePicker = exports.M_ContextMenuItem = exports.M_ContextMenu = exports.M_ComboBox = exports.M_Chip = exports.M_Checkbox = void 0;
|
|
7
7
|
/* eslint-disable import/order */
|
|
8
8
|
/* eslint-disable import/first */
|
|
9
9
|
// common
|
|
@@ -122,6 +122,7 @@ Object.defineProperty(exports, "D_Snackbar", { enumerable: true, get: function (
|
|
|
122
122
|
Object.defineProperty(exports, "D_StatusBlock", { enumerable: true, get: function () { return desktop_1.D_StatusBlock; } });
|
|
123
123
|
Object.defineProperty(exports, "D_TextButton", { enumerable: true, get: function () { return desktop_1.D_TextButton; } });
|
|
124
124
|
Object.defineProperty(exports, "D_PriceTextField", { enumerable: true, get: function () { return desktop_1.D_PriceTextField; } });
|
|
125
|
+
Object.defineProperty(exports, "D_NewPriceTextField", { enumerable: true, get: function () { return desktop_1.D_NewPriceTextField; } });
|
|
125
126
|
Object.defineProperty(exports, "D_TextField", { enumerable: true, get: function () { return desktop_1.D_TextField; } });
|
|
126
127
|
Object.defineProperty(exports, "D_TextLabel", { enumerable: true, get: function () { return desktop_1.D_TextLabel; } });
|
|
127
128
|
Object.defineProperty(exports, "D_PriceTextLabel", { enumerable: true, get: function () { return desktop_1.D_PriceTextLabel; } });
|
|
@@ -194,6 +195,7 @@ Object.defineProperty(exports, "M_Snackbar", { enumerable: true, get: function (
|
|
|
194
195
|
Object.defineProperty(exports, "M_StatusBlock", { enumerable: true, get: function () { return mobile_1.M_StatusBlock; } });
|
|
195
196
|
Object.defineProperty(exports, "M_TextButton", { enumerable: true, get: function () { return mobile_1.M_TextButton; } });
|
|
196
197
|
Object.defineProperty(exports, "M_PriceTextField", { enumerable: true, get: function () { return mobile_1.M_PriceTextField; } });
|
|
198
|
+
Object.defineProperty(exports, "M_NewPriceTextField", { enumerable: true, get: function () { return mobile_1.M_NewPriceTextField; } });
|
|
197
199
|
Object.defineProperty(exports, "M_TextField", { enumerable: true, get: function () { return mobile_1.M_TextField; } });
|
|
198
200
|
Object.defineProperty(exports, "M_TextLabel", { enumerable: true, get: function () { return mobile_1.M_TextLabel; } });
|
|
199
201
|
Object.defineProperty(exports, "M_PriceTextLabel", { enumerable: true, get: function () { return mobile_1.M_PriceTextLabel; } });
|
|
@@ -216,3 +218,10 @@ Object.defineProperty(exports, "AdminListHeader", { enumerable: true, get: funct
|
|
|
216
218
|
Object.defineProperty(exports, "AdminListItem", { enumerable: true, get: function () { return sub_2.AdminListItem; } });
|
|
217
219
|
Object.defineProperty(exports, "BulkActionBar", { enumerable: true, get: function () { return sub_2.BulkActionBar; } });
|
|
218
220
|
Object.defineProperty(exports, "ToolBar", { enumerable: true, get: function () { return sub_2.ToolBar; } });
|
|
221
|
+
// 통화 정책 (NewPriceTextField)
|
|
222
|
+
var pricing_1 = require("./src/core/pricing");
|
|
223
|
+
Object.defineProperty(exports, "PricingPolicyProvider", { enumerable: true, get: function () { return pricing_1.PricingPolicyProvider; } });
|
|
224
|
+
Object.defineProperty(exports, "usePricingPolicy", { enumerable: true, get: function () { return pricing_1.usePricingPolicy; } });
|
|
225
|
+
Object.defineProperty(exports, "createPricingPolicy", { enumerable: true, get: function () { return pricing_1.createPricingPolicy; } });
|
|
226
|
+
Object.defineProperty(exports, "DEFAULT_PRICING_POLICY", { enumerable: true, get: function () { return pricing_1.DEFAULT_PRICING_POLICY; } });
|
|
227
|
+
Object.defineProperty(exports, "CurrencyCode", { enumerable: true, get: function () { return pricing_1.CurrencyCode; } });
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { CurrencyCode } from '../types';
|
|
3
|
+
import type { IFormValues, PDSTextType } from '../../../common/types';
|
|
4
|
+
import type { Path } from 'react-hook-form';
|
|
5
|
+
type InputElement = HTMLInputElement | HTMLTextAreaElement;
|
|
6
|
+
export type NewPriceTextFieldValidation = {
|
|
7
|
+
/** false면 필수 검증 해제, 문자열이면 그 문구로 필수 검증 */
|
|
8
|
+
required?: boolean | string;
|
|
9
|
+
/** 키 단위로 기본 검증(min/max/format)을 덮어쓰거나 추가한다 */
|
|
10
|
+
validate?: Record<string, (value: string) => string | boolean | undefined>;
|
|
11
|
+
};
|
|
12
|
+
export type NewPriceTextFieldProps = {
|
|
13
|
+
name: Path<IFormValues>;
|
|
14
|
+
hintText?: PDSTextType;
|
|
15
|
+
defaultAmount?: number;
|
|
16
|
+
validation?: NewPriceTextFieldValidation;
|
|
17
|
+
size?: 'large' | 'rlarge' | 'medium' | 'small';
|
|
18
|
+
state?: 'normal' | 'read_only';
|
|
19
|
+
responsiveMode?: 'none' | 'use';
|
|
20
|
+
customWidth?: string;
|
|
21
|
+
deleteBtnMode?: 'none' | 'use';
|
|
22
|
+
useRequirementMode?: 'none' | 'use';
|
|
23
|
+
onChange?: (e: React.ChangeEvent<InputElement>) => void;
|
|
24
|
+
onBlur?: (e: React.FocusEvent<InputElement>) => void;
|
|
25
|
+
onFocus?: (e: React.FocusEvent<InputElement>) => void;
|
|
26
|
+
onKeyDown?: (e: React.KeyboardEvent<InputElement>) => void;
|
|
27
|
+
onKeyUp?: (e: React.KeyboardEvent<InputElement>) => void;
|
|
28
|
+
onTarget?: () => void;
|
|
29
|
+
onCurrencyChange?: (selectedCurrency: string) => void;
|
|
30
|
+
onValueChange?: (data: {
|
|
31
|
+
selectedCurrency: string;
|
|
32
|
+
baseCurrencyValue: number;
|
|
33
|
+
calculatedValue: number;
|
|
34
|
+
displayValue: string;
|
|
35
|
+
}) => void;
|
|
36
|
+
};
|
|
37
|
+
export type CurrencyOption = {
|
|
38
|
+
value: CurrencyCode;
|
|
39
|
+
text: string;
|
|
40
|
+
currency: CurrencyCode;
|
|
41
|
+
state: 'normal';
|
|
42
|
+
};
|
|
43
|
+
export declare function useNewPriceTextField({ name, hintText, defaultAmount, validation, state, useRequirementMode, onChange, onBlur, onFocus, onKeyDown, onKeyUp, onTarget, onCurrencyChange, onValueChange }: NewPriceTextFieldProps): {
|
|
44
|
+
hintText: string | number | object | null | undefined;
|
|
45
|
+
displayValue: string;
|
|
46
|
+
rules: {
|
|
47
|
+
required: string | boolean;
|
|
48
|
+
validate: Record<string, (value: string) => string | boolean | undefined>;
|
|
49
|
+
};
|
|
50
|
+
errorMessage: string | undefined;
|
|
51
|
+
isFocused: boolean;
|
|
52
|
+
isInputReadOnly: boolean;
|
|
53
|
+
baseCurrency: CurrencyCode;
|
|
54
|
+
selectedCurrency: CurrencyCode;
|
|
55
|
+
currencyOptions: CurrencyOption[];
|
|
56
|
+
dropdownState: "normal" | "read_only";
|
|
57
|
+
handlers: {
|
|
58
|
+
onChange: (e: React.ChangeEvent<InputElement>) => void;
|
|
59
|
+
onBlur: (e: React.FocusEvent<InputElement>) => void;
|
|
60
|
+
onFocus: (e: React.FocusEvent<InputElement>) => void;
|
|
61
|
+
onKeyDown: ((e: import("react").KeyboardEvent<InputElement>) => void) | undefined;
|
|
62
|
+
onKeyUp: ((e: import("react").KeyboardEvent<InputElement>) => void) | undefined;
|
|
63
|
+
onTarget: () => void | undefined;
|
|
64
|
+
onDelete: () => void;
|
|
65
|
+
selectCurrency: (currency: CurrencyCode) => void;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.useNewPriceTextField = void 0;
|
|
15
|
+
var react_1 = require("react");
|
|
16
|
+
var react_hook_form_1 = require("react-hook-form");
|
|
17
|
+
var react_i18next_1 = require("react-i18next");
|
|
18
|
+
var types_1 = require("../../../common/types");
|
|
19
|
+
var input_utils_1 = require("../input-utils");
|
|
20
|
+
var policy_context_1 = require("../policy-context");
|
|
21
|
+
var service_1 = require("../service");
|
|
22
|
+
function useNewPriceTextField(_a) {
|
|
23
|
+
var _b;
|
|
24
|
+
var name = _a.name, hintText = _a.hintText, defaultAmount = _a.defaultAmount, validation = _a.validation, _c = _a.state, state = _c === void 0 ? 'normal' : _c, _d = _a.useRequirementMode, useRequirementMode = _d === void 0 ? 'use' : _d, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onKeyUp = _a.onKeyUp, onTarget = _a.onTarget, onCurrencyChange = _a.onCurrencyChange, onValueChange = _a.onValueChange;
|
|
25
|
+
var t = (0, react_i18next_1.useTranslation)('translation').t;
|
|
26
|
+
var policy = (0, policy_context_1.usePricingPolicy)();
|
|
27
|
+
var baseCurrency = policy.baseCurrency;
|
|
28
|
+
var basePolicy = policy.policies[baseCurrency];
|
|
29
|
+
if (!basePolicy) {
|
|
30
|
+
throw new Error("NewPriceTextField: policy for base currency ".concat(baseCurrency, " is missing"));
|
|
31
|
+
}
|
|
32
|
+
var decimalDigits = basePolicy.decimalDigits;
|
|
33
|
+
var _e = (0, react_hook_form_1.useFormContext)(), setValue = _e.setValue, watch = _e.watch, trigger = _e.trigger, errors = _e.formState.errors;
|
|
34
|
+
var formValue = watch(name);
|
|
35
|
+
var rawValue = (0, input_utils_1.toRawValue)(formValue);
|
|
36
|
+
var _f = (0, react_1.useState)(baseCurrency), selectedCurrency = _f[0], setSelectedCurrency = _f[1];
|
|
37
|
+
var _g = (0, react_1.useState)(false), isFocused = _g[0], setIsFocused = _g[1];
|
|
38
|
+
var didInitRef = (0, react_1.useRef)(false);
|
|
39
|
+
/** 마운트 시 폼이 비어 있고 defaultAmount가 있으면 1회만 기록. 폼 값이 있으면 폼이 우선 */
|
|
40
|
+
(0, react_1.useEffect)(function () {
|
|
41
|
+
if (didInitRef.current) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
didInitRef.current = true;
|
|
45
|
+
if (defaultAmount !== undefined && rawValue === '') {
|
|
46
|
+
setValue(name, (0, input_utils_1.normalizePriceOnBlur)(String(defaultAmount), decimalDigits));
|
|
47
|
+
}
|
|
48
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
|
+
}, []);
|
|
50
|
+
/** 기준 통화가 바뀌면(정책 교체) 선택 통화도 기준 통화로 */
|
|
51
|
+
(0, react_1.useEffect)(function () {
|
|
52
|
+
setSelectedCurrency(baseCurrency);
|
|
53
|
+
}, [baseCurrency]);
|
|
54
|
+
var isInputReadOnly = state === 'read_only' || selectedCurrency !== baseCurrency;
|
|
55
|
+
var dropdownState = policy.multiCurrency && policy.currencies.length > 1 ? 'normal' : 'read_only';
|
|
56
|
+
var currencyOptions = (0, react_1.useMemo)(function () {
|
|
57
|
+
return policy.currencies.map(function (currency) { return ({
|
|
58
|
+
value: currency,
|
|
59
|
+
text: currency,
|
|
60
|
+
currency: currency,
|
|
61
|
+
state: 'normal'
|
|
62
|
+
}); });
|
|
63
|
+
}, [policy.currencies]);
|
|
64
|
+
/** 기준 통화 금액 → 선택 통화 금액 */
|
|
65
|
+
var calculatedValue = (0, react_1.useMemo)(function () {
|
|
66
|
+
if (rawValue === '') {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
var amount = Number(rawValue);
|
|
70
|
+
if (Number.isNaN(amount)) {
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
if (selectedCurrency === baseCurrency) {
|
|
74
|
+
return amount;
|
|
75
|
+
}
|
|
76
|
+
var rate = policy.exchangeRates[selectedCurrency];
|
|
77
|
+
var baseRate = policy.exchangeRates[baseCurrency];
|
|
78
|
+
if (!rate || !baseRate) {
|
|
79
|
+
// 환율이 없으면 렌더 중 throw 대신 빈 표시 (createPricingPolicy를 거친 정책에서는 발생하지 않음)
|
|
80
|
+
return Number.NaN;
|
|
81
|
+
}
|
|
82
|
+
return service_1.PricingService.exchangePrice(amount, baseCurrency, selectedCurrency, policy.exchangeRates);
|
|
83
|
+
}, [rawValue, selectedCurrency, baseCurrency, policy.exchangeRates]);
|
|
84
|
+
var displayValue = (0, react_1.useMemo)(function () {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
if (rawValue === '' || Number.isNaN(calculatedValue)) {
|
|
87
|
+
return '';
|
|
88
|
+
}
|
|
89
|
+
if (selectedCurrency === baseCurrency) {
|
|
90
|
+
return isFocused ? (0, input_utils_1.groupDigits)(rawValue) : (0, input_utils_1.formatAmount)(rawValue, decimalDigits);
|
|
91
|
+
}
|
|
92
|
+
var selectedDigits = (_b = (_a = policy.policies[selectedCurrency]) === null || _a === void 0 ? void 0 : _a.decimalDigits) !== null && _b !== void 0 ? _b : 0;
|
|
93
|
+
return (0, input_utils_1.formatAmount)(calculatedValue, selectedDigits);
|
|
94
|
+
}, [
|
|
95
|
+
rawValue,
|
|
96
|
+
selectedCurrency,
|
|
97
|
+
baseCurrency,
|
|
98
|
+
isFocused,
|
|
99
|
+
decimalDigits,
|
|
100
|
+
calculatedValue,
|
|
101
|
+
policy.policies
|
|
102
|
+
]);
|
|
103
|
+
/** react-hook-form 검증 규칙: 문서의 기본 3종 + required, 소비자 validation으로 키 단위 재정의 */
|
|
104
|
+
var rules = (0, react_1.useMemo)(function () {
|
|
105
|
+
var _a;
|
|
106
|
+
var required = false;
|
|
107
|
+
if ((validation === null || validation === void 0 ? void 0 : validation.required) !== undefined) {
|
|
108
|
+
required = validation.required;
|
|
109
|
+
}
|
|
110
|
+
else if (useRequirementMode === 'use') {
|
|
111
|
+
required = String(t('str_please_enter_price'));
|
|
112
|
+
}
|
|
113
|
+
// 문구는 react-i18next의 t로 만든다. bare i18next 싱글턴은 소비 앱에서 중첩 설치되면
|
|
114
|
+
// 초기화되지 않아 undefined를 돌려주므로(검증이 통과로 처리됨) 쓰지 않는다.
|
|
115
|
+
var translate = function (key, options) { return String(t(key, options)); };
|
|
116
|
+
var validate = __assign({ price: function (value) { return (0, input_utils_1.validatePriceAmount)(value, basePolicy, translate); } }, ((_a = validation === null || validation === void 0 ? void 0 : validation.validate) !== null && _a !== void 0 ? _a : {}));
|
|
117
|
+
return { required: required, validate: validate };
|
|
118
|
+
}, [validation, useRequirementMode, basePolicy, t]);
|
|
119
|
+
var errorMessage = (_b = (0, types_1.getErrorByName)(errors, name)) === null || _b === void 0 ? void 0 : _b.message;
|
|
120
|
+
/** 값이 비어 있지 않을 때만 통화·환산값을 알린다 */
|
|
121
|
+
(0, react_1.useEffect)(function () {
|
|
122
|
+
var _a, _b;
|
|
123
|
+
if (!onValueChange || rawValue === '' || Number.isNaN(calculatedValue)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
var selectedDigits = (_b = (_a = policy.policies[selectedCurrency]) === null || _a === void 0 ? void 0 : _a.decimalDigits) !== null && _b !== void 0 ? _b : 0;
|
|
127
|
+
onValueChange({
|
|
128
|
+
selectedCurrency: selectedCurrency,
|
|
129
|
+
baseCurrencyValue: Number(rawValue),
|
|
130
|
+
calculatedValue: calculatedValue,
|
|
131
|
+
displayValue: (0, input_utils_1.formatAmount)(calculatedValue, selectedDigits)
|
|
132
|
+
});
|
|
133
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
134
|
+
}, [rawValue, selectedCurrency, calculatedValue]);
|
|
135
|
+
var handleChange = (0, react_1.useCallback)(function (e) {
|
|
136
|
+
if (isInputReadOnly) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
var input = e.target;
|
|
140
|
+
var selectionStart = input.selectionStart;
|
|
141
|
+
var previousDisplay = displayValue;
|
|
142
|
+
var next = (0, input_utils_1.sanitizePriceInput)(input.value, decimalDigits);
|
|
143
|
+
if (next === null) {
|
|
144
|
+
input.value = previousDisplay;
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
setValue(name, next, { shouldValidate: true, shouldDirty: true });
|
|
148
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
149
|
+
// 콤마가 추가·삭제되면 커서를 같은 자리로
|
|
150
|
+
if (previousDisplay && selectionStart !== null) {
|
|
151
|
+
setTimeout(function () {
|
|
152
|
+
var commaCount = (input.value.match(/,/g) || []).length;
|
|
153
|
+
var previousCommaCount = (previousDisplay.match(/,/g) || []).length;
|
|
154
|
+
var nextPosition = selectionStart + (commaCount - previousCommaCount);
|
|
155
|
+
input.setSelectionRange(nextPosition, nextPosition);
|
|
156
|
+
}, 0);
|
|
157
|
+
}
|
|
158
|
+
}, [isInputReadOnly, displayValue, decimalDigits, setValue, name, onChange]);
|
|
159
|
+
var handleBlur = (0, react_1.useCallback)(function (e) {
|
|
160
|
+
setIsFocused(false);
|
|
161
|
+
var validated = false;
|
|
162
|
+
if (selectedCurrency === baseCurrency && rawValue !== '') {
|
|
163
|
+
var normalized = (0, input_utils_1.normalizePriceOnBlur)(rawValue, decimalDigits);
|
|
164
|
+
if (normalized !== rawValue) {
|
|
165
|
+
setValue(name, normalized, { shouldValidate: true, shouldDirty: true });
|
|
166
|
+
validated = true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!validated) {
|
|
170
|
+
trigger(name);
|
|
171
|
+
}
|
|
172
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
173
|
+
}, [selectedCurrency, baseCurrency, rawValue, decimalDigits, setValue, trigger, name, onBlur]);
|
|
174
|
+
var handleFocus = (0, react_1.useCallback)(function (e) {
|
|
175
|
+
if (!isInputReadOnly) {
|
|
176
|
+
setIsFocused(true);
|
|
177
|
+
}
|
|
178
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
179
|
+
}, [isInputReadOnly, onFocus]);
|
|
180
|
+
var handleDelete = (0, react_1.useCallback)(function () {
|
|
181
|
+
setValue(name, '', { shouldValidate: true, shouldDirty: true });
|
|
182
|
+
}, [setValue, name]);
|
|
183
|
+
var selectCurrency = (0, react_1.useCallback)(function (currency) {
|
|
184
|
+
setSelectedCurrency(currency);
|
|
185
|
+
onCurrencyChange === null || onCurrencyChange === void 0 ? void 0 : onCurrencyChange(currency);
|
|
186
|
+
}, [onCurrencyChange]);
|
|
187
|
+
return {
|
|
188
|
+
hintText: hintText !== null && hintText !== void 0 ? hintText : t('str_please_enter_price'),
|
|
189
|
+
displayValue: displayValue,
|
|
190
|
+
rules: rules,
|
|
191
|
+
errorMessage: errorMessage,
|
|
192
|
+
isFocused: isFocused,
|
|
193
|
+
isInputReadOnly: isInputReadOnly,
|
|
194
|
+
baseCurrency: baseCurrency,
|
|
195
|
+
selectedCurrency: selectedCurrency,
|
|
196
|
+
currencyOptions: currencyOptions,
|
|
197
|
+
dropdownState: dropdownState,
|
|
198
|
+
handlers: {
|
|
199
|
+
onChange: handleChange,
|
|
200
|
+
onBlur: handleBlur,
|
|
201
|
+
onFocus: handleFocus,
|
|
202
|
+
onKeyDown: onKeyDown,
|
|
203
|
+
onKeyUp: onKeyUp,
|
|
204
|
+
onTarget: function () { return onTarget === null || onTarget === void 0 ? void 0 : onTarget(); },
|
|
205
|
+
onDelete: handleDelete,
|
|
206
|
+
selectCurrency: selectCurrency
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
exports.useNewPriceTextField = useNewPriceTextField;
|
|
@@ -16,3 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./types"), exports);
|
|
18
18
|
__exportStar(require("./service"), exports);
|
|
19
|
+
__exportStar(require("./policy-model"), exports);
|
|
20
|
+
__exportStar(require("./policy-context"), exports);
|
|
21
|
+
__exportStar(require("./input-utils"), exports);
|
|
22
|
+
__exportStar(require("./hooks/useNewPriceTextField"), exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PriceTextField 입력값 정제·포맷 순수 함수 모음.
|
|
3
|
+
* 통화 정책(소수 자릿수)만 인자로 받고 React/RHF에 의존하지 않는다.
|
|
4
|
+
*/
|
|
5
|
+
/** 폼에 들어 있는 값을 콤마·공백 없는 숫자 문자열로 바꾼다. */
|
|
6
|
+
export declare function toRawValue(formValue: unknown): string;
|
|
7
|
+
/** 입력 중 표시용: 정수부에만 천 단위 콤마를 넣는다. */
|
|
8
|
+
export declare function groupDigits(raw: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* 키 입력 결과를 정제한다.
|
|
11
|
+
* @returns 허용된 숫자 문자열(콤마 없음) 또는 거부 시 null
|
|
12
|
+
*/
|
|
13
|
+
export declare function sanitizePriceInput(input: string, decimalDigits: number): string | null;
|
|
14
|
+
/** blur 시 소수 자릿수를 고정한다. 입력 단계에서 자릿수를 이미 제한하므로 반올림은 일어나지 않는다. */
|
|
15
|
+
export declare function normalizePriceOnBlur(raw: string, decimalDigits: number): string;
|
|
16
|
+
/** 표시용 포맷: 자릿수 고정 + 천 단위 콤마 */
|
|
17
|
+
export declare function formatAmount(amount: number | string, decimalDigits: number): string;
|
|
18
|
+
/** 검증에 필요한 통화 정책 부분집합 (policy-model의 CurrencyPolicy와 호환) */
|
|
19
|
+
export type PriceAmountPolicy = {
|
|
20
|
+
code: string;
|
|
21
|
+
decimalDigits: number;
|
|
22
|
+
minAmount: number;
|
|
23
|
+
maxAmount: number;
|
|
24
|
+
paymentUnit: number;
|
|
25
|
+
};
|
|
26
|
+
/** react-i18next의 t 와 같은 모양. bare i18next 싱글턴에 의존하지 않기 위해 주입받는다 */
|
|
27
|
+
export type PriceMessageTranslator = (key: string, options?: Record<string, unknown>) => string;
|
|
28
|
+
/**
|
|
29
|
+
* 가격 입력값을 정책(최소·최대·단위·소수 자릿수)으로 검증한다.
|
|
30
|
+
* @returns 오류 문구(i18n 적용) 또는 통과 시 undefined. 빈 값은 통과(required는 별도 처리)
|
|
31
|
+
*/
|
|
32
|
+
export declare function validatePriceAmount(value: string, policy: PriceAmountPolicy, t: PriceMessageTranslator): string | undefined;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PriceTextField 입력값 정제·포맷 순수 함수 모음.
|
|
4
|
+
* 통화 정책(소수 자릿수)만 인자로 받고 React/RHF에 의존하지 않는다.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.validatePriceAmount = exports.formatAmount = exports.normalizePriceOnBlur = exports.sanitizePriceInput = exports.groupDigits = exports.toRawValue = void 0;
|
|
8
|
+
/** 폼에 들어 있는 값을 콤마·공백 없는 숫자 문자열로 바꾼다. */
|
|
9
|
+
function toRawValue(formValue) {
|
|
10
|
+
if (formValue === null || formValue === undefined) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
return String(formValue).replace(/[,\s]/g, '');
|
|
14
|
+
}
|
|
15
|
+
exports.toRawValue = toRawValue;
|
|
16
|
+
/** 입력 중 표시용: 정수부에만 천 단위 콤마를 넣는다. */
|
|
17
|
+
function groupDigits(raw) {
|
|
18
|
+
if (!raw) {
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
var _a = raw.split('.'), integerPart = _a[0], decimalPart = _a[1];
|
|
22
|
+
var grouped = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
23
|
+
return decimalPart !== undefined ? "".concat(grouped, ".").concat(decimalPart) : grouped;
|
|
24
|
+
}
|
|
25
|
+
exports.groupDigits = groupDigits;
|
|
26
|
+
/**
|
|
27
|
+
* 키 입력 결과를 정제한다.
|
|
28
|
+
* @returns 허용된 숫자 문자열(콤마 없음) 또는 거부 시 null
|
|
29
|
+
*/
|
|
30
|
+
function sanitizePriceInput(input, decimalDigits) {
|
|
31
|
+
var raw = input.replace(/[,\s]/g, '');
|
|
32
|
+
if (raw === '') {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
if (!/^\d*\.?\d*$/.test(raw)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (decimalDigits === 0 && raw.includes('.')) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
var _a = raw.split('.'), fraction = _a[1];
|
|
42
|
+
if (fraction !== undefined && fraction.length > decimalDigits) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return raw;
|
|
46
|
+
}
|
|
47
|
+
exports.sanitizePriceInput = sanitizePriceInput;
|
|
48
|
+
/** blur 시 소수 자릿수를 고정한다. 입력 단계에서 자릿수를 이미 제한하므로 반올림은 일어나지 않는다. */
|
|
49
|
+
function normalizePriceOnBlur(raw, decimalDigits) {
|
|
50
|
+
if (raw === '' || raw === '.') {
|
|
51
|
+
return '';
|
|
52
|
+
}
|
|
53
|
+
var numeric = Number(raw);
|
|
54
|
+
if (Number.isNaN(numeric)) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
return numeric.toFixed(decimalDigits);
|
|
58
|
+
}
|
|
59
|
+
exports.normalizePriceOnBlur = normalizePriceOnBlur;
|
|
60
|
+
/** 표시용 포맷: 자릿수 고정 + 천 단위 콤마 */
|
|
61
|
+
function formatAmount(amount, decimalDigits) {
|
|
62
|
+
var fixed = Number(amount).toFixed(decimalDigits);
|
|
63
|
+
return decimalDigits > 0
|
|
64
|
+
? fixed.replace(/(\d)(?=(\d{3})+\.)/g, '$1,')
|
|
65
|
+
: fixed.replace(/(\d)(?=(\d{3})+$)/g, '$1,');
|
|
66
|
+
}
|
|
67
|
+
exports.formatAmount = formatAmount;
|
|
68
|
+
function getDecimalPlaces(value) {
|
|
69
|
+
var decimalStr = value.toString().split('.')[1];
|
|
70
|
+
return decimalStr ? decimalStr.length : 0;
|
|
71
|
+
}
|
|
72
|
+
function isDivisible(amount, unit) {
|
|
73
|
+
var precision = Math.pow(10, Math.max(getDecimalPlaces(amount), getDecimalPlaces(unit)));
|
|
74
|
+
var intAmount = Math.round(amount * precision);
|
|
75
|
+
var intUnit = Math.round(unit * precision);
|
|
76
|
+
return intAmount % intUnit === 0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 가격 입력값을 정책(최소·최대·단위·소수 자릿수)으로 검증한다.
|
|
80
|
+
* @returns 오류 문구(i18n 적용) 또는 통과 시 undefined. 빈 값은 통과(required는 별도 처리)
|
|
81
|
+
*/
|
|
82
|
+
function validatePriceAmount(value, policy, t) {
|
|
83
|
+
var raw = toRawValue(value);
|
|
84
|
+
if (raw === '') {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
var amount = Number(raw);
|
|
88
|
+
if (Number.isNaN(amount)) {
|
|
89
|
+
return t('str_please_enter_price');
|
|
90
|
+
}
|
|
91
|
+
var currency = policy.code;
|
|
92
|
+
if (amount < policy.minAmount) {
|
|
93
|
+
return t('str_min_price', {
|
|
94
|
+
minPrice: formatAmount(policy.minAmount, policy.decimalDigits),
|
|
95
|
+
currency: currency
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (amount > policy.maxAmount) {
|
|
99
|
+
return t('str_max_price', {
|
|
100
|
+
maxPrice: formatAmount(policy.maxAmount, policy.decimalDigits),
|
|
101
|
+
currency: currency
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
var unitMessage = function () {
|
|
105
|
+
return t('str_price_unit', {
|
|
106
|
+
priceUnit: formatAmount(policy.paymentUnit, policy.decimalDigits),
|
|
107
|
+
currency: currency
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
var _a = raw.split('.'), fraction = _a[1];
|
|
111
|
+
if (fraction !== undefined && fraction.length > policy.decimalDigits) {
|
|
112
|
+
return unitMessage();
|
|
113
|
+
}
|
|
114
|
+
if (!isDivisible(amount, policy.paymentUnit)) {
|
|
115
|
+
return unitMessage();
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
exports.validatePriceAmount = validatePriceAmount;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PricingPolicy, PricingPolicyInput } from './policy-model';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
type Props = {
|
|
4
|
+
/** 완성된 정책 또는 createPricingPolicy 입력 */
|
|
5
|
+
policy: PricingPolicy | PricingPolicyInput;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* 채널 통화 정책을 하위 NewPriceTextField에 공급한다.
|
|
10
|
+
* 소비 앱은 채널 프로바이더 안쪽에서 한 번만 감싼다.
|
|
11
|
+
*/
|
|
12
|
+
export declare function PricingPolicyProvider({ policy, children }: Props): JSX.Element;
|
|
13
|
+
export declare function usePricingPolicy(): PricingPolicy;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.usePricingPolicy = exports.PricingPolicyProvider = void 0;
|
|
15
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var react_1 = require("react");
|
|
17
|
+
var policy_model_1 = require("./policy-model");
|
|
18
|
+
var PricingPolicyContext = (0, react_1.createContext)(policy_model_1.DEFAULT_PRICING_POLICY);
|
|
19
|
+
function isPricingPolicy(policy) {
|
|
20
|
+
return 'policies' in policy && 'currencies' in policy;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 채널 통화 정책을 하위 NewPriceTextField에 공급한다.
|
|
24
|
+
* 소비 앱은 채널 프로바이더 안쪽에서 한 번만 감싼다.
|
|
25
|
+
*/
|
|
26
|
+
function PricingPolicyProvider(_a) {
|
|
27
|
+
var policy = _a.policy, children = _a.children;
|
|
28
|
+
var value = (0, react_1.useMemo)(function () { return (isPricingPolicy(policy) ? policy : (0, policy_model_1.createPricingPolicy)(policy)); }, [policy]);
|
|
29
|
+
return (0, jsx_runtime_1.jsx)(PricingPolicyContext.Provider, __assign({ value: value }, { children: children }));
|
|
30
|
+
}
|
|
31
|
+
exports.PricingPolicyProvider = PricingPolicyProvider;
|
|
32
|
+
function usePricingPolicy() {
|
|
33
|
+
return (0, react_1.useContext)(PricingPolicyContext);
|
|
34
|
+
}
|
|
35
|
+
exports.usePricingPolicy = usePricingPolicy;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CurrencyCode } from './types';
|
|
2
|
+
import type { ExchangeRateMap } from './types';
|
|
3
|
+
/** 통화 하나의 입력·표시 규칙 */
|
|
4
|
+
export type CurrencyPolicy = {
|
|
5
|
+
code: CurrencyCode;
|
|
6
|
+
/** 소수 자릿수 (KRW 0, USD 2) */
|
|
7
|
+
decimalDigits: number;
|
|
8
|
+
minAmount: number;
|
|
9
|
+
maxAmount: number;
|
|
10
|
+
/** 입력 단위 (KRW 100, USD 0.01) */
|
|
11
|
+
paymentUnit: number;
|
|
12
|
+
};
|
|
13
|
+
/** 채널 단위 통화 정책. PricingPolicyProvider로 공급한다. */
|
|
14
|
+
export type PricingPolicy = {
|
|
15
|
+
baseCurrency: CurrencyCode;
|
|
16
|
+
/** 드롭다운 순서. 첫 번째는 항상 기준 통화 */
|
|
17
|
+
currencies: CurrencyCode[];
|
|
18
|
+
/** 기준 통화 대비 환율. 기준 통화는 1 */
|
|
19
|
+
exchangeRates: ExchangeRateMap;
|
|
20
|
+
/** true면 드롭다운 선택 가능, false면 읽기 전용 */
|
|
21
|
+
multiCurrency: boolean;
|
|
22
|
+
policies: Partial<Record<CurrencyCode, CurrencyPolicy>>;
|
|
23
|
+
};
|
|
24
|
+
/** 소비 앱이 채널 정보로 정책을 만들 때 쓰는 입력 */
|
|
25
|
+
export type PricingPolicyInput = {
|
|
26
|
+
baseCurrency: CurrencyCode;
|
|
27
|
+
altCurrencies?: CurrencyCode[];
|
|
28
|
+
/** 기준 통화 대비 환율. 기준 통화 항목은 생략 가능(1로 간주). 기준 통화가 1이 아니면 그 값으로 나눠 정규화 */
|
|
29
|
+
exchangeRates?: ExchangeRateMap;
|
|
30
|
+
/** 생략하면 보조 통화가 하나라도 있을 때 true */
|
|
31
|
+
multiCurrency?: boolean;
|
|
32
|
+
/** 통화별 소수 자릿수 재정의 (예: 채널의 baseCurrencyDecimalPlaces) */
|
|
33
|
+
decimalDigits?: Partial<Record<CurrencyCode, number>>;
|
|
34
|
+
/** 통화별 최소·최대·단위 재정의 (채널 계약 예외) */
|
|
35
|
+
limits?: Partial<Record<CurrencyCode, Partial<Pick<CurrencyPolicy, 'minAmount' | 'maxAmount' | 'paymentUnit'>>>>;
|
|
36
|
+
};
|
|
37
|
+
export declare function createPricingPolicy(input: PricingPolicyInput): PricingPolicy;
|
|
38
|
+
/** Provider가 없을 때 쓰는 기본 정책: KRW 단일 통화 */
|
|
39
|
+
export declare const DEFAULT_PRICING_POLICY: PricingPolicy;
|