rangeflow 1.0.11 → 1.0.13
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/README.md +8 -8
- package/dist/hooks/use-rangeflow.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -110,7 +110,7 @@ Main component. Renders the full picker.
|
|
|
110
110
|
| `calendar` | `boolean` | No | `true` | Show the popover calendar on the left of the header. |
|
|
111
111
|
| `CalendarProps` | `DayPickerProps` from `react-day-picker` | No | `undefined` | Pass through props to the inner calendar (months, locale, modifiers, etc.). |
|
|
112
112
|
| `Slots` | `Slots` | No | `{}` | Replace any visible part with your own component. |
|
|
113
|
-
| `api` | `RangeFlowApi` | No | `undefined` | Hook returned object for external control. See `
|
|
113
|
+
| `api` | `RangeFlowApi` | No | `undefined` | Hook returned object for external control. See `useRangeFlow`. |
|
|
114
114
|
|
|
115
115
|
#### Types
|
|
116
116
|
|
|
@@ -126,12 +126,12 @@ type DateDisabled =
|
|
|
126
126
|
| { before?: Date; after: Date }
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
-
### `
|
|
129
|
+
### `useRangeFlow()`
|
|
130
130
|
|
|
131
131
|
Returns an imperative API object. Pass it into `<RangeFlow api={...} />` to control the picker from outside.
|
|
132
132
|
|
|
133
133
|
```ts
|
|
134
|
-
const rangeflow =
|
|
134
|
+
const rangeflow = useRangeFlow()
|
|
135
135
|
|
|
136
136
|
rangeflow.updateRange({ from, to }) // change the window
|
|
137
137
|
rangeflow.updateSelectedDates({ from, to }) // change the picked range
|
|
@@ -339,16 +339,16 @@ Keep the slider and tabs, drop the popover calendar.
|
|
|
339
339
|
/>
|
|
340
340
|
```
|
|
341
341
|
|
|
342
|
-
### 8. External controls with `
|
|
342
|
+
### 8. External controls with `useRangeFlow`
|
|
343
343
|
|
|
344
344
|
Drive the picker from buttons, forms, or URL params.
|
|
345
345
|
|
|
346
346
|
```tsx
|
|
347
|
-
import { RangeFlow,
|
|
347
|
+
import { RangeFlow, useRangeFlow } from 'rangeflow'
|
|
348
348
|
import dayjs from 'dayjs'
|
|
349
349
|
|
|
350
350
|
export function WithControls() {
|
|
351
|
-
const rangeflow =
|
|
351
|
+
const rangeflow = useRangeFlow()
|
|
352
352
|
|
|
353
353
|
return (
|
|
354
354
|
<div>
|
|
@@ -503,12 +503,12 @@ Use these class names to style parts of the picker without touching the tokens.
|
|
|
503
503
|
|
|
504
504
|
If you are an AI tool generating code with RangeFlow, keep these facts in mind:
|
|
505
505
|
|
|
506
|
-
- The package is `rangeflow`. Only two named exports are public: `RangeFlow` (component) and `
|
|
506
|
+
- The package is `rangeflow`. Only two named exports are public: `RangeFlow` (component) and `useRangeFlow` (hook). Also a type export `RangeFlowApi`.
|
|
507
507
|
- Always import the CSS file once: `import 'rangeflow/style.css'`.
|
|
508
508
|
- `defaultRange` and `defaultSelected` are required. Both must be `{ from: Date; to: Date }`.
|
|
509
509
|
- `defaultSelected` must fit inside `defaultRange` or the slider will clamp it.
|
|
510
510
|
- `onChange` is required and fires with `{ from: Date; to: Date }`.
|
|
511
|
-
- To drive the picker from outside, call `
|
|
511
|
+
- To drive the picker from outside, call `useRangeFlow()` and pass the result to `<RangeFlow api={...} />`. Then use `updateRange` or `updateSelectedDates`.
|
|
512
512
|
- Theming is CSS variable based. Set `--rangeflow-accent` on any parent to re-skin the picker.
|
|
513
513
|
- Dark mode turns on via a `dark` class or `data-theme="dark"` on the picker or any parent.
|
|
514
514
|
- The picker is 560px wide and 140px tall by default (`w-140 h-35` in Tailwind units).
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RangeFlowApi } from '../types';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function useRangeFlow(): RangeFlowApi;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ function N(e, t) {
|
|
|
58
58
|
//#region src/package/rangeflow/utils/create-slider-values.ts
|
|
59
59
|
var ce = N([1, 100], [5, 100]);
|
|
60
60
|
function P(e, t) {
|
|
61
|
-
let n = d(e.from).startOf("day"), r = d(e.to).startOf("day").diff(n, "day"), i = d(t.from).startOf("day"), a = d(t.to).startOf("day"), o = Math.max(i.diff(n, "day"), 0), s =
|
|
61
|
+
let n = d(e.from).startOf("day"), r = d(e.to).startOf("day").diff(n, "day"), i = d(t.from).startOf("day"), a = d(t.to).startOf("day"), o = Math.max(i.diff(n, "day"), 0), s = (a.diff(i, "day") + 1) * 100 / r, c = o * 100 / r, l = Math.max(ce(s), 5), u = M(c - (l - s), 0, Math.max(100 - l, 0));
|
|
62
62
|
return {
|
|
63
63
|
size: l,
|
|
64
64
|
left: u,
|
|
@@ -297,7 +297,7 @@ function ge(e, t) {
|
|
|
297
297
|
left: r,
|
|
298
298
|
right: i,
|
|
299
299
|
from: a.add(u, "day").toDate(),
|
|
300
|
-
to: a.add(u + l, "day").toDate()
|
|
300
|
+
to: a.add(u + l - 1, "day").toDate()
|
|
301
301
|
};
|
|
302
302
|
}
|
|
303
303
|
//#endregion
|
|
@@ -352,7 +352,7 @@ function ve() {
|
|
|
352
352
|
//#region src/package/rangeflow/components/DateSlider/SliderValue.tsx
|
|
353
353
|
var ye = n(() => {
|
|
354
354
|
let { SliderValueLabel: e } = G(), n = K((e) => e.slider.size), r = K((e) => e.selected_date), i = c(() => {
|
|
355
|
-
let e =
|
|
355
|
+
let e = d(r.to).diff(r.from, "day") + 1;
|
|
356
356
|
return n < 10 ? `${e}D` : e === 1 ? "1 Day" : `${e} Days`;
|
|
357
357
|
}, [
|
|
358
358
|
r.from,
|
|
@@ -880,4 +880,4 @@ function He() {
|
|
|
880
880
|
};
|
|
881
881
|
}
|
|
882
882
|
//#endregion
|
|
883
|
-
export { Ve as RangeFlow, He as
|
|
883
|
+
export { Ve as RangeFlow, He as useRangeFlow };
|