diff --git a/package.json b/package.json index 0fdeea2..b125551 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,6 @@ "react": ">17" }, "dependencies": { - "ink-multi-select": "^2.0.0", - "ink-quicksearch-input": "^1.0.0", "ink-select-input": "^5.0.0", "ink-text-input": "^5.0.1" } diff --git a/readme.md b/readme.md index 40729d4..2136da6 100644 --- a/readme.md +++ b/readme.md @@ -67,6 +67,13 @@ dependencies and then run one of the demo scripts: - `yarn demo:custommanager` ([See Code](https://github.com/lukasbach/ink-form/blob/main/src/demo/custommanager.tsx)) - `yarn demo:imperative` ([See Code](https://github.com/lukasbach/ink-form/blob/main/src/demo/imperative.ts)) +## Update Note + +This package is now pure ESM as of 2.0.0. (Details: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) + +With that upgrade, I had to remove the multi select component as its dependency does not support ESM. Please +use the v1x version branch with CJS if you need that. + ## Documentation Detailed documentation is available at [lukasbach.github.io/ink-form](https://lukasbach.github.io/ink-form/). diff --git a/src/demo/overview.tsx b/src/demo/overview.tsx index cefea1d..c23e5b8 100644 --- a/src/demo/overview.tsx +++ b/src/demo/overview.tsx @@ -38,7 +38,6 @@ render( title: "Selection fields", fields: [ { type: 'select', name: 'field20', label: 'Select', options }, - { type: 'multiselect', name: 'field21', label: 'Multi Select', options }, ] }, { diff --git a/src/managers/MultiSelectFormFieldManager.tsx b/src/managers/MultiSelectFormFieldManager.tsx deleted file mode 100644 index 594e3eb..0000000 --- a/src/managers/MultiSelectFormFieldManager.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { - FormFieldManager, - FormFieldMultiSelect, - FormFieldValueRendererProps, - SpecificFormFieldRendererProps, - TypeOfField, -} from '../types.js'; -import React from 'react'; -import { Box } from 'ink'; -import SelectInput from 'ink-multi-select'; - -export class MultiSelectFormFieldManager implements FormFieldManager { - public type: TypeOfField = 'multiselect'; - - public renderField: React.FC> = props => ( - - ({ value: option.value, label: option.label ?? option.value }))} - onSelect={option => props.onChange([...(props.value ?? []), option.value as string])} - onUnselect={option => props.onChange((props.value ?? []).filter(value => value !== option.value))} - defaultSelected={props.field.options.filter(option => props.value?.includes(option.value))} - /> - - ); - - public renderValue: React.FC> = props => ( - <> - {props.field.options - .filter(option => props.value?.includes(option.value)) - ?.map(option => option.label ?? option.value) - ?.join(', ') ?? 'No value'} - - ); -} diff --git a/src/managers/managers.ts b/src/managers/managers.ts index 4a6d725..27a2104 100644 --- a/src/managers/managers.ts +++ b/src/managers/managers.ts @@ -1,6 +1,5 @@ import { FloatFormFieldManager } from './FloatFormFieldManager.js'; import { IntegerFormFieldManager } from './IntegerFormFieldManager.js'; -import { MultiSelectFormFieldManager } from './MultiSelectFormFieldManager.js'; import { SelectFormFieldManager } from './SelectFormFieldManager.js'; import { FormField, FormFieldManager, TypeOfField } from '../types.js'; import { StringFormFieldManager } from './StringFormFieldManager.js'; @@ -9,7 +8,6 @@ import { BooleanFormFieldManager } from './BooleanFormFieldManager.js'; export const managers: FormFieldManager[] = [ new FloatFormFieldManager(), new IntegerFormFieldManager(), - new MultiSelectFormFieldManager(), new SelectFormFieldManager(), new StringFormFieldManager(), new BooleanFormFieldManager(), diff --git a/src/types.ts b/src/types.ts index c6d4c79..8379d88 100644 --- a/src/types.ts +++ b/src/types.ts @@ -76,7 +76,6 @@ export interface FormSection { * - FormFieldInteger * - FormFieldFloat * - FormFieldSelect - * - FormFieldMultiSelect * - FormFieldBoolean * * You can add your own form field by extending ``AbstractFormField`` and implementing @@ -87,7 +86,6 @@ export type FormField = | FormFieldInteger | FormFieldFloat | FormFieldSelect - | FormFieldMultiSelect | FormFieldBoolean | AbstractFormField; @@ -155,10 +153,6 @@ export type FormFieldSelect = AbstractFormField<'select', string> & { options: Array<{ label?: string; value: string }>; }; -export type FormFieldMultiSelect = AbstractFormField<'multiselect', string[]> & { - options: Array<{ label?: string; value: string }>; -}; - export interface FormFieldValueRendererProps { value?: ValueOfField; field: T;