@fibery/ui-kit 9.4.2 → 9.4.3

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/lib/skeleton.d.ts CHANGED
@@ -3,22 +3,13 @@ import "./design-system.js";
3
3
  import { ComponentType, ReactNode } from "react";
4
4
  //#region src/skeleton.d.ts
5
5
  type SkeletonBaseProps = {
6
- /** Bar height, one step of the scale — the type scale it stands in for picks the step. */
7
6
  height?: SkeletonHeight;
8
- /**
9
- * 1:1 plate sized to the element it replaces — an icon, a checkbox, an avatar — rather than to a
10
- * step of the bar scale. Overrides height and width. dt#1620 replaces it with the Square shape.
11
- */
12
7
  size?: number;
13
8
  inverted?: boolean;
14
9
  animateAppearance?: boolean;
15
10
  margins?: boolean;
16
11
  index?: number;
17
12
  };
18
- /**
19
- * A bar is either one known width, or a range to generate one within when the width is not
20
- * known. Both ends are required for a range, so a fixed width has exactly one spelling.
21
- */
22
13
  type SkeletonWidthProps = {
23
14
  width?: SkeletonWidth;
24
15
  minWidth?: never;
package/lib/skeleton.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import "./skeleton.wyw-in-js.css";
2
2
  import { skeletonWidths } from "./design-system/skeleton.js";
3
- import { getRandomInt } from "./random.js";
4
3
  /* empty css */
5
4
  import { Fragment, jsx } from "react/jsx-runtime";
6
5
  import { memo } from "react";
@@ -17,13 +16,16 @@ var Container = /*#__PURE__*/ styled("div")({
17
16
  propsAsIs: false,
18
17
  vars: { "cjtjcsl-0": [_exp4()] }
19
18
  });
20
- var widthInRange = (minWidth, maxWidth, seed) => {
21
- const steps = skeletonWidths.filter((step) => step >= minWidth && step <= maxWidth);
22
- return steps[getRandomInt(0, steps.length - 1, seed)];
19
+ var stepsInRange = (minWidth = 80, maxWidth = 120) => skeletonWidths.filter((step) => step >= minWidth && step <= maxWidth);
20
+ var widthAt = (steps, index) => steps[steps.length - 1 - index % steps.length];
21
+ var lineWidth = (steps, line, amount) => {
22
+ const [shortest, ...longer] = steps;
23
+ if (amount > 1 && line === amount - 1 || longer.length === 0) return shortest;
24
+ return widthAt(longer, line);
23
25
  };
24
26
  var Skeleton = memo(function Skeleton({ height = 12, width, minWidth, maxWidth, size, index = 0, margins = true, animateAppearance = false }) {
25
27
  const barHeight = size ?? height;
26
- const barWidth = size ?? width ?? widthInRange(minWidth ?? 80, maxWidth ?? 120, index);
28
+ const barWidth = size ?? width ?? widthAt(stepsInRange(minWidth, maxWidth), index);
27
29
  return /* @__PURE__ */ jsx(Container, {
28
30
  height: barHeight,
29
31
  style: {
@@ -33,21 +35,20 @@ var Skeleton = memo(function Skeleton({ height = 12, width, minWidth, maxWidth,
33
35
  className: cx(skeletonStyle, margins && marginStyle, animateAppearance && skeletonAppearanceStyle)
34
36
  });
35
37
  });
36
- var SkeletonList = memo(function SkeletonList({ amount = 1, WrapperComponent, ...restProps }) {
38
+ var SkeletonList = memo(function SkeletonList({ amount = 1, WrapperComponent, width, minWidth, maxWidth, ...restProps }) {
39
+ const steps = width ? [width] : stepsInRange(minWidth, maxWidth);
37
40
  return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: amount }, (_, index) => {
38
41
  const style = { opacity: (amount - index) / amount };
42
+ const skeleton = /* @__PURE__ */ jsx(Skeleton, {
43
+ ...restProps,
44
+ width: lineWidth(steps, index, amount)
45
+ });
39
46
  return /* @__PURE__ */ jsx("div", {
40
47
  style,
41
48
  children: WrapperComponent ? /* @__PURE__ */ jsx(WrapperComponent, {
42
49
  index,
43
- children: /* @__PURE__ */ jsx(Skeleton, {
44
- index: index + 1,
45
- ...restProps
46
- })
47
- }) : /* @__PURE__ */ jsx(Skeleton, {
48
- index: index + 1,
49
- ...restProps
50
- })
50
+ children: skeleton
51
+ }) : skeleton
51
52
  }, index);
52
53
  }) });
53
54
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/ui-kit",
3
- "version": "9.4.2",
3
+ "version": "9.4.3",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "lib"
@@ -140,9 +140,9 @@
140
140
  "tabbable": "5.2.1",
141
141
  "vaul": "1.1.2",
142
142
  "virtua": "0.50.4",
143
- "@fibery/helpers": "4.2.0",
144
- "@fibery/emoji-data": "3.0.0",
145
- "@fibery/react": "2.0.9"
143
+ "@fibery/helpers": "4.2.1",
144
+ "@fibery/react": "2.0.10",
145
+ "@fibery/emoji-data": "3.0.0"
146
146
  },
147
147
  "peerDependencies": {
148
148
  "react": "18.3.1",