Skip to content

Commit 4742502

Browse files
authored
feat: utilities package (#557)
1 parent 796d1a4 commit 4742502

File tree

69 files changed

+2732
-655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2732
-655
lines changed

.changeset/easy-pots-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@reshaped/utilities": patch
3+
---
4+
5+
Flyout: Moved implementation to the new utilities package

.github/workflows/pull-request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ jobs:
206206
- name: Install dependencies
207207
run: pnpm install --frozen-lockfile
208208

209+
- name: Build all packages
210+
run: pnpm build
211+
209212
- name: Run tests
210213
run: pnpm test:browser --shard ${{ matrix.shard }}
211214

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export default defineConfig([
5151
],
5252
"react-hooks/rules-of-hooks": "error",
5353
"react-hooks/exhaustive-deps": "error",
54+
"react-hooks/refs": "off",
5455
},
5556
settings: {
5657
"import/resolver": {

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"url": "https://github.com/reshaped-ui/reshaped.git"
99
},
1010
"scripts": {
11-
"dev": "storybook dev -p 3001 --disable-telemetry",
11+
"dev": "pnpm -r --parallel run dev",
1212
"clean": "pnpm -r run clean",
1313
"commit": "git-cz",
1414
"changeset": "changeset",
@@ -23,7 +23,7 @@
2323
"chromatic": "chromatic -b build:chromatic --project-token=$(cat .chromatic) --only-changed --externals '.storybook/public/**'",
2424
"test:vrt": "pnpm chromatic",
2525
"test:browser": "pnpm --filter reshaped run test:browser",
26-
"test:unit": "pnpm --filter reshaped run test:unit",
26+
"test:unit": "pnpm -r run test:unit",
2727
"test:size": "size-limit",
2828
"lint": "pnpm lint:js && pnpm lint:css",
2929
"lint:js": "eslint './packages/**/*.{ts,tsx}' --fix",
@@ -85,7 +85,8 @@
8585
"vite": "7.3.0",
8686
"vite-tsconfig-paths": "5.1.4",
8787
"vitest": "4.0.16",
88-
"vitest-browser-react": "2.0.2"
88+
"vitest-browser-react": "2.0.2",
89+
"tsc-watch": "7.2.0"
8990
},
9091
"engines": {
9192
"node": ">=22"

packages/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
},
3232
"scripts": {
3333
"clean": "rm -rf dist",
34+
"dev": "tsc --watch -p tsconfig.json",
3435
"build": "pnpm clean && tsc -p tsconfig.json"
3536
},
3637
"peerDependencies": {

packages/reshaped/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
},
7878
"scripts": {
7979
"clean": "sh ./bin/clean.sh",
80+
"dev": "storybook dev -p 3001 -c ../../.storybook --disable-telemetry",
8081
"build": "pnpm clean && pnpm build:esm && pnpm build:css && pnpm build:bundle",
8182
"build:themes": "node bin/cli.js theming --config dist/cli/theming/reshaped.config.js --output src/themes",
8283
"build:esm": "tsc -p tsconfig.esm.json && resolve-tspaths -p tsconfig.esm.json",
@@ -98,6 +99,7 @@
9899
"react-dom": "^18 || ^19"
99100
},
100101
"dependencies": {
102+
"@reshaped/utilities": "workspace:*",
101103
"@csstools/postcss-global-data": "3.1.0",
102104
"chalk": "4.1.2",
103105
"commander": "14.0.2",

packages/reshaped/src/components/Accordion/AccordionControlled.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const AccordionControlled: React.FC<T.ControlledProps> = (props) => {
2020
triggerId: `${id}-trigger`,
2121
contentId: `${id}-content`,
2222
active,
23-
// eslint-disable-next-line react-hooks/refs
23+
2424
onToggle: onToggleRef.current,
2525
iconPosition,
2626
iconSize,

packages/reshaped/src/components/Calendar/Calendar.utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ export const applyNavigationBounds = (args: { date: Date; min?: Date; max?: Date
141141
};
142142
};
143143

144+
const isMonthMatch = (date1: Date, date2: Date) => {
145+
return date1.getMonth() === date2.getMonth() && date1.getFullYear() === date2.getFullYear();
146+
};
147+
144148
/**
145149
* Decide if date has to be focusable with Tab (only one date should be)
146150
* 1. If there is a selected value - it's focusable
@@ -154,17 +158,13 @@ export const isDateFocusable = (args: {
154158
}) => {
155159
const { date, startValue, lastFocusedDate } = args;
156160
const today = new Date();
157-
const renderedMonth = date.getMonth();
158-
const valueMonth = startValue?.getMonth();
159-
const todayMonth = today.getMonth();
160-
const lastFocusedMonth = lastFocusedDate?.getMonth();
161161
const isoDate = getLocalISODate({ date });
162162
const isoToday = getLocalISODate({ date: today });
163163
const isoValueDate = startValue && getLocalISODate({ date: startValue });
164164
const isoLastFocusedDate = lastFocusedDate && getLocalISODate({ date: lastFocusedDate });
165165

166-
if (lastFocusedDate && renderedMonth === lastFocusedMonth) return isoDate === isoLastFocusedDate;
167-
if (startValue && renderedMonth === valueMonth) return isoDate === isoValueDate;
168-
if (renderedMonth === todayMonth) return isoDate === isoToday;
166+
if (lastFocusedDate && isMonthMatch(date, lastFocusedDate)) return isoDate === isoLastFocusedDate;
167+
if (startValue && isMonthMatch(date, startValue)) return isoDate === isoValueDate;
168+
if (isMonthMatch(date, today)) return isoDate === isoToday;
169169
return true;
170170
};

packages/reshaped/src/components/Carousel/Carousel.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ const Carousel: React.FC<T.Props> = (props) => {
5858
// };
5959
};
6060

61-
// eslint-disable-next-line react-hooks/refs
6261
const handleScroll = rafThrottle((event: React.UIEvent<HTMLUListElement>) => {
6362
const el = event.target as Element;
6463
const firstVisibleIndex = getFirstVisibleIndex();

packages/reshaped/src/components/Flyout/Flyout.module.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.content {
2-
--rs-flyout-gap: 0;
32
--rs-flyout-max-h: 100%;
43
--rs-flyout-max-w: 100%;
54
--rs-flyout-origin-x: 50%;
@@ -57,16 +56,12 @@
5756
.content.--position-top-end,
5857
.content.--position-top-start {
5958
--rs-flyout-origin-y: 100%;
60-
61-
padding-bottom: calc(var(--rs-unit-x1) * var(--rs-flyout-gap));
6259
}
6360

6461
.content.--position-bottom,
6562
.content.--position-bottom-end,
6663
.content.--position-bottom-start {
6764
--rs-flyout-origin-y: 0%;
68-
69-
padding-top: calc(var(--rs-unit-x1) * var(--rs-flyout-gap));
7065
}
7166

7267
.content.--position-top-start,
@@ -83,16 +78,12 @@
8378
.content.--position-start-top,
8479
.content.--position-start-bottom {
8580
--rs-flyout-origin-x: 100%;
86-
87-
padding-right: calc(var(--rs-unit-x1) * var(--rs-flyout-gap));
8881
}
8982

9083
.content.--position-end,
9184
.content.--position-end-top,
9285
.content.--position-end-bottom {
9386
--rs-flyout-origin-x: 0%;
94-
95-
padding-left: calc(var(--rs-unit-x1) * var(--rs-flyout-gap));
9687
}
9788

9889
.content.--position-start-top,

0 commit comments

Comments
 (0)