@conform-to/dom
Advanced tools
Comparing version 0.8.0 to 0.8.1
@@ -0,1 +1,2 @@ | ||
import { type Pretty } from './types.js'; | ||
export interface IntentButtonProps { | ||
@@ -8,2 +9,7 @@ name: typeof INTENT; | ||
name: string; | ||
operation: 'insert'; | ||
defaultValue?: Schema; | ||
index?: number; | ||
} | { | ||
name: string; | ||
operation: 'prepend'; | ||
@@ -30,2 +36,6 @@ defaultValue?: Schema; | ||
}; | ||
type ExtractListIntentPayload<Operation, Schema = unknown> = Pretty<Omit<Extract<ListIntentPayload<Schema>, { | ||
operation: Operation; | ||
}>, 'name' | 'operation'>>; | ||
type ListIntent<Operation> = {} extends ExtractListIntentPayload<Operation> ? <Schema>(name: string, payload?: ExtractListIntentPayload<Operation, Schema>) => IntentButtonProps : <Schema>(name: string, payload: ExtractListIntentPayload<Operation, Schema>) => IntentButtonProps; | ||
/** | ||
@@ -37,19 +47,14 @@ * Helpers to configure an intent button for modifying a list | ||
export declare const list: { | ||
prepend: <Schema>(name: string, payload?: { | ||
defaultValue?: Schema | undefined; | ||
} | undefined) => IntentButtonProps; | ||
append: <Schema_1>(name: string, payload?: { | ||
defaultValue?: Schema_1 | undefined; | ||
} | undefined) => IntentButtonProps; | ||
replace: <Schema_2>(name: string, payload: { | ||
defaultValue: Schema_2; | ||
index: number; | ||
}) => IntentButtonProps; | ||
remove: <Schema_3>(name: string, payload: { | ||
index: number; | ||
}) => IntentButtonProps; | ||
reorder: <Schema_4>(name: string, payload: { | ||
from: number; | ||
to: number; | ||
}) => IntentButtonProps; | ||
/** | ||
* @deprecated You can use `insert` without specifying an index instead | ||
*/ | ||
append: ListIntent<'append'>; | ||
/** | ||
* @deprecated You can use `insert` with zero index instead | ||
*/ | ||
prepend: ListIntent<'prepend'>; | ||
insert: ListIntent<'insert'>; | ||
replace: ListIntent<'replace'>; | ||
remove: ListIntent<'remove'>; | ||
reorder: ListIntent<'reorder'>; | ||
}; | ||
@@ -80,1 +85,2 @@ export declare const INTENT = "__intent__"; | ||
export declare function updateList<Schema>(list: Array<Schema>, payload: ListIntentPayload<Schema>): Array<Schema>; | ||
export {}; |
@@ -63,2 +63,3 @@ 'use strict'; | ||
if (!form) { | ||
// eslint-disable-next-line no-console | ||
console.warn('No form element is provided'); | ||
@@ -104,2 +105,3 @@ return; | ||
function updateList(list, payload) { | ||
var _payload$index; | ||
switch (payload.operation) { | ||
@@ -112,2 +114,5 @@ case 'prepend': | ||
break; | ||
case 'insert': | ||
list.splice((_payload$index = payload.index) !== null && _payload$index !== void 0 ? _payload$index : list.length, 0, payload.defaultValue); | ||
break; | ||
case 'replace': | ||
@@ -114,0 +119,0 @@ list.splice(payload.index, 1, payload.defaultValue); |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"main": "index.js", | ||
@@ -9,0 +9,0 @@ "module": "index.mjs", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43663
1196