inquirer-plugins 1.0.0-alpha.5 → 1.0.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 +5 -34
- package/dist/lib/_internal/plugins/table/table.d.ts +2 -0
- package/dist/lib/_internal/plugins/table/table.d.ts.map +1 -0
- package/dist/lib/_internal/plugins/table/table.js +1 -0
- package/dist/lib/_internal/plugins/table/types/columns.d.ts +21 -0
- package/dist/lib/_internal/plugins/table/types/columns.d.ts.map +1 -0
- package/dist/lib/_internal/plugins/table/types/columns.js +2 -0
- package/dist/lib/_internal/plugins/table/types/common.d.ts +25 -0
- package/dist/lib/_internal/plugins/table/types/common.d.ts.map +1 -0
- package/dist/lib/_internal/plugins/table/types/common.js +5 -0
- package/dist/lib/_internal/plugins/table/types/rows.d.ts +2 -0
- package/dist/lib/_internal/plugins/table/types/rows.d.ts.map +1 -0
- package/dist/lib/_internal/plugins/table/types/table.d.ts +27 -0
- package/dist/lib/_internal/plugins/table/types/table.d.ts.map +1 -0
- package/dist/lib/_internal/plugins/table/types.d.ts +27 -0
- package/dist/lib/_internal/plugins/table/types.d.ts.map +1 -0
- package/dist/lib/_internal/plugins/table/types.js +24 -0
- package/dist/lib/_internal/plugins/table/utils.d.ts +25 -0
- package/dist/lib/_internal/plugins/table/utils.d.ts.map +1 -0
- package/dist/lib/_internal/plugins/table/utils.js +179 -0
- package/dist/lib/_internal/plugins/table.d.ts +11 -0
- package/dist/lib/_internal/plugins/table.d.ts.map +1 -0
- package/dist/lib/_internal/plugins/table.js +173 -0
- package/dist/lib/_internal/types/chalk.d.ts +7 -0
- package/dist/lib/_internal/types/chalk.d.ts.map +1 -0
- package/dist/lib/_internal/types/chalk.js +1 -0
- package/dist/lib/_internal/types/inquirer.d.ts +6 -0
- package/dist/lib/_internal/types/inquirer.d.ts.map +1 -0
- package/dist/lib/_internal/types/inquirer.js +5 -0
- package/dist/lib/_internal/types/parse-types.d.ts +7 -0
- package/dist/lib/_internal/types/parse-types.d.ts.map +1 -0
- package/{src/_internal/types/parse-types.ts → dist/lib/_internal/types/parse-types.js} +1 -3
- package/dist/lib/_internal/types/table.d.ts +15 -0
- package/dist/lib/_internal/types/table.d.ts.map +1 -0
- package/dist/lib/_internal/types/table.js +1 -0
- package/dist/lib/_internal/utils/chalk.d.ts +12 -0
- package/dist/lib/_internal/utils/chalk.d.ts.map +1 -0
- package/dist/lib/_internal/utils/chalk.js +29 -0
- package/dist/lib/_internal/utils/columns.d.ts +7 -0
- package/dist/lib/_internal/utils/columns.d.ts.map +1 -0
- package/dist/lib/_internal/utils/columns.js +28 -0
- package/dist/lib/_internal/utils/common.d.ts +4 -0
- package/dist/lib/_internal/utils/common.d.ts.map +1 -0
- package/dist/lib/_internal/utils/common.js +3 -0
- package/dist/lib/_internal/utils/keypress.d.ts +12 -0
- package/dist/lib/_internal/utils/keypress.d.ts.map +1 -0
- package/dist/lib/_internal/utils/keypress.js +28 -0
- package/dist/lib/_internal/utils/parse-types.d.ts +4 -0
- package/dist/lib/_internal/utils/parse-types.d.ts.map +1 -0
- package/{src/_internal/utils/parse-types.ts → dist/lib/_internal/utils/parse-types.js} +3 -7
- package/dist/lib/_internal/utils/table/arrow-key.d.ts +14 -0
- package/dist/lib/_internal/utils/table/arrow-key.d.ts.map +1 -0
- package/dist/lib/_internal/utils/table/arrow-key.js +24 -0
- package/dist/lib/_internal/utils/table/cell.d.ts +3 -0
- package/dist/lib/_internal/utils/table/cell.d.ts.map +1 -0
- package/dist/lib/_internal/utils/table/cell.js +6 -0
- package/dist/lib/_internal/utils/table/columns.d.ts +3 -0
- package/dist/lib/_internal/utils/table/columns.d.ts.map +1 -0
- package/dist/lib/_internal/utils/table/columns.js +29 -0
- package/dist/lib/_internal/utils/table/pagenate.d.ts +4 -0
- package/dist/lib/_internal/utils/table/pagenate.d.ts.map +1 -0
- package/dist/lib/_internal/utils/table/pagenate.js +20 -0
- package/dist/lib/_internal/utils/table/rows.d.ts +3 -0
- package/dist/lib/_internal/utils/table/rows.d.ts.map +1 -0
- package/dist/lib/_internal/utils/table/rows.js +4 -0
- package/dist/lib/modules/table.d.ts +2 -0
- package/dist/lib/modules/table.d.ts.map +1 -0
- package/dist/lib/modules/table.js +1 -0
- package/dist/lib/modules/types/chalk.d.ts +2 -0
- package/dist/lib/modules/types/chalk.d.ts.map +1 -0
- package/dist/lib/modules/types/chalk.js +1 -0
- package/dist/{modules → lib/modules}/types/inquirer.d.ts +1 -0
- package/dist/lib/modules/types/inquirer.d.ts.map +1 -0
- package/dist/{modules → lib/modules}/types/parse-types.d.ts +1 -0
- package/dist/lib/modules/types/parse-types.d.ts.map +1 -0
- package/dist/lib/modules/types/table.d.ts +2 -0
- package/dist/lib/modules/types/table.d.ts.map +1 -0
- package/dist/lib/modules/types/table.js +1 -0
- package/package.json +27 -103
- package/LICENSE +0 -21
- package/dist/_internal/plugins/table/table.d.ts +0 -15
- package/dist/_internal/plugins/table/table.js +0 -77
- package/dist/_internal/plugins/table/types.d.ts +0 -47
- package/dist/_internal/plugins/table/types.js +0 -23
- package/dist/_internal/plugins/table/utils.d.ts +0 -3
- package/dist/_internal/plugins/table/utils.js +0 -22
- package/dist/_internal/plugins/table.d.ts +0 -49
- package/dist/_internal/plugins/table.js +0 -263
- package/dist/_internal/plugins/test.js +0 -50
- package/dist/_internal/types/inquirer.d.ts +0 -1
- package/dist/_internal/types/parse-types.d.ts +0 -6
- package/dist/_internal/types/parse-types.js +0 -5
- package/dist/_internal/utils/chalk.d.ts +0 -9
- package/dist/_internal/utils/chalk.js +0 -10
- package/dist/_internal/utils/keypress.d.ts +0 -4
- package/dist/_internal/utils/keypress.js +0 -20
- package/dist/_internal/utils/parse-types.d.ts +0 -3
- package/dist/_internal/utils/parse-types.js +0 -23
- package/dist/modules/table.d.ts +0 -2
- package/dist/modules/table.js +0 -2
- package/src/_internal/plugins/table/README.md +0 -117
- package/src/_internal/plugins/table/table.ts +0 -93
- package/src/_internal/plugins/table/types.ts +0 -74
- package/src/_internal/plugins/table/utils.ts +0 -25
- package/src/_internal/plugins/table.ts +0 -305
- package/src/_internal/plugins/test.ts +0 -76
- package/src/_internal/types/inquirer.ts +0 -1
- package/src/_internal/utils/chalk.ts +0 -13
- package/src/_internal/utils/keypress.ts +0 -23
- package/src/modules/table.ts +0 -2
- package/src/modules/types/inquirer.ts +0 -1
- package/src/modules/types/parse-types.ts +0 -1
- package/table/package.json +0 -6
- package/tsconfig.json +0 -27
- package/types/inquirer/package.json +0 -6
- package/types/parse-types/package.json +0 -6
- /package/dist/{_internal/plugins/test.d.ts → lib/_internal/plugins/table/types/rows.js} +0 -0
- /package/dist/{_internal/types/inquirer.js → lib/_internal/plugins/table/types/table.js} +0 -0
- /package/dist/{modules → lib/modules}/types/inquirer.js +0 -0
- /package/dist/{modules → lib/modules}/types/parse-types.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-types.d.ts","sourceRoot":"","sources":["../../../../src/lib/_internal/types/parse-types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;EAIb,CAAA;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ExtractedAnsiText } from './chalk.js'
|
|
2
|
+
export type PageSize = number | null
|
|
3
|
+
export interface Paginator {
|
|
4
|
+
indexFrom: number
|
|
5
|
+
indexTo: number | null
|
|
6
|
+
}
|
|
7
|
+
export interface PointerIndexes {
|
|
8
|
+
row: number
|
|
9
|
+
column: number
|
|
10
|
+
}
|
|
11
|
+
export type Cell = number | string | boolean
|
|
12
|
+
export type Rows = Cell[][]
|
|
13
|
+
export type ExtractedRow = ExtractedAnsiText
|
|
14
|
+
export type ExtractedRows = ExtractedAnsiText[][]
|
|
15
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/lib/_internal/types/table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEnD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAA;AAEpC,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAC5C,MAAM,MAAM,IAAI,GAAG,IAAI,EAAE,EAAE,CAAA;AAE3B,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAAA;AAC5C,MAAM,MAAM,aAAa,GAAG,iBAAiB,EAAE,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ExtractedAnsiText } from '../types/chalk.js'
|
|
2
|
+
export declare const trim: (txt: string) => string
|
|
3
|
+
export declare const extractAnsiWrapper: (val: number | string | boolean) => ExtractedAnsiText
|
|
4
|
+
export declare const success: import('chalk').ChalkInstance
|
|
5
|
+
export declare const warn: import('chalk').ChalkInstance
|
|
6
|
+
export declare const info: import('chalk').ChalkInstance
|
|
7
|
+
export declare const error: import('chalk').ChalkInstance
|
|
8
|
+
export declare const hop: import('chalk').ChalkInstance
|
|
9
|
+
export declare const cyan: import('chalk').ChalkInstance
|
|
10
|
+
export declare const bold: import('chalk').ChalkInstance
|
|
11
|
+
export declare const dim: import('chalk').ChalkInstance
|
|
12
|
+
//# sourceMappingURL=chalk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chalk.d.ts","sourceRoot":"","sources":["../../../../src/lib/_internal/utils/chalk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAGnD,eAAO,MAAM,IAAI,QAAS,MAAM,WAAyC,CAAA;AAEzE,eAAO,MAAM,kBAAkB,QAAS,MAAM,GAAG,MAAM,GAAG,OAAO,KAAG,iBAkBnE,CAAA;AAED,eAAO,MAAM,OAAO,+BAAc,CAAA;AAClC,eAAO,MAAM,IAAI,+BAAuB,CAAA;AACxC,eAAO,MAAM,IAAI,+BAAuB,CAAA;AACxC,eAAO,MAAM,KAAK,+BAAY,CAAA;AAC9B,eAAO,MAAM,GAAG,+BAAuB,CAAA;AACvC,eAAO,MAAM,IAAI,+BAAa,CAAA;AAC9B,eAAO,MAAM,IAAI,+BAAa,CAAA;AAC9B,eAAO,MAAM,GAAG,+BAAY,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
// eslint-disable-next-line no-control-regex
|
|
3
|
+
export const trim = (txt) => txt.replace(/\u001b\[[0-9;]*m/g, '');
|
|
4
|
+
export const extractAnsiWrapper = (val) => {
|
|
5
|
+
const txt = `${val}`;
|
|
6
|
+
const raw = trim(txt);
|
|
7
|
+
// eslint-disable-next-line no-control-regex
|
|
8
|
+
const match = txt.match(/^(\u001b\[[0-9;]*m)(.*?)(\u001b\[39m)?$/s);
|
|
9
|
+
if (!match) {
|
|
10
|
+
return {
|
|
11
|
+
text: raw,
|
|
12
|
+
attach: (v) => v,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const prefix = match[1];
|
|
16
|
+
const suffix = match[3] || '\u001b[39m';
|
|
17
|
+
return {
|
|
18
|
+
text: raw,
|
|
19
|
+
attach: (v) => `${prefix}${v}${suffix}`,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export const success = chalk.green;
|
|
23
|
+
export const warn = chalk.hex('#FFA500');
|
|
24
|
+
export const info = chalk.hex('#77CFF5');
|
|
25
|
+
export const error = chalk.red;
|
|
26
|
+
export const hop = chalk.hex('#F577F5');
|
|
27
|
+
export const cyan = chalk.cyan;
|
|
28
|
+
export const bold = chalk.bold;
|
|
29
|
+
export const dim = chalk.dim;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../../../../src/lib/_internal/utils/columns.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,cAAc,SACnB,MAAM,gBACE,MAAM,YACV,MAAM,yBACM,MAAM,EAAE,WAU/B,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const isValidColumnIndex = (index, maxIndex, disableIndexes) => {
|
|
2
|
+
if (index > maxIndex || index < 0) {
|
|
3
|
+
return false
|
|
4
|
+
}
|
|
5
|
+
if (disableIndexes.includes(index)) {
|
|
6
|
+
return false
|
|
7
|
+
}
|
|
8
|
+
return true
|
|
9
|
+
}
|
|
10
|
+
const getNextIndex = (index, maxIndex, num) => {
|
|
11
|
+
if (index + num > maxIndex) {
|
|
12
|
+
return 0
|
|
13
|
+
}
|
|
14
|
+
if (index + num < 0) {
|
|
15
|
+
return maxIndex
|
|
16
|
+
}
|
|
17
|
+
return index + num
|
|
18
|
+
}
|
|
19
|
+
export const getColumnIndex = (diff, currentIndex, maxIndex, disableColumnIndexes = []) => {
|
|
20
|
+
let index = currentIndex
|
|
21
|
+
for (let i = 0; i <= maxIndex; i++) {
|
|
22
|
+
index = getNextIndex(index, maxIndex, diff)
|
|
23
|
+
if (isValidColumnIndex(index, maxIndex, disableColumnIndexes)) {
|
|
24
|
+
break
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return index
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/lib/_internal/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAGtC,eAAO,MAAM,MAAM,UAAW,IAAI,KAAG,OAA6C,CAAA;AAClF,eAAO,MAAM,WAAW,SAAU,IAAI,WAA8D,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Key } from 'readline'
|
|
2
|
+
export declare const getKeypressValue: (key: Key) => string
|
|
3
|
+
export declare const getBackspaceText: (str: string) => string
|
|
4
|
+
export declare const isUpKey: (key: Key) => boolean
|
|
5
|
+
export declare const isDownKey: (key: Key) => boolean
|
|
6
|
+
export declare const isLeftKey: (key: Key) => boolean
|
|
7
|
+
export declare const isRightKey: (key: Key) => boolean
|
|
8
|
+
export declare const isEscapeKey: (key: Key) => boolean
|
|
9
|
+
export declare const isSpaceKey: (key: Key) => boolean
|
|
10
|
+
export declare const isDeleteKey: (key: Key) => boolean
|
|
11
|
+
export declare const isBackspaceKey: (key: Key) => boolean
|
|
12
|
+
//# sourceMappingURL=keypress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keypress.d.ts","sourceRoot":"","sources":["../../../../src/lib/_internal/utils/keypress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,eAAO,MAAM,gBAAgB,QAAS,GAAG,WAaxC,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAS,MAAM,WAK3C,CAAA;AAED,eAAO,MAAM,OAAO,QAAS,GAAG,YAAsB,CAAA;AACtD,eAAO,MAAM,SAAS,QAAS,GAAG,YAAwB,CAAA;AAC1D,eAAO,MAAM,SAAS,QAAS,GAAG,YAAwB,CAAA;AAC1D,eAAO,MAAM,UAAU,QAAS,GAAG,YAAyB,CAAA;AAC5D,eAAO,MAAM,WAAW,QAAS,GAAG,YAA0B,CAAA;AAC9D,eAAO,MAAM,UAAU,QAAS,GAAG,YAAyB,CAAA;AAC5D,eAAO,MAAM,WAAW,QAAS,GAAG,YAA0B,CAAA;AAC9D,eAAO,MAAM,cAAc,QAAS,GAAG,YAA6B,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const getKeypressValue = key => {
|
|
2
|
+
switch (key.name) {
|
|
3
|
+
case 'escape':
|
|
4
|
+
case 'delete':
|
|
5
|
+
case 'backspace':
|
|
6
|
+
case 'down':
|
|
7
|
+
case 'up':
|
|
8
|
+
case 'left':
|
|
9
|
+
case 'right':
|
|
10
|
+
return ''
|
|
11
|
+
default:
|
|
12
|
+
return key.sequence || ''
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export const getBackspaceText = str => {
|
|
16
|
+
if (!str) {
|
|
17
|
+
return ''
|
|
18
|
+
}
|
|
19
|
+
return str.slice(0, -1)
|
|
20
|
+
}
|
|
21
|
+
export const isUpKey = key => key.name === 'up'
|
|
22
|
+
export const isDownKey = key => key.name === 'down'
|
|
23
|
+
export const isLeftKey = key => key.name === 'left'
|
|
24
|
+
export const isRightKey = key => key.name === 'right'
|
|
25
|
+
export const isEscapeKey = key => key.name === 'escape'
|
|
26
|
+
export const isSpaceKey = key => key.name === 'space'
|
|
27
|
+
export const isDeleteKey = key => key.name === 'delete'
|
|
28
|
+
export const isBackspaceKey = key => key.name === 'backspace'
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ParseType } from '../types/parse-types.js'
|
|
2
|
+
export declare const parse: (value: string, type: ParseType) => string | number | boolean
|
|
3
|
+
export declare const parseView: (value: string, type: ParseType) => string | number | boolean
|
|
4
|
+
//# sourceMappingURL=parse-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-types.d.ts","sourceRoot":"","sources":["../../../../src/lib/_internal/utils/parse-types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAI9D,eAAO,MAAM,KAAK,UAAW,MAAM,QAAQ,SAAS,8BASnD,CAAA;AAED,eAAO,MAAM,SAAS,UAAW,MAAM,QAAQ,SAAS,8BASvD,CAAA"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { isNumber } from 'my-gadgetry/type-check'
|
|
2
|
-
|
|
3
|
-
import { PARSE_TYPES, ParseType } from '~types/parse-types.js'
|
|
4
|
-
|
|
2
|
+
import { PARSE_TYPES } from '../types/parse-types.js'
|
|
5
3
|
const BOOL_VALUES = Object.freeze(['Y', 'y', 'yes', 'YES', 'x', 'v', 'o', 'true'])
|
|
6
|
-
|
|
7
|
-
export const parse = (value: string, type: ParseType) => {
|
|
4
|
+
export const parse = (value, type) => {
|
|
8
5
|
switch (type) {
|
|
9
6
|
case PARSE_TYPES.number:
|
|
10
7
|
return isNumber(value, true) ? Number(value) : 0
|
|
@@ -14,8 +11,7 @@ export const parse = (value: string, type: ParseType) => {
|
|
|
14
11
|
return value
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
export const parseView = (value: string, type: ParseType) => {
|
|
14
|
+
export const parseView = (value, type) => {
|
|
19
15
|
switch (type) {
|
|
20
16
|
case PARSE_TYPES.number:
|
|
21
17
|
return value ? Number(value) : 0
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Key } from 'readline'
|
|
2
|
+
import { PageSize, Paginator, PointerIndexes } from '../../types/table.js'
|
|
3
|
+
import { SetUseState } from '../../types/inquirer.js'
|
|
4
|
+
export declare const onArrowKeyPress: (
|
|
5
|
+
key: Key,
|
|
6
|
+
pointerIndexes: PointerIndexes,
|
|
7
|
+
setPointer: SetUseState<PointerIndexes>,
|
|
8
|
+
setPaginator: SetUseState<Paginator>,
|
|
9
|
+
pageSize: PageSize,
|
|
10
|
+
maxColumnIndex: number,
|
|
11
|
+
maxRowIndex: number,
|
|
12
|
+
disableColumnIndexes: number[]
|
|
13
|
+
) => void
|
|
14
|
+
//# sourceMappingURL=arrow-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-key.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_internal/utils/table/arrow-key.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,eAAO,MAAM,eAAe,QACrB,GAAG,kBACQ,cAAc,cAClB,WAAW,CAAC,cAAc,CAAC,gBACzB,WAAW,CAAC,SAAS,CAAC,YAC1B,QAAQ,kBACF,MAAM,eACT,MAAM,wBACG,MAAM,EAAE,SAoB/B,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isDownKey, isLeftKey, isRightKey, isUpKey } from '../keypress.js';
|
|
2
|
+
import { getColumnIndex, isValidColumnIndex } from '../table/columns.js';
|
|
3
|
+
import { paginate } from '../table/pagenate.js';
|
|
4
|
+
export const onArrowKeyPress = (key, pointerIndexes, setPointer, setPaginator, pageSize, maxColumnIndex, maxRowIndex, disableColumnIndexes) => {
|
|
5
|
+
let column = pointerIndexes.column;
|
|
6
|
+
let row = pointerIndexes.row;
|
|
7
|
+
if (isUpKey(key) || isDownKey(key)) {
|
|
8
|
+
row = isUpKey(key) ? Math.max(0, pointerIndexes.row - 1) : Math.min(maxRowIndex, pointerIndexes.row + 1);
|
|
9
|
+
if (!isValidColumnIndex(pointerIndexes.column, maxColumnIndex, disableColumnIndexes)) {
|
|
10
|
+
column = getColumnIndex(1, pointerIndexes.column, maxColumnIndex, disableColumnIndexes);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
else if (isRightKey(key) || isLeftKey(key)) {
|
|
14
|
+
column = getColumnIndex(isRightKey(key) ? 1 : -1, pointerIndexes.column, maxColumnIndex, disableColumnIndexes);
|
|
15
|
+
}
|
|
16
|
+
const pointer = {
|
|
17
|
+
column,
|
|
18
|
+
row,
|
|
19
|
+
};
|
|
20
|
+
setPointer(pointer);
|
|
21
|
+
if (pointerIndexes.row !== row) {
|
|
22
|
+
setPaginator(paginate(pointer, pageSize, maxRowIndex));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_internal/utils/table/cell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAErD,eAAO,MAAM,YAAY,gBAAiB,MAAM,YAAY,MAAM,QAAQ,aAAa,KAAG,IAKzF,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const isValidColumnIndex: (index: number, maxIndex: number, disableIndexes: number[]) => boolean;
|
|
2
|
+
export declare const getColumnIndex: (diff: number, currentIndex: number, maxIndex: number, disableColumnIndexes?: number[]) => number;
|
|
3
|
+
//# sourceMappingURL=columns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_internal/utils/table/columns.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,UAAW,MAAM,YAAY,MAAM,kBAAkB,MAAM,EAAE,YAQ3F,CAAA;AAaD,eAAO,MAAM,cAAc,SACnB,MAAM,gBACE,MAAM,YACV,MAAM,yBACM,MAAM,EAAE,WAU/B,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const isValidColumnIndex = (index, maxIndex, disableIndexes) => {
|
|
2
|
+
if (index > maxIndex || index < 0) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
if (disableIndexes.includes(index)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return true;
|
|
9
|
+
};
|
|
10
|
+
const getNextIndex = (index, maxIndex, num) => {
|
|
11
|
+
const nextIndex = index + num;
|
|
12
|
+
if (nextIndex > maxIndex) {
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
if (nextIndex < 0) {
|
|
16
|
+
return maxIndex;
|
|
17
|
+
}
|
|
18
|
+
return nextIndex;
|
|
19
|
+
};
|
|
20
|
+
export const getColumnIndex = (diff, currentIndex, maxIndex, disableColumnIndexes = []) => {
|
|
21
|
+
let index = currentIndex;
|
|
22
|
+
for (let i = 0; i <= maxIndex; i++) {
|
|
23
|
+
index = getNextIndex(index, maxIndex, diff);
|
|
24
|
+
if (isValidColumnIndex(index, maxIndex, disableColumnIndexes)) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return index;
|
|
29
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Paginator, PointerIndexes, PageSize } from '../../types/table.js'
|
|
2
|
+
export declare const getPageCount: (maxRowIndex: number, pageSize: PageSize) => number
|
|
3
|
+
export declare const paginate: (pointerIndexes: PointerIndexes, pageSize: PageSize, maxRowIndex: number) => Paginator
|
|
4
|
+
//# sourceMappingURL=pagenate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagenate.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_internal/utils/table/pagenate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAErE,eAAO,MAAM,YAAY,gBAAiB,MAAM,YAAY,QAAQ,WAKnE,CAAA;AAED,eAAO,MAAM,QAAQ,mBAAoB,cAAc,YAAY,QAAQ,eAAe,MAAM,KAAG,SAalG,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const getPageCount = (maxRowIndex, pageSize) => {
|
|
2
|
+
if (!pageSize) {
|
|
3
|
+
return 1;
|
|
4
|
+
}
|
|
5
|
+
return Math.ceil((maxRowIndex + 1) / pageSize);
|
|
6
|
+
};
|
|
7
|
+
export const paginate = (pointerIndexes, pageSize, maxRowIndex) => {
|
|
8
|
+
if (!pageSize) {
|
|
9
|
+
return {
|
|
10
|
+
indexFrom: 0,
|
|
11
|
+
indexTo: maxRowIndex,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const middleOfPage = Math.floor(pageSize / 2);
|
|
15
|
+
let indexFrom = Math.max(0, pointerIndexes.row - middleOfPage);
|
|
16
|
+
const maxPageSizeIndex = pageSize - 1;
|
|
17
|
+
const indexTo = Math.min(maxRowIndex, indexFrom + maxPageSizeIndex);
|
|
18
|
+
indexFrom = Math.min(indexFrom, indexTo - (pageSize - 1));
|
|
19
|
+
return { indexFrom, indexTo };
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../../../../src/lib/_internal/utils/table/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAGrD,eAAO,MAAM,oBAAoB,SAAU,IAAI,KAAG,aAEjD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/lib/modules/table.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../_internal/plugins/table.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chalk.d.ts","sourceRoot":"","sources":["../../../../src/lib/modules/types/chalk.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../_internal/types/chalk.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inquirer.d.ts","sourceRoot":"","sources":["../../../../src/lib/modules/types/inquirer.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-types.d.ts","sourceRoot":"","sources":["../../../../src/lib/modules/types/parse-types.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/lib/modules/types/table.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../_internal/types/table.js';
|
package/package.json
CHANGED
|
@@ -1,111 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inquirer-plugins",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "index.js",
|
|
3
|
+
"version": "1.0.1",
|
|
5
4
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/cilly-yllic/inquirer-plugins/issues"
|
|
12
|
-
},
|
|
13
|
-
"homepage": "https://github.com/cilly-yllic/inquirer-plugins#readme",
|
|
14
|
-
"scripts": {
|
|
15
|
-
"prepare": "husky",
|
|
16
|
-
"lint": "eslint .",
|
|
17
|
-
"lint:fix": "npm run lint -- --fix",
|
|
18
|
-
"_prettier": "prettier .",
|
|
19
|
-
"prettier:write": "npm run _prettier -- --write",
|
|
20
|
-
"prettier": "npm run prettier:write",
|
|
21
|
-
"prettier:check": "npm run _prettier -- --check",
|
|
22
|
-
"clean": "rimraf ./dist ./cli",
|
|
23
|
-
"tsc": "tsc -p tsconfig.publish.json && tsc-alias -p tsconfig.publish.json",
|
|
24
|
-
"generate": "tsx --tsconfig ./tsconfig.tsx.json ./tools/generate-alias.zx.ts",
|
|
25
|
-
"ci:update-version": "tsx --tsconfig ./tsconfig.tsx.json ./tools/update-version.zx.ts",
|
|
26
|
-
"md:generate": "tsx --tsconfig ./tsconfig.tsx.json ./tools/generate-md.ts",
|
|
27
|
-
|
|
28
|
-
"//--- test ---//": "",
|
|
29
|
-
"test": "run-s test:*",
|
|
30
|
-
"test:lint": "npm run lint",
|
|
31
|
-
"test:prettier": "npm run prettier:check",
|
|
32
|
-
|
|
33
|
-
"//--- build ---//": "",
|
|
34
|
-
"build": "run-s build:*",
|
|
35
|
-
"build:test": "npm run test",
|
|
36
|
-
"build:clean": "npm run clean",
|
|
37
|
-
"build:tsc": "npm run tsc",
|
|
38
|
-
"build:generate": "npm run generate",
|
|
39
|
-
|
|
40
|
-
"//--- publish ---//": "",
|
|
41
|
-
"publish:build": "run-s build:{clean,tsc,generate}",
|
|
42
|
-
"dry-run": "tsx --tsconfig ./tsconfig.tsx.json ./src/_internal/plugins/test.ts"
|
|
43
|
-
},
|
|
44
|
-
"author": "",
|
|
45
|
-
"license": "MIT",
|
|
46
|
-
"description": "",
|
|
47
|
-
"engines": {
|
|
48
|
-
"node": ">=19.0.0"
|
|
49
|
-
},
|
|
50
|
-
"keywords": [
|
|
51
|
-
"answer",
|
|
52
|
-
"answers",
|
|
53
|
-
"ask",
|
|
54
|
-
"confirm",
|
|
55
|
-
"generator",
|
|
56
|
-
"input",
|
|
57
|
-
"inquire",
|
|
58
|
-
"inquirer",
|
|
59
|
-
"prompt",
|
|
60
|
-
"prompts",
|
|
61
|
-
"table",
|
|
62
|
-
"question"
|
|
63
|
-
],
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
64
8
|
"exports": {
|
|
65
|
-
".": "./
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"cli-table3": "^0.6.5",
|
|
78
|
-
"inquirer": "^9.2.23",
|
|
79
|
-
"my-gadgetry": "^1.2.17",
|
|
80
|
-
"zx": "^8.1.2"
|
|
81
|
-
},
|
|
82
|
-
"devDependencies": {
|
|
83
|
-
"@eslint/js": "^8.57.0",
|
|
84
|
-
"@types/inquirer": "^9.0.7",
|
|
85
|
-
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
|
86
|
-
"@typescript-eslint/parser": "^7.9.0",
|
|
87
|
-
"eslint": "^8.57.0",
|
|
88
|
-
"eslint-config-prettier": "^9.1.0",
|
|
89
|
-
"eslint-import-resolver-typescript": "^3.6.1",
|
|
90
|
-
"eslint-plugin-import": "^2.29.1",
|
|
91
|
-
"eslint-plugin-jest": "^28.6.0",
|
|
92
|
-
"eslint-plugin-unused-imports": "^3.2.0",
|
|
93
|
-
"husky": "^9.0.11",
|
|
94
|
-
"lint-staged": "^15.2.6",
|
|
95
|
-
"npm-run-all2": "^6.2.0",
|
|
96
|
-
"prettier": "^3.3.2",
|
|
97
|
-
"tsc-alias": "^1.8.10",
|
|
98
|
-
"tsx": "^4.15.2",
|
|
99
|
-
"typescript": "^5.4.5",
|
|
100
|
-
"typescript-eslint": "^7.13.0"
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"development": "./src/index.ts",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./table": "./dist/lib/modules/table.js",
|
|
17
|
+
"./types/chalk": "./dist/lib/modules/types/chalk.js",
|
|
18
|
+
"./types/inquirer": "./dist/lib/modules/types/inquirer.js",
|
|
19
|
+
"./types/parse-types": "./dist/lib/modules/types/parse-types.js",
|
|
20
|
+
"./types/table": "./dist/lib/modules/types/table.js"
|
|
101
21
|
},
|
|
102
22
|
"files": [
|
|
103
|
-
"!**/__tests__",
|
|
104
23
|
"dist",
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
|
|
24
|
+
"!**/*.tsbuildinfo"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@inquirer/core": "^10.1.10",
|
|
28
|
+
"chalk": "^5.4.1",
|
|
29
|
+
"cli-cursor": "^5.0.0",
|
|
30
|
+
"cli-table3": "^0.6.5",
|
|
31
|
+
"figures": "^6.1.0",
|
|
32
|
+
"my-gadgetry": "1.3.6",
|
|
33
|
+
"tslib": "^2.3.0"
|
|
34
|
+
}
|
|
111
35
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 cilly
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Answers } from 'inquirer';
|
|
2
|
-
import { Column, Cell, RawInputs } from './types.js';
|
|
3
|
-
export declare class TableClass {
|
|
4
|
-
columns: Column[];
|
|
5
|
-
rows: string[][];
|
|
6
|
-
constructor(columns: Column[], rows: Cell[][]);
|
|
7
|
-
get header(): string[];
|
|
8
|
-
getColumnType(columnIndex: number): import("../../types/parse-types.js").ParseType;
|
|
9
|
-
getParser(columnIndex: number): Exclude<Column['parser'], undefined>;
|
|
10
|
-
getValidator(columnIndex: number): Exclude<Column['validate'], undefined>;
|
|
11
|
-
updateRow(rowIndex: number, columnIndex: number, value: string, answers: Answers): string;
|
|
12
|
-
getValue(rowIndex: number, columnIndex: number): string;
|
|
13
|
-
getRaw(): RawInputs;
|
|
14
|
-
getResult(answers: Answers): Record<string, Cell>[];
|
|
15
|
-
}
|