@kosdev-code/kos-ddk-components 0.1.0-dev.9 → 0.1.0-dev.90

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/index.js CHANGED
@@ -79,7 +79,7 @@ const ActionItem = styled("div", {
79
79
  user-select: none;
80
80
  white-space: nowrap;
81
81
  `;
82
- const Container$a = styled.div`
82
+ const Container$9 = styled.div`
83
83
  align-items: center;
84
84
  display: flex;
85
85
  gap: var(--ddk-component-action-item-button-container-gap);
@@ -171,7 +171,7 @@ const ActionItemButton = ({
171
171
  unitStyle = "external",
172
172
  unitValue,
173
173
  ...props
174
- }) => /* @__PURE__ */ jsxs(Container$a, { children: [
174
+ }) => /* @__PURE__ */ jsxs(Container$9, { children: [
175
175
  unitStyle === "inline" ? /* @__PURE__ */ jsxs(
176
176
  ActionItemButtonStyles,
177
177
  {
@@ -331,13 +331,13 @@ const CardButton = styled(Card, {
331
331
  height: var(--ddk-component-card-button-svg-size);
332
332
  }
333
333
  `;
334
- const Container$9 = styled.div`
334
+ const Container$8 = styled.div`
335
335
  display: flex;
336
336
  flex-direction: column;
337
337
  height: 100%;
338
338
  margin: 0 auto;
339
339
  gap: 16px;
340
- max-width: ${(props) => props.contain === false ? "" : props.size === "small" ? "var(--ddk-component-container-max-width-small)" : props.size === "medium" ? "var(--ddk-component-container-max-width-medium)" : "var(--ddk-component-container-max-width-large)"};
340
+ max-width: ${(props) => props.contain === false ? "" : props.size === "small" ? "var(--ddk-component-container-max-width-small)" : props.size === "medium" ? "var(--ddk-component-container-max-width-medium)" : "var(--ddk-component-page-max-width, var(--ddk-component-container-max-width-large))"};
341
341
 
342
342
  overflow-y: auto;
343
343
  width: 100%;
@@ -573,6 +573,17 @@ const HeadingLarge = styled.div`
573
573
  letter-spacing: var(--ddk-component-typography-heading-large-letter-spacing);
574
574
  line-height: var(--ddk-component-typography-heading-large-line-height);
575
575
  `;
576
+ const HeadingExtraLarge = styled.div`
577
+ color: var(--ddk-component-typography-heading-x-large-color);
578
+ font-family: var(--ddk-component-typography-heading-x-large-font-family);
579
+ font-size: var(--ddk-component-typography-heading-x-large-font-size);
580
+ font-style: var(--ddk-component-typography-heading-x-large-font-style);
581
+ font-weight: var(--ddk-component-typography-heading-x-large-font-weight);
582
+ letter-spacing: var(
583
+ --ddk-component-typography-heading-x-large-letter-spacing
584
+ );
585
+ line-height: var(--ddk-component-typography-heading-x-large-line-height);
586
+ `;
576
587
  const HeadingMediumInformation = styled(HeadingMedium)`
577
588
  color: var(--ddk-component-typography-label-information-color);
578
589
  `;
@@ -609,7 +620,7 @@ const LabelInformationSmall = styled(LabelSmall)`
609
620
  const LabelInformationExtraSmall = styled(LabelExtraSmall)`
610
621
  color: var(--ddk-component-typography-label-information-color);
611
622
  `;
612
- const Container$8 = styled.div`
623
+ const Container$7 = styled.div`
613
624
  align-items: var(--ddk-component-input-container-align-items);
614
625
  display: flex;
615
626
  flex-direction: var(--ddk-component-input-container-flex-direction);
@@ -668,7 +679,7 @@ const StyledInput = styled.input`
668
679
  }
669
680
  `;
670
681
  const Input = forwardRef(
671
- ({ error, isError, ...props }, ref) => /* @__PURE__ */ jsxs(Container$8, { children: [
682
+ ({ error, isError, ...props }, ref) => /* @__PURE__ */ jsxs(Container$7, { children: [
672
683
  error && /* @__PURE__ */ jsx(ErrorText, { children: error }),
673
684
  /* @__PURE__ */ jsx(StyledInput, { ref, isError: isError || !!error, ...props })
674
685
  ] })
@@ -983,7 +994,7 @@ const ContentStyle = styled.div`
983
994
  `;
984
995
  const Content$1 = ({ align, children, className, size }) => {
985
996
  const { componentModeOverride } = useComponentConfigurationContext();
986
- return /* @__PURE__ */ jsx(Container$9, { size, children: /* @__PURE__ */ jsx(
997
+ return /* @__PURE__ */ jsx(Container$8, { size, children: /* @__PURE__ */ jsx(
987
998
  ContentStyle,
988
999
  {
989
1000
  align,
@@ -1054,7 +1065,7 @@ const HeaderContainer = styled.div`
1054
1065
  display: flex;
1055
1066
  flex-direction: var(--ddk-component-modal-header-flex-direction);
1056
1067
  gap: var(--ddk-component-modal-header-gap);
1057
- height: var(--ddk-component-modal-header-height);
1068
+ min-height: var(--ddk-component-modal-header-height);
1058
1069
  justify-content: space-between;
1059
1070
  padding: ${(props) => props.contain ? "var(--ddk-component-modal-header-padding-maximized)" : "var(--ddk-component-modal-header-padding)"};
1060
1071
  user-select: none;
@@ -4767,7 +4778,7 @@ const modalStyles = (mode, enableAnimation) => css`
4767
4778
  }
4768
4779
  }
4769
4780
  `;
4770
- const ModalContainer = styled(Container$9)`
4781
+ const ModalContainer$1 = styled(Container$8)`
4771
4782
  align-items: center;
4772
4783
  display: flex;
4773
4784
  flex-direction: column;
@@ -4808,7 +4819,7 @@ const Modal = ({
4808
4819
  style,
4809
4820
  onPointerDown: () => mode !== "maximized" && closeOnShroudClick && onClose?.(),
4810
4821
  children: /* @__PURE__ */ jsx(
4811
- ModalContainer,
4822
+ ModalContainer$1,
4812
4823
  {
4813
4824
  ...props,
4814
4825
  contain: mode !== "fullscreen",
@@ -4830,14 +4841,101 @@ const Modal = ({
4830
4841
  document.body
4831
4842
  );
4832
4843
  };
4833
- const Container$7 = styled.div`
4844
+ const ModalContainer = styled.div`
4834
4845
  display: flex;
4835
4846
  flex-direction: column;
4836
4847
  overflow-y: auto;
4837
4848
  overflow-x: hidden;
4838
- gap: 40px;
4849
+ gap: var(--ddk-component-base-modal-container-gap);
4839
4850
  height: 100%;
4840
4851
  `;
4852
+ const BackText = () => {
4853
+ const { t } = useKosTranslation("common");
4854
+ return t("close");
4855
+ };
4856
+ const VolumeBackButton = ({
4857
+ children,
4858
+ fill,
4859
+ label,
4860
+ size = "medium",
4861
+ ...props
4862
+ }) => /* @__PURE__ */ jsx(
4863
+ IconButton,
4864
+ {
4865
+ icon: fill ? ChevronLeftIcon : ChevronLeftIcon,
4866
+ size,
4867
+ ...props,
4868
+ children: label ?? /* @__PURE__ */ jsx(BackText, {})
4869
+ }
4870
+ );
4871
+ const backButton = (label) => function UtilityBackButton({ onPointerDown }) {
4872
+ return /* @__PURE__ */ jsx(
4873
+ VolumeBackButton,
4874
+ {
4875
+ onPointerDown,
4876
+ label,
4877
+ size: "small"
4878
+ }
4879
+ );
4880
+ };
4881
+ const useUtilityModal = ({
4882
+ onComplete,
4883
+ onClose,
4884
+ layout = "maximized",
4885
+ onBack,
4886
+ showBack = !!onBack,
4887
+ backButtonLabel = "Back",
4888
+ closeButtonLabel = "Close"
4889
+ } = {}) => {
4890
+ const { componentModeOverride } = useComponentConfigurationContext();
4891
+ const isCompact = componentModeOverride === "compact";
4892
+ const [closing, setClosing] = useState(false);
4893
+ const close = useCallback(() => {
4894
+ onClose?.();
4895
+ setClosing(true);
4896
+ }, [onClose]);
4897
+ const BackButton2 = useMemo(() => backButton(backButtonLabel), [
4898
+ backButtonLabel
4899
+ ]);
4900
+ const fullscreen = layout === "fullscreen";
4901
+ const modalProps = {
4902
+ show: !closing,
4903
+ mode: layout,
4904
+ contain: fullscreen ? false : !isCompact,
4905
+ // A utility closes from its own controls, never from a tap outside it.
4906
+ closeOnShroudClick: false,
4907
+ onClose: close,
4908
+ onClosed: onComplete
4909
+ };
4910
+ const headerProps = fullscreen ? {
4911
+ contain: true,
4912
+ raiseCloseButton: true,
4913
+ showCloseButton: true,
4914
+ closeButtonLabel,
4915
+ onClose: close
4916
+ } : {
4917
+ contain: isCompact,
4918
+ CloseButton: isCompact ? CompactCloseButton : void 0,
4919
+ showCloseButton: true,
4920
+ closeButtonLabel,
4921
+ onClose: close,
4922
+ OpenButton: BackButton2,
4923
+ showOpenButton: !isCompact && showBack,
4924
+ onOpen: onBack
4925
+ };
4926
+ return {
4927
+ isCompact,
4928
+ close,
4929
+ modalProps,
4930
+ headerProps,
4931
+ showFooterBack: isCompact && showBack
4932
+ };
4933
+ };
4934
+ const WorkflowModalBase = styled(Modal)`
4935
+ --ddk-component-modal-min-height: var(
4936
+ --ddk-component-workflow-modal-min-height
4937
+ );
4938
+ `;
4841
4939
  const WorkflowContent = styled(Content$1)`
4842
4940
  align-items: center;
4843
4941
  gap: 24px;
@@ -4892,13 +4990,13 @@ const WorkflowModal = ({
4892
4990
  }) => {
4893
4991
  const { componentModeOverride } = useComponentConfigurationContext();
4894
4992
  return /* @__PURE__ */ jsx(
4895
- Modal,
4993
+ WorkflowModalBase,
4896
4994
  {
4897
4995
  ...props,
4898
4996
  contain: componentModeOverride !== "compact",
4899
4997
  show,
4900
4998
  onClose,
4901
- children: /* @__PURE__ */ jsxs(Container$7, { children: [
4999
+ children: /* @__PURE__ */ jsxs(ModalContainer, { children: [
4902
5000
  (showCloseButton && !!onClose || title) && /* @__PURE__ */ jsx(
4903
5001
  Header,
4904
5002
  {
@@ -4910,10 +5008,10 @@ const WorkflowModal = ({
4910
5008
  title
4911
5009
  }
4912
5010
  ),
4913
- /* @__PURE__ */ jsx(Content$1, { children: /* @__PURE__ */ jsxs(WorkflowContent, { children: [
5011
+ /* @__PURE__ */ jsxs(WorkflowContent, { contain: componentModeOverride === "compact", children: [
4914
5012
  getIcon(status, iconStyle),
4915
5013
  information
4916
- ] }) }),
5014
+ ] }),
4917
5015
  /* @__PURE__ */ jsx(Footer, { children: footer })
4918
5016
  ] })
4919
5017
  }
@@ -5039,9 +5137,36 @@ const CardTitle$1 = styled.div`
5039
5137
  gap: 12px;
5040
5138
 
5041
5139
  letter-spacing: 0.56px;
5042
-
5043
- max-height: 36px;
5044
5140
  `;
5141
+ const TITLE_TWO_LINES = 2.6;
5142
+ const TITLE_MIN_SCALE = 0.75;
5143
+ const useFitTitle = () => {
5144
+ const ref = useRef(null);
5145
+ const fitted = useRef("");
5146
+ const fit = useCallback(() => {
5147
+ const el = ref.current;
5148
+ if (!el) return;
5149
+ const key = `${el.clientWidth}|${el.textContent}`;
5150
+ if (key === fitted.current) return;
5151
+ fitted.current = key;
5152
+ el.style.fontSize = "";
5153
+ let size = parseFloat(getComputedStyle(el).fontSize);
5154
+ const min = size * TITLE_MIN_SCALE;
5155
+ while (el.scrollHeight > size * TITLE_TWO_LINES && size - 1 >= min) {
5156
+ size -= 1;
5157
+ el.style.fontSize = `${size}px`;
5158
+ }
5159
+ }, []);
5160
+ useLayoutEffect(fit);
5161
+ useLayoutEffect(() => {
5162
+ const el = ref.current;
5163
+ if (!el || typeof ResizeObserver === "undefined") return;
5164
+ const observer = new ResizeObserver(() => fit());
5165
+ observer.observe(el);
5166
+ return () => observer.disconnect();
5167
+ }, [fit]);
5168
+ return ref;
5169
+ };
5045
5170
  const CardBody = styled.div`
5046
5171
  align-items: center;
5047
5172
  grid-area: body;
@@ -5108,6 +5233,7 @@ const DashboardCard = ({
5108
5233
  };
5109
5234
  const { componentModeOverride } = useComponentConfigurationContext();
5110
5235
  const isCompact = componentModeOverride === "compact";
5236
+ const titleRef = useFitTitle();
5111
5237
  return /* @__PURE__ */ jsxs(
5112
5238
  DashboardCardContainer,
5113
5239
  {
@@ -5126,7 +5252,7 @@ const DashboardCard = ({
5126
5252
  }
5127
5253
  ),
5128
5254
  !!avatar && /* @__PURE__ */ jsx(CardAvatar, { backgroundColor, children: avatar }),
5129
- title && /* @__PURE__ */ jsx(CardTitle$1, { backgroundColor, children: title }),
5255
+ title && /* @__PURE__ */ jsx(CardTitle$1, { ref: titleRef, backgroundColor, children: title }),
5130
5256
  /* @__PURE__ */ jsx(CardBody, { children: body }),
5131
5257
  componentModeOverride === "compact" && !!showNavIcon && /* @__PURE__ */ jsx(CardNav, {}),
5132
5258
  !!footer && /* @__PURE__ */ jsx(CardFooter, { children: footer })
@@ -5886,6 +6012,33 @@ const InfoCardContainer = (props) => {
5886
6012
  const { t } = useKosTranslation("common");
5887
6013
  return /* @__PURE__ */ jsx(InfoCard, { unavailableText: t("unavailable"), ...props });
5888
6014
  };
6015
+ const InfoMessageCard = styled(Card)`
6016
+ background-color: var(--ddk-semantic-color-system-orange-light);
6017
+ border-color: var(--ddk-semantic-color-system-orange);
6018
+ gap: var(--ddk-generic-padding-medium);
6019
+ padding: var(--ddk-generic-padding-large) var(--ddk-generic-padding-x-large);
6020
+ display: flex;
6021
+ align-items: flex-start;
6022
+ min-height: initial;
6023
+ `;
6024
+ const InfoMessageIcon = styled(ErrorIconWithBackground)`
6025
+ background-color: var(--ddk-semantic-color-system-orange);
6026
+ box-sizing: border-box;
6027
+ width: var(--ddk-component-info-message-icon-width);
6028
+ height: var(--ddk-component-info-message-icon-height);
6029
+ padding: var(--ddk-component-info-message-icon-padding);
6030
+ `;
6031
+ const Message = styled(BodyLarge)`
6032
+ color: var(--ddk-semantic-color-system-orange);
6033
+ flex: 1;
6034
+ `;
6035
+ const InfoMessage = ({ children, ...props }) => {
6036
+ const { componentModeOverride } = useComponentConfigurationContext();
6037
+ return /* @__PURE__ */ jsxs(InfoMessageCard, { ...props, children: [
6038
+ /* @__PURE__ */ jsx(InfoMessageIcon, {}),
6039
+ /* @__PURE__ */ jsx(Message, { children })
6040
+ ] });
6041
+ };
5889
6042
  var build$1 = { exports: {} };
5890
6043
  var build = build$1.exports;
5891
6044
  var hasRequiredBuild;
@@ -10729,7 +10882,7 @@ const Tabs = ({
10729
10882
  const TabContainerComponent = showBackground ? TabContainerWithBackground : TabContainer;
10730
10883
  const TabListComponent = contain ? TabListWithPadding : TabList;
10731
10884
  return /* @__PURE__ */ jsxs(Fragment, { children: [
10732
- /* @__PURE__ */ jsx(TabContainerComponent, { children: /* @__PURE__ */ jsx(Container$9, { children: /* @__PURE__ */ jsx(TabListComponent, { children: tabs.map((tab) => {
10885
+ /* @__PURE__ */ jsx(TabContainerComponent, { children: /* @__PURE__ */ jsx(Container$8, { children: /* @__PURE__ */ jsx(TabListComponent, { children: tabs.map((tab) => {
10733
10886
  const TabComponent = activeTabValue === tab.id ? ActiveTab : Tab;
10734
10887
  return /* @__PURE__ */ jsx(
10735
10888
  TabComponent,
@@ -10740,7 +10893,7 @@ const Tabs = ({
10740
10893
  tab.id
10741
10894
  );
10742
10895
  }) }) }) }),
10743
- /* @__PURE__ */ jsx(TabContent, { children: /* @__PURE__ */ jsx(Container$9, { children: activeTabValue && tabMap[activeTabValue] && /* @__PURE__ */ jsx("section", { children: tabMap[activeTabValue].content }) }) })
10896
+ /* @__PURE__ */ jsx(TabContent, { children: /* @__PURE__ */ jsx(Container$8, { children: activeTabValue && tabMap[activeTabValue] && /* @__PURE__ */ jsx("section", { children: tabMap[activeTabValue].content }) }) })
10744
10897
  ] });
10745
10898
  };
10746
10899
  const useNavigate = () => {
@@ -11050,7 +11203,7 @@ const ContainerStyles = styled.div`
11050
11203
  const TopNavigation = ({
11051
11204
  iconNavigationItems,
11052
11205
  navigationItems
11053
- }) => /* @__PURE__ */ jsx(TopNavigationStyles, { children: /* @__PURE__ */ jsx(Container$9, { children: /* @__PURE__ */ jsxs(ContainerStyles, { children: [
11206
+ }) => /* @__PURE__ */ jsx(TopNavigationStyles, { children: /* @__PURE__ */ jsx(Container$8, { children: /* @__PURE__ */ jsxs(ContainerStyles, { children: [
11054
11207
  /* @__PURE__ */ jsx(TopNavigationButtonList, { items: navigationItems }),
11055
11208
  /* @__PURE__ */ jsx(TopNavigationIconButtonList, { items: iconNavigationItems })
11056
11209
  ] }) }) });
@@ -11060,26 +11213,7 @@ const viewStyles = css`
11060
11213
  gap: var(--ddk-component-view-gap);
11061
11214
  padding: var(--ddk-component-view-padding);
11062
11215
  `;
11063
- const View = ({ children, contain = true, style }) => contain ? /* @__PURE__ */ jsx(Container$9, { children: /* @__PURE__ */ jsx("div", { css: [viewStyles, style], children }) }) : /* @__PURE__ */ jsx("div", { css: [viewStyles, style], children });
11064
- const BackText = () => {
11065
- const { t } = useKosTranslation("common");
11066
- return t("close");
11067
- };
11068
- const VolumeBackButton = ({
11069
- children,
11070
- fill,
11071
- label,
11072
- size = "medium",
11073
- ...props
11074
- }) => /* @__PURE__ */ jsx(
11075
- IconButton,
11076
- {
11077
- icon: fill ? ChevronLeftIcon : ChevronLeftIcon,
11078
- size,
11079
- ...props,
11080
- children: label ?? /* @__PURE__ */ jsx(BackText, {})
11081
- }
11082
- );
11216
+ const View = ({ children, contain = true, style }) => contain ? /* @__PURE__ */ jsx(Container$8, { children: /* @__PURE__ */ jsx("div", { css: [viewStyles, style], children }) }) : /* @__PURE__ */ jsx("div", { css: [viewStyles, style], children });
11083
11217
  export {
11084
11218
  ActionCard,
11085
11219
  ActionItem,
@@ -11113,7 +11247,7 @@ export {
11113
11247
  ComponentConfigurationProvider,
11114
11248
  ConfirmationModalContainer as ConfirmationModal,
11115
11249
  ConfirmationModalContainer,
11116
- Container$9 as Container,
11250
+ Container$8 as Container,
11117
11251
  Content$1 as Content,
11118
11252
  DashboardCardContainer,
11119
11253
  Description$1 as Description,
@@ -11133,6 +11267,7 @@ export {
11133
11267
  Grid,
11134
11268
  Header,
11135
11269
  Heading,
11270
+ HeadingExtraLarge,
11136
11271
  HeadingLarge,
11137
11272
  HeadingLargeInformation,
11138
11273
  HeadingMedium,
@@ -11143,6 +11278,7 @@ export {
11143
11278
  InfoCardContainer,
11144
11279
  InfoCardHead,
11145
11280
  InfoContainer,
11281
+ InfoMessage,
11146
11282
  InfoTable,
11147
11283
  InformationIconStyle,
11148
11284
  Input,
@@ -11165,6 +11301,7 @@ export {
11165
11301
  ListContainer,
11166
11302
  MenuButton,
11167
11303
  Modal,
11304
+ ModalContainer,
11168
11305
  MultiDial,
11169
11306
  MultiPicker,
11170
11307
  MultiPickerCard,
@@ -11251,6 +11388,7 @@ export {
11251
11388
  useExperience,
11252
11389
  useKeyboardToggle,
11253
11390
  useNavigate,
11391
+ useUtilityModal,
11254
11392
  useViewExperience,
11255
11393
  useViewExperienceListMap
11256
11394
  };