react-matchings 0.0.8 → 0.1.1
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 +70 -3
- package/dist/index.css +1 -1
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +224 -136
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +225 -137
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,12 +4,18 @@ A React component for building question-and-answer matching interactions. It ren
|
|
|
4
4
|
|
|
5
5
|
Default styles are included automatically when the component is imported. Consumers do not need to import a separate CSS file.
|
|
6
6
|
|
|
7
|
+
[View the package on npm](https://www.npmjs.com/package/react-matchings)
|
|
8
|
+
|
|
7
9
|
## Features
|
|
8
10
|
|
|
9
11
|
- Drag-to-connect matching interaction
|
|
10
|
-
-
|
|
12
|
+
- Pointer support for mouse, touch, and pen input
|
|
13
|
+
- Automatic scrolling while dragging near a scroll container edge
|
|
14
|
+
- One-to-one answers by default, with optional answer reuse
|
|
15
|
+
- Controlled matches and change callback for saving or validating answers
|
|
11
16
|
- Custom classes for the container, question buttons, and answer buttons
|
|
12
17
|
- Configurable connector line color, endpoint color, radius, and offset
|
|
18
|
+
- Per-match styles for validation feedback
|
|
13
19
|
- Disabled state for submitted or read-only flows
|
|
14
20
|
- TypeScript definitions included
|
|
15
21
|
|
|
@@ -61,6 +67,8 @@ function App() {
|
|
|
61
67
|
| ------------------- | -------------------------------- | ----------- | ------------------------------------------------------------ |
|
|
62
68
|
| `questions` | `{ id: number; text: string }[]` | Required | Items rendered in the left column. |
|
|
63
69
|
| `answers` | `{ id: number; text: string }[]` | Required | Items rendered in the right column. |
|
|
70
|
+
| `matches` | `TMatch[]` | `undefined` | Controlled match list. Use with `onChange` to own state. |
|
|
71
|
+
| `defaultMatches` | `TMatch[]` | `undefined` | Initial match list for uncontrolled usage. |
|
|
64
72
|
| `onChange` | `(matches: TMatch[]) => void` | `undefined` | Called whenever the user creates or removes a match. |
|
|
65
73
|
| `className` | `string` | `undefined` | Additional classes for the root container. |
|
|
66
74
|
| `questionClassName` | `string` | `undefined` | Additional classes for question buttons. |
|
|
@@ -70,6 +78,9 @@ function App() {
|
|
|
70
78
|
| `circleRadius` | `number` | `8` | Radius of connector endpoints in pixels. |
|
|
71
79
|
| `offset` | `number` | `10` | Distance from button edges to connector endpoints in pixels. |
|
|
72
80
|
| `disabled` | `boolean` | `false` | Prevents users from creating or removing matches. |
|
|
81
|
+
| `allowAnswerReuse` | `boolean` | `false` | Allows multiple questions to connect to the same answer. |
|
|
82
|
+
| `autoScroll` | `boolean \| TAutoScrollOptions` | `true` | Scrolls the nearest overflow container while dragging near an edge. |
|
|
83
|
+
| `getMatchStyles` | `(match: TMatch) => TMatchStyles \| undefined` | `undefined` | Returns connector and item styles for an established match. |
|
|
73
84
|
|
|
74
85
|
## Types
|
|
75
86
|
|
|
@@ -78,6 +89,18 @@ type TMatch = {
|
|
|
78
89
|
questionId: number;
|
|
79
90
|
answerId: number;
|
|
80
91
|
};
|
|
92
|
+
|
|
93
|
+
type TMatchStyles = {
|
|
94
|
+
lineColor?: string;
|
|
95
|
+
circleColor?: string;
|
|
96
|
+
questionClassName?: string;
|
|
97
|
+
answerClassName?: string;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
type TAutoScrollOptions = {
|
|
101
|
+
edgeThreshold?: number;
|
|
102
|
+
maxSpeed?: number;
|
|
103
|
+
};
|
|
81
104
|
```
|
|
82
105
|
|
|
83
106
|
`onChange` receives the full list of current matches:
|
|
@@ -88,6 +111,32 @@ const handleChange = (matches: TMatch[]) => {
|
|
|
88
111
|
};
|
|
89
112
|
```
|
|
90
113
|
|
|
114
|
+
Use `defaultMatches` when you only need to seed the initial state:
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
<Matching
|
|
118
|
+
questions={questions}
|
|
119
|
+
answers={answers}
|
|
120
|
+
defaultMatches={[{ questionId: 1, answerId: 2 }]}
|
|
121
|
+
onChange={setMatches}
|
|
122
|
+
/>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Use `matches` when the parent owns the current value:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
const [matches, setMatches] = useState<TMatch[]>([
|
|
129
|
+
{ questionId: 1, answerId: 2 },
|
|
130
|
+
]);
|
|
131
|
+
|
|
132
|
+
<Matching
|
|
133
|
+
questions={questions}
|
|
134
|
+
answers={answers}
|
|
135
|
+
matches={matches}
|
|
136
|
+
onChange={setMatches}
|
|
137
|
+
/>
|
|
138
|
+
```
|
|
139
|
+
|
|
91
140
|
## Styling
|
|
92
141
|
|
|
93
142
|
The component ships with default styles and injects them automatically in the browser. You can override the default button and layout styles with class props:
|
|
@@ -149,8 +198,24 @@ export function Assessment() {
|
|
|
149
198
|
<Matching
|
|
150
199
|
questions={questions}
|
|
151
200
|
answers={answers}
|
|
201
|
+
matches={matches}
|
|
152
202
|
onChange={setMatches}
|
|
153
203
|
disabled={submitted}
|
|
204
|
+
getMatchStyles={(match) =>
|
|
205
|
+
submitted &&
|
|
206
|
+
!correctMatches.some(
|
|
207
|
+
(correct) =>
|
|
208
|
+
correct.questionId === match.questionId &&
|
|
209
|
+
correct.answerId === match.answerId,
|
|
210
|
+
)
|
|
211
|
+
? {
|
|
212
|
+
lineColor: "#ef4444",
|
|
213
|
+
circleColor: "#ef4444",
|
|
214
|
+
questionClassName: "bg-red-500",
|
|
215
|
+
answerClassName: "bg-red-500",
|
|
216
|
+
}
|
|
217
|
+
: undefined
|
|
218
|
+
}
|
|
154
219
|
/>
|
|
155
220
|
|
|
156
221
|
<button
|
|
@@ -174,9 +239,11 @@ export function Assessment() {
|
|
|
174
239
|
## Behavior
|
|
175
240
|
|
|
176
241
|
- Press and drag from a question to an answer to create a match.
|
|
242
|
+
- Drag near the edge of an overflow container to scroll it.
|
|
177
243
|
- Click a matched question to remove its current match.
|
|
178
244
|
- A question can have one answer at a time.
|
|
179
|
-
- An answer can
|
|
245
|
+
- An answer can have one question by default. Connecting it again replaces its previous match.
|
|
246
|
+
- Set `allowAnswerReuse` to `true` to connect an answer to more than one question.
|
|
180
247
|
- `onChange` receives the complete match list after each create or remove action.
|
|
181
248
|
|
|
182
249
|
## Local Testing
|
|
@@ -191,7 +258,7 @@ npm pack
|
|
|
191
258
|
Then install the generated tarball in a test React application:
|
|
192
259
|
|
|
193
260
|
```bash
|
|
194
|
-
npm install /absolute/path/to/react-matchings/react-matchings-0.0.
|
|
261
|
+
npm install /absolute/path/to/react-matchings/react-matchings-0.1.0.tgz
|
|
195
262
|
```
|
|
196
263
|
|
|
197
264
|
Import only the component:
|
package/dist/index.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
|
|
2
|
-
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-space-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-slate-300:oklch(86.9% .022 252.894);--color-slate-700:oklch(37.2% .044 257.287);--color-slate-900:oklch(20.8% .042 265.755);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-3xl:48rem;--font-weight-medium:500;--radius-md:.375rem;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.absolute{position:absolute}.relative{position:relative}.z-10{z-index:10}.z-20{z-index:20}.contents{display:contents}.grid{display:grid}.h-full{height:100%}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.gap-10{gap:calc(var(--spacing) * 10)}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}.rounded{border-radius:.25rem}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-gray-200{border-color:var(--color-gray-200)}.border-slate-300{border-color:var(--color-slate-300)}.bg-black{background-color:var(--color-black)}.bg-gray-700{background-color:var(--color-gray-700)}.bg-slate-900{background-color:var(--color-slate-900)}.bg-white{background-color:var(--color-white)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.text-slate-900{color:var(--color-slate-900)}.text-white{color:var(--color-white)}.select-none{-webkit-user-select:none;user-select:none}@media (hover:hover){.hover\:bg-slate-700:hover{background-color:var(--color-slate-700)}}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-gray-500:focus{--tw-ring-color:var(--color-gray-500)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}
|
|
2
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-space-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-500:oklch(63.7% .237 25.331);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-700:oklch(37.2% .044 257.287);--color-slate-900:oklch(20.8% .042 265.755);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-3xl:48rem;--font-weight-medium:500;--radius-md:.375rem;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.absolute{position:absolute}.relative{position:relative}.z-10{z-index:10}.z-20{z-index:20}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.contents{display:contents}.grid{display:grid}.h-full{height:100%}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.touch-none{touch-action:none}.resize{resize:both}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.gap-10{gap:calc(var(--spacing) * 10)}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}.rounded{border-radius:.25rem}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-gray-200{border-color:var(--color-gray-200)}.border-slate-300{border-color:var(--color-slate-300)}.bg-black{background-color:var(--color-black)}.bg-gray-700{background-color:var(--color-gray-700)}.bg-red-500{background-color:var(--color-red-500)}.bg-slate-900{background-color:var(--color-slate-900)}.bg-white{background-color:var(--color-white)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.text-slate-900{color:var(--color-slate-900)}.text-white{color:var(--color-white)}.select-none{-webkit-user-select:none;user-select:none}@media (hover:hover){.hover\:bg-slate-700:hover{background-color:var(--color-slate-700)}}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-gray-500:focus{--tw-ring-color:var(--color-gray-500)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,17 @@ type TMatch = {
|
|
|
4
4
|
questionId: number;
|
|
5
5
|
answerId: number;
|
|
6
6
|
};
|
|
7
|
-
type
|
|
7
|
+
type TMatchStyles = {
|
|
8
|
+
lineColor?: string;
|
|
9
|
+
circleColor?: string;
|
|
10
|
+
questionClassName?: string;
|
|
11
|
+
answerClassName?: string;
|
|
12
|
+
};
|
|
13
|
+
type TAutoScrollOptions = {
|
|
14
|
+
edgeThreshold?: number;
|
|
15
|
+
maxSpeed?: number;
|
|
16
|
+
};
|
|
17
|
+
type MatchingProps = {
|
|
8
18
|
questions: {
|
|
9
19
|
id: number;
|
|
10
20
|
text: string;
|
|
@@ -13,6 +23,8 @@ type Props = {
|
|
|
13
23
|
id: number;
|
|
14
24
|
text: string;
|
|
15
25
|
}[];
|
|
26
|
+
matches?: TMatch[];
|
|
27
|
+
defaultMatches?: TMatch[];
|
|
16
28
|
className?: string;
|
|
17
29
|
questionClassName?: string;
|
|
18
30
|
answerClassName?: string;
|
|
@@ -21,8 +33,11 @@ type Props = {
|
|
|
21
33
|
circleRadius?: number;
|
|
22
34
|
offset?: number;
|
|
23
35
|
disabled?: boolean;
|
|
36
|
+
allowAnswerReuse?: boolean;
|
|
37
|
+
autoScroll?: boolean | TAutoScrollOptions;
|
|
38
|
+
getMatchStyles?: (match: TMatch) => TMatchStyles | undefined;
|
|
24
39
|
onChange?: (matches: TMatch[]) => void;
|
|
25
40
|
};
|
|
26
|
-
declare function Matching({ questions, answers, className, questionClassName, answerClassName, lineColor, circleColor, circleRadius, offset, disabled, onChange, }:
|
|
41
|
+
declare function Matching({ questions, answers, matches: controlledMatches, defaultMatches, className, questionClassName, answerClassName, lineColor, circleColor, circleRadius, offset, disabled, allowAnswerReuse, autoScroll, getMatchStyles, onChange, }: MatchingProps): react_jsx_runtime.JSX.Element;
|
|
27
42
|
|
|
28
|
-
export { Matching, type TMatch };
|
|
43
|
+
export { Matching, type MatchingProps, type TAutoScrollOptions, type TMatch, type TMatchStyles };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,17 @@ type TMatch = {
|
|
|
4
4
|
questionId: number;
|
|
5
5
|
answerId: number;
|
|
6
6
|
};
|
|
7
|
-
type
|
|
7
|
+
type TMatchStyles = {
|
|
8
|
+
lineColor?: string;
|
|
9
|
+
circleColor?: string;
|
|
10
|
+
questionClassName?: string;
|
|
11
|
+
answerClassName?: string;
|
|
12
|
+
};
|
|
13
|
+
type TAutoScrollOptions = {
|
|
14
|
+
edgeThreshold?: number;
|
|
15
|
+
maxSpeed?: number;
|
|
16
|
+
};
|
|
17
|
+
type MatchingProps = {
|
|
8
18
|
questions: {
|
|
9
19
|
id: number;
|
|
10
20
|
text: string;
|
|
@@ -13,6 +23,8 @@ type Props = {
|
|
|
13
23
|
id: number;
|
|
14
24
|
text: string;
|
|
15
25
|
}[];
|
|
26
|
+
matches?: TMatch[];
|
|
27
|
+
defaultMatches?: TMatch[];
|
|
16
28
|
className?: string;
|
|
17
29
|
questionClassName?: string;
|
|
18
30
|
answerClassName?: string;
|
|
@@ -21,8 +33,11 @@ type Props = {
|
|
|
21
33
|
circleRadius?: number;
|
|
22
34
|
offset?: number;
|
|
23
35
|
disabled?: boolean;
|
|
36
|
+
allowAnswerReuse?: boolean;
|
|
37
|
+
autoScroll?: boolean | TAutoScrollOptions;
|
|
38
|
+
getMatchStyles?: (match: TMatch) => TMatchStyles | undefined;
|
|
24
39
|
onChange?: (matches: TMatch[]) => void;
|
|
25
40
|
};
|
|
26
|
-
declare function Matching({ questions, answers, className, questionClassName, answerClassName, lineColor, circleColor, circleRadius, offset, disabled, onChange, }:
|
|
41
|
+
declare function Matching({ questions, answers, matches: controlledMatches, defaultMatches, className, questionClassName, answerClassName, lineColor, circleColor, circleRadius, offset, disabled, allowAnswerReuse, autoScroll, getMatchStyles, onChange, }: MatchingProps): react_jsx_runtime.JSX.Element;
|
|
27
42
|
|
|
28
|
-
export { Matching, type TMatch };
|
|
43
|
+
export { Matching, type MatchingProps, type TAutoScrollOptions, type TMatch, type TMatchStyles };
|