@molecule/app-price-range-slider-react 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T00:40:48.533Z
7
+ -->
8
+
9
+ # @molecule/app-price-range-slider-react
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ Numeric min/max range picker.
16
+
17
+ Exports `<PriceRangeSlider>` — TWO native `<input type="range">` controls
18
+ rendered side by side (min slider + max slider) with formatted endpoint
19
+ labels. The handles clamp against each other so `low <= high` always
20
+ holds. It is not a single-track dual-thumb slider.
21
+
22
+ ## Quick Start
23
+
24
+ ```tsx
25
+ import { useState } from 'react'
26
+ import { PriceRangeSlider } from '@molecule/app-price-range-slider-react'
27
+
28
+ function PriceFilter() {
29
+ const [range, setRange] = useState<[number, number]>([50, 500])
30
+ return (
31
+ <PriceRangeSlider
32
+ min={0}
33
+ max={1000}
34
+ value={range}
35
+ onChange={setRange}
36
+ step={10}
37
+ label="Price range"
38
+ formatValue={(n) => `$${n}`}
39
+ />
40
+ )
41
+ }
42
+ ```
43
+
44
+ ## Type
45
+
46
+ `feature`
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ npm install @molecule/app-price-range-slider-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
52
+ npm install -D @types/react
53
+ ```
54
+
55
+ ## API
56
+
57
+ ### Interfaces
58
+
59
+ #### `PriceRangeSliderProps`
60
+
61
+ Props for {@link PriceRangeSlider}.
62
+
63
+ ```typescript
64
+ interface PriceRangeSliderProps {
65
+ /** Minimum possible value. */
66
+ min: number
67
+ /** Maximum possible value. */
68
+ max: number
69
+ /** Current [low, high] tuple. If only one value is relevant, set low === min. */
70
+ value: [number, number]
71
+ /** Called whenever either handle moves. */
72
+ onChange: (value: [number, number]) => void
73
+ /** Step increment. Defaults to 1. */
74
+ step?: number
75
+ /** Called to format each endpoint label — defaults to USD currency formatting. */
76
+ formatValue?: (n: number) => string
77
+ /** Optional label above. */
78
+ label?: React.ReactNode
79
+ /** Extra classes. */
80
+ className?: string
81
+ }
82
+ ```
83
+
84
+ ### Functions
85
+
86
+ #### `PriceRangeSlider(props)`
87
+
88
+ Dual-handle numeric range slider using two native `<input type="range">`
89
+ controls. Apps supply min/max/step and a `formatValue` to render the
90
+ endpoint labels (typical use: currency-formatted prices).
91
+
92
+ ```typescript
93
+ function PriceRangeSlider({
94
+ min,
95
+ max,
96
+ value,
97
+ onChange,
98
+ step = 1,
99
+ formatValue,
100
+ label,
101
+ className,
102
+ }: PriceRangeSliderProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
103
+ ```
104
+
105
+ - `props` — Component props (see {@link PriceRangeSliderProps}).
106
+
107
+ ## Injection Notes
108
+
109
+ ### Requirements
110
+
111
+ Peer dependencies:
112
+
113
+ - `@molecule/app-react` ^1.0.0
114
+ - `@molecule/app-ui` ^1.0.0
115
+ - `@molecule/app-ui-react` ^1.0.0
116
+ - `react` ^18.0.0 || ^19.0.0
117
+
118
+ ### Runtime Dependencies
119
+
120
+ - `@molecule/app-react`
121
+ - `@molecule/app-ui`
122
+ - `@molecule/app-ui-react`
123
+ - `react`
124
+
125
+ The default `formatValue` renders US-style dollars (`$1,000`) — always pass
126
+ your own formatter for non-USD apps. The two sliders carry fixed English
127
+ aria-labels ("Minimum"/"Maximum"); there is no locale bond. Requires a
128
+ wired ClassMap bond (`getClassMap()`).
@@ -0,0 +1,28 @@
1
+ import type React from 'react';
2
+ /** Props for {@link PriceRangeSlider}. */
3
+ export interface PriceRangeSliderProps {
4
+ /** Minimum possible value. */
5
+ min: number;
6
+ /** Maximum possible value. */
7
+ max: number;
8
+ /** Current [low, high] tuple. If only one value is relevant, set low === min. */
9
+ value: [number, number];
10
+ /** Called whenever either handle moves. */
11
+ onChange: (value: [number, number]) => void;
12
+ /** Step increment. Defaults to 1. */
13
+ step?: number;
14
+ /** Called to format each endpoint label — defaults to USD currency formatting. */
15
+ formatValue?: (n: number) => string;
16
+ /** Optional label above. */
17
+ label?: React.ReactNode;
18
+ /** Extra classes. */
19
+ className?: string;
20
+ }
21
+ /**
22
+ * Dual-handle numeric range slider using two native `<input type="range">`
23
+ * controls. Apps supply min/max/step and a `formatValue` to render the
24
+ * endpoint labels (typical use: currency-formatted prices).
25
+ * @param props - Component props (see {@link PriceRangeSliderProps}).
26
+ */
27
+ export declare function PriceRangeSlider({ min, max, value, onChange, step, formatValue, label, className, }: PriceRangeSliderProps): React.ReactElement;
28
+ //# sourceMappingURL=PriceRangeSlider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PriceRangeSlider.d.ts","sourceRoot":"","sources":["../src/PriceRangeSlider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,0CAA0C;AAC1C,MAAM,WAAW,qBAAqB;IACpC,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,iFAAiF;IACjF,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvB,2CAA2C;IAC3C,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAA;IAC3C,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kFAAkF;IAClF,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IACnC,4BAA4B;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,GAAG,EACH,GAAG,EACH,KAAK,EACL,QAAQ,EACR,IAAQ,EACR,WAAW,EACX,KAAK,EACL,SAAS,GACV,EAAE,qBAAqB,GAAG,KAAK,CAAC,YAAY,CAmC5C"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { getClassMap } from '@molecule/app-ui';
3
+ /**
4
+ * Dual-handle numeric range slider using two native `<input type="range">`
5
+ * controls. Apps supply min/max/step and a `formatValue` to render the
6
+ * endpoint labels (typical use: currency-formatted prices).
7
+ * @param props - Component props (see {@link PriceRangeSliderProps}).
8
+ */
9
+ export function PriceRangeSlider({ min, max, value, onChange, step = 1, formatValue, label, className, }) {
10
+ const cm = getClassMap();
11
+ const [low, high] = value;
12
+ const fmt = formatValue ?? ((n) => `$${n.toLocaleString()}`);
13
+ return (_jsxs("div", { className: cm.cn(cm.stack(2), className), children: [label && (_jsx("span", { className: cm.cn(cm.textSize('xs'), cm.fontWeight('semibold')), children: label })), _jsxs("div", { className: cm.flex({ align: 'center', gap: 'sm' }), children: [_jsx("span", { className: cm.textSize('sm'), children: fmt(low) }), _jsx("input", { type: "range", min: min, max: max, step: step, value: low, onChange: (e) => onChange([Math.min(Number(e.target.value), high), high]), className: cm.flex1, "aria-label": "Minimum" }), _jsx("input", { type: "range", min: min, max: max, step: step, value: high, onChange: (e) => onChange([low, Math.max(Number(e.target.value), low)]), className: cm.flex1, "aria-label": "Maximum" }), _jsx("span", { className: cm.textSize('sm'), children: fmt(high) })] })] }));
14
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Numeric min/max range picker.
3
+ *
4
+ * Exports `<PriceRangeSlider>` — TWO native `<input type="range">` controls
5
+ * rendered side by side (min slider + max slider) with formatted endpoint
6
+ * labels. The handles clamp against each other so `low <= high` always
7
+ * holds. It is not a single-track dual-thumb slider.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import { useState } from 'react'
12
+ * import { PriceRangeSlider } from '@molecule/app-price-range-slider-react'
13
+ *
14
+ * function PriceFilter() {
15
+ * const [range, setRange] = useState<[number, number]>([50, 500])
16
+ * return (
17
+ * <PriceRangeSlider
18
+ * min={0}
19
+ * max={1000}
20
+ * value={range}
21
+ * onChange={setRange}
22
+ * step={10}
23
+ * label="Price range"
24
+ * formatValue={(n) => `$${n}`}
25
+ * />
26
+ * )
27
+ * }
28
+ * ```
29
+ *
30
+ * @remarks
31
+ * The default `formatValue` renders US-style dollars (`$1,000`) — always pass
32
+ * your own formatter for non-USD apps. The two sliders carry fixed English
33
+ * aria-labels ("Minimum"/"Maximum"); there is no locale bond. Requires a
34
+ * wired ClassMap bond (`getClassMap()`).
35
+ *
36
+ * @module
37
+ */
38
+ export * from './PriceRangeSlider.js';
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,cAAc,uBAAuB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Numeric min/max range picker.
3
+ *
4
+ * Exports `<PriceRangeSlider>` — TWO native `<input type="range">` controls
5
+ * rendered side by side (min slider + max slider) with formatted endpoint
6
+ * labels. The handles clamp against each other so `low <= high` always
7
+ * holds. It is not a single-track dual-thumb slider.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import { useState } from 'react'
12
+ * import { PriceRangeSlider } from '@molecule/app-price-range-slider-react'
13
+ *
14
+ * function PriceFilter() {
15
+ * const [range, setRange] = useState<[number, number]>([50, 500])
16
+ * return (
17
+ * <PriceRangeSlider
18
+ * min={0}
19
+ * max={1000}
20
+ * value={range}
21
+ * onChange={setRange}
22
+ * step={10}
23
+ * label="Price range"
24
+ * formatValue={(n) => `$${n}`}
25
+ * />
26
+ * )
27
+ * }
28
+ * ```
29
+ *
30
+ * @remarks
31
+ * The default `formatValue` renders US-style dollars (`$1,000`) — always pass
32
+ * your own formatter for non-USD apps. The two sliders carry fixed English
33
+ * aria-labels ("Minimum"/"Maximum"); there is no locale bond. Requires a
34
+ * wired ClassMap bond (`getClassMap()`).
35
+ *
36
+ * @module
37
+ */
38
+ export * from './PriceRangeSlider.js';
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@molecule/app-price-range-slider-react",
3
+ "version": "1.0.0",
4
+ "description": "Single- or dual-handle range slider with formatted labels",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "keywords": [
23
+ "molecule",
24
+ "price-range-slider",
25
+ "react"
26
+ ],
27
+ "license": "Apache-2.0",
28
+ "peerDependencies": {
29
+ "@molecule/app-react": "^1.0.0",
30
+ "@molecule/app-ui": "^1.0.0",
31
+ "@molecule/app-ui-react": "^1.0.0",
32
+ "react": "^18.0.0 || ^19.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "@molecule/app-react": "1.0.0",
36
+ "@molecule/app-ui": "1.0.0",
37
+ "@molecule/app-ui-react": "1.0.0",
38
+ "@types/node": "26.1.2",
39
+ "@types/react": "19.2.17",
40
+ "@types/react-dom": "19.2.3",
41
+ "react": "19.2.8",
42
+ "react-dom": "19.2.8",
43
+ "typescript": "6.0.3",
44
+ "vitest": "4.1.10"
45
+ }
46
+ }