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

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,8 +5137,39 @@ const CardTitle$1 = styled.div`
5039
5137
  gap: 12px;
5040
5138
 
5041
5139
  letter-spacing: 0.56px;
5042
-
5043
- max-height: 36px;
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
+ };
5170
+ const SPAN_WITHOUT_SIZING = `
5171
+ width: 0;
5172
+ min-width: 100%;
5044
5173
  `;
5045
5174
  const CardBody = styled.div`
5046
5175
  align-items: center;
@@ -5049,13 +5178,16 @@ const CardBody = styled.div`
5049
5178
  gap: 8px;
5050
5179
  min-height: 0;
5051
5180
  flex: 1;
5181
+ ${SPAN_WITHOUT_SIZING}
5052
5182
  `;
5053
5183
  const CardFooter = styled.div`
5054
- align-items: center;
5055
5184
  grid-area: footer;
5056
- display: flex;
5185
+ display: -webkit-box;
5186
+ -webkit-box-orient: vertical;
5187
+ -webkit-line-clamp: 2;
5188
+ overflow: hidden;
5057
5189
  font-size: 14px;
5058
- flex-wrap: wrap;
5190
+ ${SPAN_WITHOUT_SIZING}
5059
5191
  `;
5060
5192
  const CardErrors = styled.div`
5061
5193
  display: flex;
@@ -5108,6 +5240,7 @@ const DashboardCard = ({
5108
5240
  };
5109
5241
  const { componentModeOverride } = useComponentConfigurationContext();
5110
5242
  const isCompact = componentModeOverride === "compact";
5243
+ const titleRef = useFitTitle();
5111
5244
  return /* @__PURE__ */ jsxs(
5112
5245
  DashboardCardContainer,
5113
5246
  {
@@ -5126,7 +5259,7 @@ const DashboardCard = ({
5126
5259
  }
5127
5260
  ),
5128
5261
  !!avatar && /* @__PURE__ */ jsx(CardAvatar, { backgroundColor, children: avatar }),
5129
- title && /* @__PURE__ */ jsx(CardTitle$1, { backgroundColor, children: title }),
5262
+ title && /* @__PURE__ */ jsx(CardTitle$1, { ref: titleRef, backgroundColor, children: title }),
5130
5263
  /* @__PURE__ */ jsx(CardBody, { children: body }),
5131
5264
  componentModeOverride === "compact" && !!showNavIcon && /* @__PURE__ */ jsx(CardNav, {}),
5132
5265
  !!footer && /* @__PURE__ */ jsx(CardFooter, { children: footer })
@@ -5886,6 +6019,33 @@ const InfoCardContainer = (props) => {
5886
6019
  const { t } = useKosTranslation("common");
5887
6020
  return /* @__PURE__ */ jsx(InfoCard, { unavailableText: t("unavailable"), ...props });
5888
6021
  };
6022
+ const InfoMessageCard = styled(Card)`
6023
+ background-color: var(--ddk-semantic-color-system-orange-light);
6024
+ border-color: var(--ddk-semantic-color-system-orange);
6025
+ gap: var(--ddk-generic-padding-medium);
6026
+ padding: var(--ddk-generic-padding-large) var(--ddk-generic-padding-x-large);
6027
+ display: flex;
6028
+ align-items: flex-start;
6029
+ min-height: initial;
6030
+ `;
6031
+ const InfoMessageIcon = styled(ErrorIconWithBackground)`
6032
+ background-color: var(--ddk-semantic-color-system-orange);
6033
+ box-sizing: border-box;
6034
+ width: var(--ddk-component-info-message-icon-width);
6035
+ height: var(--ddk-component-info-message-icon-height);
6036
+ padding: var(--ddk-component-info-message-icon-padding);
6037
+ `;
6038
+ const Message = styled(BodyLarge)`
6039
+ color: var(--ddk-semantic-color-system-orange);
6040
+ flex: 1;
6041
+ `;
6042
+ const InfoMessage = ({ children, ...props }) => {
6043
+ const { componentModeOverride } = useComponentConfigurationContext();
6044
+ return /* @__PURE__ */ jsxs(InfoMessageCard, { ...props, children: [
6045
+ /* @__PURE__ */ jsx(InfoMessageIcon, {}),
6046
+ /* @__PURE__ */ jsx(Message, { children })
6047
+ ] });
6048
+ };
5889
6049
  var build$1 = { exports: {} };
5890
6050
  var build = build$1.exports;
5891
6051
  var hasRequiredBuild;
@@ -10729,7 +10889,7 @@ const Tabs = ({
10729
10889
  const TabContainerComponent = showBackground ? TabContainerWithBackground : TabContainer;
10730
10890
  const TabListComponent = contain ? TabListWithPadding : TabList;
10731
10891
  return /* @__PURE__ */ jsxs(Fragment, { children: [
10732
- /* @__PURE__ */ jsx(TabContainerComponent, { children: /* @__PURE__ */ jsx(Container$9, { children: /* @__PURE__ */ jsx(TabListComponent, { children: tabs.map((tab) => {
10892
+ /* @__PURE__ */ jsx(TabContainerComponent, { children: /* @__PURE__ */ jsx(Container$8, { children: /* @__PURE__ */ jsx(TabListComponent, { children: tabs.map((tab) => {
10733
10893
  const TabComponent = activeTabValue === tab.id ? ActiveTab : Tab;
10734
10894
  return /* @__PURE__ */ jsx(
10735
10895
  TabComponent,
@@ -10740,7 +10900,7 @@ const Tabs = ({
10740
10900
  tab.id
10741
10901
  );
10742
10902
  }) }) }) }),
10743
- /* @__PURE__ */ jsx(TabContent, { children: /* @__PURE__ */ jsx(Container$9, { children: activeTabValue && tabMap[activeTabValue] && /* @__PURE__ */ jsx("section", { children: tabMap[activeTabValue].content }) }) })
10903
+ /* @__PURE__ */ jsx(TabContent, { children: /* @__PURE__ */ jsx(Container$8, { children: activeTabValue && tabMap[activeTabValue] && /* @__PURE__ */ jsx("section", { children: tabMap[activeTabValue].content }) }) })
10744
10904
  ] });
10745
10905
  };
10746
10906
  const useNavigate = () => {
@@ -11050,7 +11210,7 @@ const ContainerStyles = styled.div`
11050
11210
  const TopNavigation = ({
11051
11211
  iconNavigationItems,
11052
11212
  navigationItems
11053
- }) => /* @__PURE__ */ jsx(TopNavigationStyles, { children: /* @__PURE__ */ jsx(Container$9, { children: /* @__PURE__ */ jsxs(ContainerStyles, { children: [
11213
+ }) => /* @__PURE__ */ jsx(TopNavigationStyles, { children: /* @__PURE__ */ jsx(Container$8, { children: /* @__PURE__ */ jsxs(ContainerStyles, { children: [
11054
11214
  /* @__PURE__ */ jsx(TopNavigationButtonList, { items: navigationItems }),
11055
11215
  /* @__PURE__ */ jsx(TopNavigationIconButtonList, { items: iconNavigationItems })
11056
11216
  ] }) }) });
@@ -11060,26 +11220,7 @@ const viewStyles = css`
11060
11220
  gap: var(--ddk-component-view-gap);
11061
11221
  padding: var(--ddk-component-view-padding);
11062
11222
  `;
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
- );
11223
+ 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
11224
  export {
11084
11225
  ActionCard,
11085
11226
  ActionItem,
@@ -11113,7 +11254,7 @@ export {
11113
11254
  ComponentConfigurationProvider,
11114
11255
  ConfirmationModalContainer as ConfirmationModal,
11115
11256
  ConfirmationModalContainer,
11116
- Container$9 as Container,
11257
+ Container$8 as Container,
11117
11258
  Content$1 as Content,
11118
11259
  DashboardCardContainer,
11119
11260
  Description$1 as Description,
@@ -11133,6 +11274,7 @@ export {
11133
11274
  Grid,
11134
11275
  Header,
11135
11276
  Heading,
11277
+ HeadingExtraLarge,
11136
11278
  HeadingLarge,
11137
11279
  HeadingLargeInformation,
11138
11280
  HeadingMedium,
@@ -11143,6 +11285,7 @@ export {
11143
11285
  InfoCardContainer,
11144
11286
  InfoCardHead,
11145
11287
  InfoContainer,
11288
+ InfoMessage,
11146
11289
  InfoTable,
11147
11290
  InformationIconStyle,
11148
11291
  Input,
@@ -11165,6 +11308,7 @@ export {
11165
11308
  ListContainer,
11166
11309
  MenuButton,
11167
11310
  Modal,
11311
+ ModalContainer,
11168
11312
  MultiDial,
11169
11313
  MultiPicker,
11170
11314
  MultiPickerCard,
@@ -11251,6 +11395,7 @@ export {
11251
11395
  useExperience,
11252
11396
  useKeyboardToggle,
11253
11397
  useNavigate,
11398
+ useUtilityModal,
11254
11399
  useViewExperience,
11255
11400
  useViewExperienceListMap
11256
11401
  };