inquirer-plugins 1.0.0-alpha.7 → 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.
Files changed (120) hide show
  1. package/README.md +5 -34
  2. package/dist/lib/_internal/plugins/table/table.d.ts +2 -0
  3. package/dist/lib/_internal/plugins/table/table.d.ts.map +1 -0
  4. package/dist/lib/_internal/plugins/table/table.js +1 -0
  5. package/dist/lib/_internal/plugins/table/types/columns.d.ts +21 -0
  6. package/dist/lib/_internal/plugins/table/types/columns.d.ts.map +1 -0
  7. package/dist/lib/_internal/plugins/table/types/columns.js +2 -0
  8. package/dist/lib/_internal/plugins/table/types/common.d.ts +25 -0
  9. package/dist/lib/_internal/plugins/table/types/common.d.ts.map +1 -0
  10. package/dist/lib/_internal/plugins/table/types/common.js +5 -0
  11. package/dist/lib/_internal/plugins/table/types/rows.d.ts +2 -0
  12. package/dist/lib/_internal/plugins/table/types/rows.d.ts.map +1 -0
  13. package/dist/lib/_internal/plugins/table/types/table.d.ts +27 -0
  14. package/dist/lib/_internal/plugins/table/types/table.d.ts.map +1 -0
  15. package/dist/lib/_internal/plugins/table/types.d.ts +27 -0
  16. package/dist/lib/_internal/plugins/table/types.d.ts.map +1 -0
  17. package/dist/lib/_internal/plugins/table/types.js +24 -0
  18. package/dist/lib/_internal/plugins/table/utils.d.ts +25 -0
  19. package/dist/lib/_internal/plugins/table/utils.d.ts.map +1 -0
  20. package/dist/lib/_internal/plugins/table/utils.js +179 -0
  21. package/dist/lib/_internal/plugins/table.d.ts +11 -0
  22. package/dist/lib/_internal/plugins/table.d.ts.map +1 -0
  23. package/dist/lib/_internal/plugins/table.js +173 -0
  24. package/dist/lib/_internal/types/chalk.d.ts +7 -0
  25. package/dist/lib/_internal/types/chalk.d.ts.map +1 -0
  26. package/dist/lib/_internal/types/chalk.js +1 -0
  27. package/dist/lib/_internal/types/inquirer.d.ts +6 -0
  28. package/dist/lib/_internal/types/inquirer.d.ts.map +1 -0
  29. package/dist/lib/_internal/types/inquirer.js +5 -0
  30. package/dist/lib/_internal/types/parse-types.d.ts +7 -0
  31. package/dist/lib/_internal/types/parse-types.d.ts.map +1 -0
  32. package/{src/_internal/types/parse-types.ts → dist/lib/_internal/types/parse-types.js} +1 -3
  33. package/dist/lib/_internal/types/table.d.ts +15 -0
  34. package/dist/lib/_internal/types/table.d.ts.map +1 -0
  35. package/dist/lib/_internal/types/table.js +1 -0
  36. package/dist/lib/_internal/utils/chalk.d.ts +12 -0
  37. package/dist/lib/_internal/utils/chalk.d.ts.map +1 -0
  38. package/dist/lib/_internal/utils/chalk.js +29 -0
  39. package/dist/lib/_internal/utils/columns.d.ts +7 -0
  40. package/dist/lib/_internal/utils/columns.d.ts.map +1 -0
  41. package/dist/lib/_internal/utils/columns.js +28 -0
  42. package/dist/lib/_internal/utils/common.d.ts +4 -0
  43. package/dist/lib/_internal/utils/common.d.ts.map +1 -0
  44. package/dist/lib/_internal/utils/common.js +3 -0
  45. package/dist/lib/_internal/utils/keypress.d.ts +12 -0
  46. package/dist/lib/_internal/utils/keypress.d.ts.map +1 -0
  47. package/dist/lib/_internal/utils/keypress.js +28 -0
  48. package/dist/lib/_internal/utils/parse-types.d.ts +4 -0
  49. package/dist/lib/_internal/utils/parse-types.d.ts.map +1 -0
  50. package/{src/_internal/utils/parse-types.ts → dist/lib/_internal/utils/parse-types.js} +3 -7
  51. package/dist/lib/_internal/utils/table/arrow-key.d.ts +14 -0
  52. package/dist/lib/_internal/utils/table/arrow-key.d.ts.map +1 -0
  53. package/dist/lib/_internal/utils/table/arrow-key.js +24 -0
  54. package/dist/lib/_internal/utils/table/cell.d.ts +3 -0
  55. package/dist/lib/_internal/utils/table/cell.d.ts.map +1 -0
  56. package/dist/lib/_internal/utils/table/cell.js +6 -0
  57. package/dist/lib/_internal/utils/table/columns.d.ts +3 -0
  58. package/dist/lib/_internal/utils/table/columns.d.ts.map +1 -0
  59. package/dist/lib/_internal/utils/table/columns.js +29 -0
  60. package/dist/lib/_internal/utils/table/pagenate.d.ts +4 -0
  61. package/dist/lib/_internal/utils/table/pagenate.d.ts.map +1 -0
  62. package/dist/lib/_internal/utils/table/pagenate.js +20 -0
  63. package/dist/lib/_internal/utils/table/rows.d.ts +3 -0
  64. package/dist/lib/_internal/utils/table/rows.d.ts.map +1 -0
  65. package/dist/lib/_internal/utils/table/rows.js +4 -0
  66. package/dist/lib/modules/table.d.ts +2 -0
  67. package/dist/lib/modules/table.d.ts.map +1 -0
  68. package/dist/lib/modules/table.js +1 -0
  69. package/dist/lib/modules/types/chalk.d.ts +2 -0
  70. package/dist/lib/modules/types/chalk.d.ts.map +1 -0
  71. package/dist/lib/modules/types/chalk.js +1 -0
  72. package/dist/{modules → lib/modules}/types/inquirer.d.ts +1 -0
  73. package/dist/lib/modules/types/inquirer.d.ts.map +1 -0
  74. package/dist/{modules → lib/modules}/types/parse-types.d.ts +1 -0
  75. package/dist/lib/modules/types/parse-types.d.ts.map +1 -0
  76. package/dist/lib/modules/types/table.d.ts +2 -0
  77. package/dist/lib/modules/types/table.d.ts.map +1 -0
  78. package/dist/lib/modules/types/table.js +1 -0
  79. package/package.json +27 -103
  80. package/LICENSE +0 -21
  81. package/dist/_internal/plugins/table/table.d.ts +0 -15
  82. package/dist/_internal/plugins/table/table.js +0 -77
  83. package/dist/_internal/plugins/table/types.d.ts +0 -47
  84. package/dist/_internal/plugins/table/types.js +0 -23
  85. package/dist/_internal/plugins/table/utils.d.ts +0 -3
  86. package/dist/_internal/plugins/table/utils.js +0 -22
  87. package/dist/_internal/plugins/table.d.ts +0 -49
  88. package/dist/_internal/plugins/table.js +0 -263
  89. package/dist/_internal/plugins/test.js +0 -50
  90. package/dist/_internal/types/inquirer.d.ts +0 -1
  91. package/dist/_internal/types/parse-types.d.ts +0 -6
  92. package/dist/_internal/types/parse-types.js +0 -5
  93. package/dist/_internal/utils/chalk.d.ts +0 -9
  94. package/dist/_internal/utils/chalk.js +0 -10
  95. package/dist/_internal/utils/keypress.d.ts +0 -4
  96. package/dist/_internal/utils/keypress.js +0 -20
  97. package/dist/_internal/utils/parse-types.d.ts +0 -3
  98. package/dist/_internal/utils/parse-types.js +0 -23
  99. package/dist/modules/table.d.ts +0 -2
  100. package/dist/modules/table.js +0 -2
  101. package/src/_internal/plugins/table/README.md +0 -117
  102. package/src/_internal/plugins/table/table.ts +0 -93
  103. package/src/_internal/plugins/table/types.ts +0 -74
  104. package/src/_internal/plugins/table/utils.ts +0 -25
  105. package/src/_internal/plugins/table.ts +0 -305
  106. package/src/_internal/plugins/test.ts +0 -76
  107. package/src/_internal/types/inquirer.ts +0 -1
  108. package/src/_internal/utils/chalk.ts +0 -13
  109. package/src/_internal/utils/keypress.ts +0 -23
  110. package/src/modules/table.ts +0 -2
  111. package/src/modules/types/inquirer.ts +0 -1
  112. package/src/modules/types/parse-types.ts +0 -1
  113. package/table/package.json +0 -6
  114. package/tsconfig.json +0 -27
  115. package/types/inquirer/package.json +0 -6
  116. package/types/parse-types/package.json +0 -6
  117. /package/dist/{_internal/plugins/test.d.ts → lib/_internal/plugins/table/types/rows.js} +0 -0
  118. /package/dist/{_internal/types/inquirer.js → lib/_internal/plugins/table/types/table.js} +0 -0
  119. /package/dist/{modules → lib/modules}/types/inquirer.js +0 -0
  120. /package/dist/{modules → lib/modules}/types/parse-types.js +0 -0
@@ -0,0 +1,5 @@
1
+ export const STATUSES = Object.freeze({
2
+ loading: 'loading',
3
+ idle: 'idle',
4
+ done: 'done',
5
+ });
@@ -0,0 +1,7 @@
1
+ export declare const PARSE_TYPES: Readonly<{
2
+ readonly input: 'input'
3
+ readonly number: 'number'
4
+ readonly confirm: 'confirm'
5
+ }>
6
+ export type ParseType = (typeof PARSE_TYPES)[keyof typeof PARSE_TYPES]
7
+ //# sourceMappingURL=parse-types.d.ts.map
@@ -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"}
@@ -2,6 +2,4 @@ export const PARSE_TYPES = Object.freeze({
2
2
  input: 'input',
3
3
  number: 'number',
4
4
  confirm: 'confirm',
5
- } as const)
6
-
7
- export type ParseType = (typeof PARSE_TYPES)[keyof typeof PARSE_TYPES]
5
+ })
@@ -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,7 @@
1
+ export declare const getColumnIndex: (
2
+ diff: number,
3
+ currentIndex: number,
4
+ maxIndex: number,
5
+ disableColumnIndexes?: number[]
6
+ ) => number
7
+ //# sourceMappingURL=columns.d.ts.map
@@ -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,4 @@
1
+ import { Cell } from '../types/table.js'
2
+ export declare const isTrue: (value: Cell) => boolean
3
+ export declare const getCheckbox: (bool: Cell) => string
4
+ //# sourceMappingURL=common.d.ts.map
@@ -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,3 @@
1
+ import figures from 'figures';
2
+ export const isTrue = (value) => value === true || value === 'true';
3
+ export const getCheckbox = (bool) => (isTrue(bool) ? figures.checkboxOn : figures.checkboxOff);
@@ -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,3 @@
1
+ import { ExtractedRows, Cell } from '../../types/table.js'
2
+ export declare const getCellValue: (columnIndex: number, rowIndex: number, rows: ExtractedRows) => Cell
3
+ //# sourceMappingURL=cell.d.ts.map
@@ -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,6 @@
1
+ export const getCellValue = (columnIndex, rowIndex, rows) => {
2
+ if (rowIndex in rows && columnIndex in rows[rowIndex]) {
3
+ return rows[rowIndex][columnIndex].text || '';
4
+ }
5
+ return '';
6
+ };
@@ -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,3 @@
1
+ import { ExtractedRows, Rows } from '../../types/table.js'
2
+ export declare const getExtractedAnsiRows: (rows: Rows) => ExtractedRows
3
+ //# sourceMappingURL=rows.d.ts.map
@@ -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,4 @@
1
+ import { extractAnsiWrapper } from '../chalk.js';
2
+ export const getExtractedAnsiRows = (rows) => {
3
+ return rows.map(cells => cells.map(cell => extractAnsiWrapper(cell)));
4
+ };
@@ -0,0 +1,2 @@
1
+ export * from '../_internal/plugins/table.js'
2
+ //# sourceMappingURL=table.d.ts.map
@@ -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,2 @@
1
+ export * from '../../_internal/types/chalk.js';
2
+ //# sourceMappingURL=chalk.d.ts.map
@@ -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';
@@ -1 +1,2 @@
1
1
  export * from '../../_internal/types/inquirer.js';
2
+ //# sourceMappingURL=inquirer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inquirer.d.ts","sourceRoot":"","sources":["../../../../src/lib/modules/types/inquirer.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
@@ -1 +1,2 @@
1
1
  export * from '../../_internal/types/parse-types.js';
2
+ //# sourceMappingURL=parse-types.d.ts.map
@@ -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,2 @@
1
+ export * from '../../_internal/types/table.js';
2
+ //# sourceMappingURL=table.d.ts.map
@@ -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.0-alpha.7",
4
- "main": "index.js",
3
+ "version": "1.0.1",
5
4
  "type": "module",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/cilly-yllic/inquirer-plugins.git"
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
- ".": "./dist/**/*.js",
66
- "./table": "./dist/modules/table.js",
67
- "./types/inquirer": "./dist/modules/types/inquirer.js",
68
- "./types/parse-types": "./dist/modules/types/parse-types.js",
69
- "./package.json": "./package.json"
70
- },
71
- "dependencies": {
72
- "@actions/core": "^1.10.1",
73
- "@actions/exec": "^1.1.1",
74
- "@actions/github": "^6.0.0",
75
- "chalk": "^5.3.0",
76
- "cli-cursor": "^4.0.0",
77
- "cli-table3": "^0.6.5",
78
- "inquirer": "^9.2.23",
79
- "my-gadgetry": "^1.2.24",
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.7",
95
- "npm-run-all2": "^6.2.0",
96
- "prettier": "^3.3.2",
97
- "tsc-alias": "^1.8.10",
98
- "tsx": "^4.15.6",
99
- "typescript": "^5.4.5",
100
- "typescript-eslint": "^7.13.1"
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
- "types",
106
- "table",
107
- "src",
108
- "package.json",
109
- "tsconfig.json"
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
- }