@kosdev-code/kos-ddk-components 0.1.0-dev.75 → 0.1.0-dev.87
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/components/dashboard-card/dashboard-card.d.ts.map +1 -1
- package/index.cjs +31 -3
- package/index.cjs.map +1 -1
- package/index.js +31 -3
- package/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-card.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ddk-components/src/components/dashboard-card/dashboard-card.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"dashboard-card.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ddk-components/src/components/dashboard-card/dashboard-card.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAwC,MAAM,OAAO,CAAC;AAKhF,UAAU,SAAS;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAiBD,eAAO,MAAM,sBAAsB;;;qHAiClC,CAAC;AAEF,eAAO,MAAM,UAAU;;;qHAqBtB,CAAC;AAEF,eAAO,MAAM,SAAS;;;qHAYrB,CAAC;AA2CF,eAAO,MAAM,QAAQ;;;yGAOpB,CAAC;AAEF,eAAO,MAAM,UAAU;;;yGAMtB,CAAC;AAEF,eAAO,MAAM,UAAU;;;yGAQtB,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;UAKnB,CAAC;AAgBF,UAAU,KAAK;IACb,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACzB;AA0ED,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAEzC,CAAC;AAElC,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAEvC,CAAC"}
|
package/index.cjs
CHANGED
|
@@ -5155,9 +5155,36 @@ const CardTitle$1 = styled.div`
|
|
|
5155
5155
|
gap: 12px;
|
|
5156
5156
|
|
|
5157
5157
|
letter-spacing: 0.56px;
|
|
5158
|
-
|
|
5159
|
-
max-height: 36px;
|
|
5160
5158
|
`;
|
|
5159
|
+
const TITLE_TWO_LINES = 2.6;
|
|
5160
|
+
const TITLE_MIN_SCALE = 0.75;
|
|
5161
|
+
const useFitTitle = () => {
|
|
5162
|
+
const ref = React.useRef(null);
|
|
5163
|
+
const fitted = React.useRef("");
|
|
5164
|
+
const fit = React.useCallback(() => {
|
|
5165
|
+
const el = ref.current;
|
|
5166
|
+
if (!el) return;
|
|
5167
|
+
const key = `${el.clientWidth}|${el.textContent}`;
|
|
5168
|
+
if (key === fitted.current) return;
|
|
5169
|
+
fitted.current = key;
|
|
5170
|
+
el.style.fontSize = "";
|
|
5171
|
+
let size = parseFloat(getComputedStyle(el).fontSize);
|
|
5172
|
+
const min = size * TITLE_MIN_SCALE;
|
|
5173
|
+
while (el.scrollHeight > size * TITLE_TWO_LINES && size - 1 >= min) {
|
|
5174
|
+
size -= 1;
|
|
5175
|
+
el.style.fontSize = `${size}px`;
|
|
5176
|
+
}
|
|
5177
|
+
}, []);
|
|
5178
|
+
React.useLayoutEffect(fit);
|
|
5179
|
+
React.useLayoutEffect(() => {
|
|
5180
|
+
const el = ref.current;
|
|
5181
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
5182
|
+
const observer = new ResizeObserver(() => fit());
|
|
5183
|
+
observer.observe(el);
|
|
5184
|
+
return () => observer.disconnect();
|
|
5185
|
+
}, [fit]);
|
|
5186
|
+
return ref;
|
|
5187
|
+
};
|
|
5161
5188
|
const CardBody = styled.div`
|
|
5162
5189
|
align-items: center;
|
|
5163
5190
|
grid-area: body;
|
|
@@ -5224,6 +5251,7 @@ const DashboardCard = ({
|
|
|
5224
5251
|
};
|
|
5225
5252
|
const { componentModeOverride } = useComponentConfigurationContext();
|
|
5226
5253
|
const isCompact = componentModeOverride === "compact";
|
|
5254
|
+
const titleRef = useFitTitle();
|
|
5227
5255
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5228
5256
|
DashboardCardContainer,
|
|
5229
5257
|
{
|
|
@@ -5242,7 +5270,7 @@ const DashboardCard = ({
|
|
|
5242
5270
|
}
|
|
5243
5271
|
),
|
|
5244
5272
|
!!avatar && /* @__PURE__ */ jsxRuntime.jsx(CardAvatar, { backgroundColor, children: avatar }),
|
|
5245
|
-
title && /* @__PURE__ */ jsxRuntime.jsx(CardTitle$1, { backgroundColor, children: title }),
|
|
5273
|
+
title && /* @__PURE__ */ jsxRuntime.jsx(CardTitle$1, { ref: titleRef, backgroundColor, children: title }),
|
|
5246
5274
|
/* @__PURE__ */ jsxRuntime.jsx(CardBody, { children: body }),
|
|
5247
5275
|
componentModeOverride === "compact" && !!showNavIcon && /* @__PURE__ */ jsxRuntime.jsx(CardNav, {}),
|
|
5248
5276
|
!!footer && /* @__PURE__ */ jsxRuntime.jsx(CardFooter, { children: footer })
|