260902f1a1758fa35a1157592b8376594332ec64e25c299b98730ba58e0bc135b9959753dcbd3e9d4fafb93260911511ab5b902c7e5f62fc23189b064a0ab6 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020
  1. import {isDefined} from './helpers/mixed';
  2. /**
  3. * @alias Options
  4. * @constructor
  5. * @description
  6. * ## Constructor options
  7. *
  8. * Constructor options are applied using an object literal passed as a second argument to the Handsontable constructor.
  9. *
  10. * ```js
  11. * var hot = new Handsontable(document.getElementById('example1'), {
  12. * data: myArray,
  13. * width: 400,
  14. * height: 300
  15. * });
  16. * ```
  17. *
  18. * ---
  19. * ## Cascading configuration
  20. *
  21. * Handsontable 0.9 and newer is using *Cascading Configuration*, which is a fast way to provide configuration options
  22. * for the entire table, including its columns and particular cells.
  23. *
  24. * Consider the following example:
  25. * ```js
  26. * var hot = new Handsontable(document.getElementById('example'), {
  27. * readOnly: true,
  28. * columns: [
  29. * {readOnly: false},
  30. * {},
  31. * {}
  32. * ],
  33. * cells: function (row, col, prop) {
  34. * var cellProperties = {};
  35. *
  36. * if (row === 0 && col === 0) {
  37. * cellProperties.readOnly = true;
  38. * }
  39. *
  40. * return cellProperties;
  41. * }
  42. * });
  43. * ```
  44. *
  45. * The above notation will result in all TDs being *read only*, except for first column TDs which will be *editable*, except for the TD in top left corner which will still be *read only*.
  46. *
  47. * ### The Cascading Configuration model
  48. *
  49. * ##### 1. Constructor
  50. *
  51. * Configuration options that are provided using first-level `handsontable(container, {option: "value"})` and `updateSettings` method.
  52. *
  53. * ##### 2. Columns
  54. *
  55. * Configuration options that are provided using second-level object `handsontable(container, {columns: {option: "value"}]})`
  56. *
  57. * ##### 3. Cells
  58. *
  59. * Configuration options that are provided using second-level function `handsontable(container, {cells: function: (row, col, prop){ }})`
  60. *
  61. * ---
  62. * ## Architecture performance
  63. *
  64. * The Cascading Configuration model is based on prototypical inheritance. It is much faster and memory efficient compared
  65. * to the previous model that used jQuery extend. See: [http://jsperf.com/extending-settings](http://jsperf.com/extending-settings).
  66. *
  67. * ---
  68. * __Important notice:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`.
  69. */
  70. function DefaultSettings() {};
  71. DefaultSettings.prototype = {
  72. /**
  73. * @description
  74. * Initial data source that will be bound to the data grid __by reference__ (editing data grid alters the data source).
  75. * Can be declared as an Array of Arrays, Array of Objects or a Function.
  76. *
  77. * See [Understanding binding as reference](http://docs.handsontable.com/tutorial-data-binding.html#page-reference).
  78. *
  79. * @type {Array|Function}
  80. * @default undefined
  81. */
  82. data: void 0,
  83. /**
  84. * @description
  85. * Defines the structure of a new row when data source is an array of objects.
  86. *
  87. * See [data-schema](http://docs.handsontable.com/tutorial-data-sources.html#page-data-schema) for examples.
  88. *
  89. * @type {Object}
  90. * @default undefined
  91. */
  92. dataSchema: void 0,
  93. /**
  94. * Width of the grid. Can be a value or a function that returns a value.
  95. *
  96. * @type {Number|Function}
  97. * @default undefined
  98. */
  99. width: void 0,
  100. /**
  101. * Height of the grid. Can be a number or a function that returns a number.
  102. *
  103. * @type {Number|Function}
  104. * @default undefined
  105. */
  106. height: void 0,
  107. /**
  108. * @description
  109. * Initial number of rows.
  110. *
  111. * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided
  112. *
  113. * @type {Number}
  114. * @default 5
  115. */
  116. startRows: 5,
  117. /**
  118. * @description
  119. * Initial number of columns.
  120. *
  121. * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided
  122. *
  123. * @type {Number}
  124. * @default 5
  125. */
  126. startCols: 5,
  127. /**
  128. * Setting `true` or `false` will enable or disable the default row headers (1, 2, 3).
  129. * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers.
  130. * If a function is set the index of the row is passed as a parameter.
  131. *
  132. * @type {Boolean|Array|Function}
  133. * @default null
  134. * @example
  135. * ```js
  136. * ...
  137. * // as boolean
  138. * rowHeaders: true,
  139. * ...
  140. *
  141. * ...
  142. * // as array
  143. * rowHeaders: [1, 2, 3],
  144. * ...
  145. *
  146. * ...
  147. * // as function
  148. * rowHeaders: function(index) {
  149. * return index + ': AB';
  150. * },
  151. * ...
  152. * ```
  153. */
  154. rowHeaders: void 0,
  155. /**
  156. * Setting `true` or `false` will enable or disable the default column headers (A, B, C).
  157. * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers.
  158. * If a function is set, then the index of the column is passed as a parameter.
  159. *
  160. * @type {Boolean|Array|Function}
  161. * @default null
  162. * @example
  163. * ```js
  164. * ...
  165. * // as boolean
  166. * colHeaders: true,
  167. * ...
  168. *
  169. * ...
  170. * // as array
  171. * colHeaders: ['A', 'B', 'C'],
  172. * ...
  173. *
  174. * ...
  175. * // as function
  176. * colHeaders: function(index) {
  177. * return index + ': AB';
  178. * },
  179. * ...
  180. * ```
  181. */
  182. colHeaders: null,
  183. /**
  184. * Defines column widths in pixels. Accepts number, string (that will be converted to a number),
  185. * array of numbers (if you want to define column width separately for each column) or a
  186. * function (if you want to set column width dynamically on each render).
  187. *
  188. * @type {Array|Function|Number|String}
  189. * @default undefined
  190. */
  191. colWidths: void 0,
  192. /**
  193. * Defines row heights in pixels. Accepts numbers, strings (that will be converted into a number),
  194. * array of numbers (if you want to define row height separately for each row) or a
  195. * function (if you want to set row height dynamically on each render).
  196. *
  197. * @type {Array|Function|Number|String}
  198. * @default undefined
  199. */
  200. rowHeights: void 0,
  201. /**
  202. * @description
  203. * Defines the cell properties and data binding for certain columns.
  204. *
  205. * __Notice:__ Using this option sets a fixed number of columns (options `startCols`, `minCols`, `maxCols` will be ignored).
  206. *
  207. * See [documentation -> datasources.html](http://docs.handsontable.com/tutorial-data-sources.html#page-nested) for examples.
  208. *
  209. * @type {Array}
  210. * @default undefined
  211. * @example
  212. * ```js
  213. * ...
  214. * columns: [
  215. * {
  216. * // column options for the first column
  217. * type: 'numeric',
  218. * format: '0,0.00 $'
  219. * },
  220. * {
  221. * // column options for the second column
  222. * type: 'text',
  223. * readOnly: true
  224. * }
  225. * ],
  226. * ...
  227. * ```
  228. */
  229. columns: void 0,
  230. /**
  231. * @description
  232. * Defines the cell properties for given `row`, `col`, `prop` coordinates.
  233. * Any constructor or column option may be overwritten for a particular cell (row/column combination)
  234. * using the `cells` property in the Handsontable constructor.
  235. *
  236. * __Note:__ Parameters `row` and `col` always represent __physical indexes__. Example below show how to execute
  237. * operations based on the __visual__ representation of Handsontable.
  238. *
  239. * @type {Function}
  240. * @default undefined
  241. * @example
  242. * ```js
  243. * ...
  244. * cells: function (row, col, prop) {
  245. * var cellProperties = {};
  246. * var visualRowIndex = this.instance.toVisualRow(row);
  247. * var visualColIndex = this.instance.toVisualColumn(col);
  248. *
  249. * if (visualRowIndex === 0 && visualColIndex === 0) {
  250. * cellProperties.readOnly = true;
  251. * }
  252. *
  253. * return cellProperties;
  254. * },
  255. * ...
  256. * ```
  257. */
  258. cells: void 0,
  259. /**
  260. * Any constructor or column option may be overwritten for a particular cell (row/column combination), using `cell`
  261. * array passed to the Handsontable constructor.
  262. *
  263. * @type {Array}
  264. * @default []
  265. * @example
  266. * ```js
  267. * ...
  268. * cell: [
  269. * {row: 0, col: 0, readOnly: true}
  270. * ],
  271. * ...
  272. * ```
  273. */
  274. cell: [],
  275. /**
  276. * @description
  277. * If `true`, enables the {@link Comments} plugin, which enables an option to apply cell comments through the context menu
  278. * (configurable with context menu keys `commentsAddEdit`, `commentsRemove`).
  279. *
  280. * To initialize Handsontable with predefined comments, provide cell coordinates and comment text values in a form of an array.
  281. *
  282. * See [Comments](http://docs.handsontable.com/demo-comments_.html) demo for examples.
  283. *
  284. * @since 0.11.0
  285. * @type {Boolean|Array}
  286. * @default false
  287. * @example
  288. * ```js
  289. * ...
  290. * comments: [{row: 1, col: 1, comment: {value: "Test comment"}}],
  291. * ...
  292. * ```
  293. */
  294. comments: false,
  295. /**
  296. * @description
  297. * If `true`, enables the Custom Borders plugin, which enables an option to apply custom borders through the context menu (configurable with context menu key `borders`).
  298. *
  299. * To initialize Handsontable with predefined custom borders, provide cell coordinates and border styles in a form of an array.
  300. *
  301. * See [Custom Borders](http://docs.handsontable.com/demo-custom-borders.html) demo for examples.
  302. *
  303. * @since 0.11.0
  304. * @type {Boolean|Array}
  305. * @default false
  306. * @example
  307. * ```js
  308. * ...
  309. * customBorders: [
  310. * {range: {
  311. * from: {row: 1, col: 1},
  312. * to: {row: 3, col: 4}},
  313. * left: {},
  314. * right: {},
  315. * top: {},
  316. * bottom: {}
  317. * }
  318. * ],
  319. * ...
  320. *
  321. * // or
  322. * ...
  323. * customBorders: [
  324. * {row: 2, col: 2, left: {width: 2, color: 'red'},
  325. * right: {width: 1, color: 'green'}, top: '', bottom: ''}
  326. * ],
  327. * ...
  328. * ```
  329. */
  330. customBorders: false,
  331. /**
  332. * Minimum number of rows. At least that number of rows will be created during initialization.
  333. *
  334. * @type {Number}
  335. * @default 0
  336. */
  337. minRows: 0,
  338. /**
  339. * Minimum number of columns. At least that number of columns will be created during initialization.
  340. *
  341. * @type {Number}
  342. * @default 0
  343. */
  344. minCols: 0,
  345. /**
  346. * Maximum number of rows. If set to a value lower than the initial row count, the data will be trimmed to the provided value as the number of rows.
  347. *
  348. * @type {Number}
  349. * @default Infinity
  350. */
  351. maxRows: Infinity,
  352. /**
  353. * Maximum number of cols. If set to a value lower than the initial col count, the data will be trimmed to the provided value as the number of cols.
  354. *
  355. * @type {Number}
  356. * @default Infinity
  357. */
  358. maxCols: Infinity,
  359. /**
  360. * When set to 1 (or more), Handsontable will add a new row at the end of grid if there are no more empty rows.
  361. * (unless the number of rows exceeds the one set in the `maxRows` property)
  362. *
  363. * @type {Number}
  364. * @default 0
  365. */
  366. minSpareRows: 0,
  367. /**
  368. * When set to 1 (or more), Handsontable will add a new column at the end of grid if there are no more empty columns.
  369. * (unless the number of rows exceeds the one set in the `maxCols` property)
  370. *
  371. * @type {Number}
  372. * @default 0
  373. */
  374. minSpareCols: 0,
  375. /**
  376. * If set to `false`, there won't be an option to insert new rows in the Context Menu.
  377. *
  378. * @type {Boolean}
  379. * @default true
  380. */
  381. allowInsertRow: true,
  382. /**
  383. * If set to `false`, there won't be an option to insert new columns in the Context Menu.
  384. *
  385. * @type {Boolean}
  386. * @default true
  387. */
  388. allowInsertColumn: true,
  389. /**
  390. * If set to `false`, there won't be an option to remove rows in the Context Menu.
  391. *
  392. * @type {Boolean}
  393. * @default true
  394. */
  395. allowRemoveRow: true,
  396. /**
  397. * If set to `false`, there won't be an option to remove columns in the Context Menu.
  398. *
  399. * @type {Boolean}
  400. * @default true
  401. */
  402. allowRemoveColumn: true,
  403. /**
  404. * If true, selection of multiple cells using keyboard or mouse is allowed.
  405. *
  406. * @type {Boolean}
  407. * @default true
  408. */
  409. multiSelect: true,
  410. /**
  411. * Enables the fill handle (drag-down and copy-down) functionality, which shows a small rectangle in bottom
  412. * right corner of the selected area, that let's you expand values to the adjacent cells.
  413. *
  414. * Possible values: `true` (to enable in all directions), `'vertical'` or `'horizontal'` (to enable in one direction),
  415. * `false` (to disable completely). Setting to `true` enables the fillHandle plugin.
  416. *
  417. * Since 0.23.0 you can pass object to plugin which allows you to add more options for this functionality. If `autoInsertRow`
  418. * option is `true`, fill-handler will create new rows till it reaches the last row. It is enabled by default.
  419. *
  420. * @example
  421. * ```js
  422. * ...
  423. * fillHandle: true // enable plugin in all directions and with autoInsertRow as true
  424. * ...
  425. * // or
  426. * ...
  427. * fillHandle: 'vertical' // enable plugin in vertical direction and with autoInsertRow as true
  428. * ...
  429. * // or
  430. * ...
  431. * fillHandle: { // enable plugin in both directions and with autoInsertRow as false
  432. * autoInsertRow: false,
  433. * }
  434. * // or
  435. * ...
  436. * fillHandle: { // enable plugin in vertical direction and with autoInsertRow as false
  437. * autoInsertRow: false,
  438. * direction: 'vertical' // 'vertical' or 'horizontal'
  439. * }
  440. * ```
  441. *
  442. * @type {Boolean|String|Object}
  443. * @default true
  444. */
  445. fillHandle: true,
  446. /**
  447. * Allows to specify the number of fixed (or *frozen*) rows at the top of the table.
  448. *
  449. * @type {Number}
  450. * @default 0
  451. * @example
  452. * ```js
  453. * fixedRowsTop: 3 // This would freeze the top 3 rows of the table.
  454. * ```
  455. */
  456. fixedRowsTop: 0,
  457. /**
  458. * Allows to specify the number of fixed (or *frozen*) rows at the bottom of the table.
  459. *
  460. * @pro
  461. * @type {Number}
  462. * @default 0
  463. * @example
  464. * ```js
  465. * fixedRowsBottom: 3 // This would freeze the top 3 rows of the table.
  466. * ```
  467. */
  468. fixedRowsBottom: 0,
  469. /**
  470. * Allows to specify the number of fixed (or *frozen*) columns on the left of the table.
  471. *
  472. * @type {Number}
  473. * @default 0
  474. * @example
  475. * ```js
  476. * fixedColumnsLeft: 3 // This would freeze the top 3 rows of the table.
  477. * ```
  478. */
  479. fixedColumnsLeft: 0,
  480. /**
  481. * If `true`, mouse click outside the grid will deselect the current selection.
  482. * Can be a function that takes the click event target and returns a boolean.
  483. *
  484. * @type {Boolean|Function}
  485. * @default true
  486. */
  487. outsideClickDeselects: true,
  488. /**
  489. * If `true`, <kbd>ENTER</kbd> begins editing mode (like in Google Docs). If `false`, <kbd>ENTER</kbd> moves to next
  490. * row (like Excel) and adds a new row if necessary. <kbd>TAB</kbd> adds new column if necessary.
  491. *
  492. * @type {Boolean}
  493. * @default true
  494. */
  495. enterBeginsEditing: true,
  496. /**
  497. * Defines the cursor movement after <kbd>ENTER</kbd> was pressed (<kbd>SHIFT</kbd> + <kbd>ENTER</kbd> uses a negative vector).
  498. * Can be an object or a function that returns an object. The event argument passed to the function
  499. * is a DOM Event object received after the <kbd>ENTER</kbd> key has been pressed. This event object can be used to check
  500. * whether user pressed <kbd>ENTER</kbd> or <kbd>SHIFT</kbd> + <kbd>ENTER</kbd>.
  501. *
  502. * @type {Object|Function}
  503. * @default {row: 1, col: 0}
  504. */
  505. enterMoves: {row: 1, col: 0},
  506. /**
  507. * Defines the cursor movement after <kbd>TAB</kbd> is pressed (<kbd>SHIFT</kbd> + <kbd>TAB</kbd> uses a negative vector).
  508. * Can be an object or a function that returns an object. The event argument passed to the function
  509. * is a DOM Event object received after the <kbd>TAB</kbd> key has been pressed. This event object can be used to check
  510. * whether user pressed <kbd>TAB</kbd> or <kbd>SHIFT</kbd> + <kbd>TAB</kbd>.
  511. *
  512. * @type {Object}
  513. * @default {row: 0, col: 1}
  514. */
  515. tabMoves: {row: 0, col: 1},
  516. /**
  517. * If `true`, pressing <kbd>TAB</kbd> or right arrow in the last column will move to first column in next row.
  518. *
  519. * @type {Boolean}
  520. * @default false
  521. */
  522. autoWrapRow: false,
  523. /**
  524. * If `true`, pressing <kbd>ENTER</kbd> or down arrow in the last row will move to the first row in the next column.
  525. *
  526. * @type {Boolean}
  527. * @default false
  528. */
  529. autoWrapCol: false,
  530. /**
  531. * Maximum number of rows than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>.
  532. *
  533. * @type {Number}
  534. * @default 1000
  535. */
  536. copyRowsLimit: 1000,
  537. /**
  538. * Maximum number of columns than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>.
  539. *
  540. * @type {Number}
  541. * @default 1000
  542. */
  543. copyColsLimit: 1000,
  544. /**
  545. * @description
  546. * Defines paste (<kbd>CTRL</kbd> + <kbd>V</kbd>) behavior.
  547. * * Default value `"overwrite"` will paste clipboard value over current selection.
  548. * * When set to `"shift_down"`, clipboard data will be pasted in place of current selection, while all selected cells are moved down.
  549. * * When set to `"shift_right"`, clipboard data will be pasted in place of current selection, while all selected cells are moved right.
  550. *
  551. * @type {String}
  552. * @default 'overwrite'
  553. */
  554. pasteMode: 'overwrite',
  555. /**
  556. * @description
  557. * Turns on saving the state of column sorting, column positions and column sizes in local storage.
  558. *
  559. * You can save any sort of data in local storage to preserve table state between page reloads.
  560. * In order to enable data storage mechanism, `persistentState` option must be set to `true` (you can set it
  561. * either during Handsontable initialization or using the `updateSettings` method). When `persistentState` is enabled it exposes 3 hooks:
  562. *
  563. * __persistentStateSave__ (key: String, value: Mixed)
  564. *
  565. * * Saves value under given key in browser local storage.
  566. *
  567. * __persistentStateLoad__ (key: String, valuePlaceholder: Object)
  568. *
  569. * * Loads `value`, saved under given key, form browser local storage. The loaded `value` will be saved in `valuePlaceholder.value`
  570. * (this is due to specific behaviour of `Hooks.run()` method). If no value have been saved under key `valuePlaceholder.value`
  571. * will be `undefined`.
  572. *
  573. * __persistentStateReset__ (key: String)
  574. *
  575. * * Clears the value saved under `key`. If no `key` is given, all values associated with table will be cleared.
  576. *
  577. * __Note:__ The main reason behind using `persistentState` hooks rather than regular LocalStorage API is that it
  578. * ensures separation of data stored by multiple Handsontable instances. In other words, if you have two (or more)
  579. * instances of Handsontable on one page, data saved by one instance won't be accessible by the second instance.
  580. * Those two instances can store data under the same key and no data would be overwritten.
  581. *
  582. * __Important:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`.
  583. *
  584. * @type {Boolean}
  585. * @default false
  586. */
  587. persistentState: void 0,
  588. /**
  589. * Class name for all visible rows in the current selection.
  590. *
  591. * @type {String}
  592. * @default undefined
  593. * @example
  594. * ```js
  595. * currentRowClassName: 'currentRow' // This will add a 'currentRow' class name to appropriate table cells.
  596. * ```
  597. */
  598. currentRowClassName: void 0,
  599. /**
  600. * Class name for all visible columns in the current selection.
  601. *
  602. * @type {String}
  603. * @default undefined
  604. * @example
  605. * ```js
  606. * currentColClassName: 'currentColumn' // This will add a 'currentColumn' class name to appropriate table cells.
  607. * ```
  608. */
  609. currentColClassName: void 0,
  610. /**
  611. * Class name for all visible headers in current selection.
  612. *
  613. * @type {String}
  614. * @since 0.27.0
  615. * @default 'ht__highlight'
  616. * @example
  617. * ```js
  618. * currentHeaderClassName: 'ht__highlight' // This will add a 'ht__highlight' class name to appropriate table headers.
  619. * ```
  620. */
  621. currentHeaderClassName: 'ht__highlight',
  622. /**
  623. * Class name for the Handsontable container element.
  624. *
  625. * @type {String|Array}
  626. * @default undefined
  627. */
  628. className: void 0,
  629. /**
  630. * Class name for all tables inside container element.
  631. *
  632. * @since 0.17.0
  633. * @type {String|Array}
  634. * @default undefined
  635. */
  636. tableClassName: void 0,
  637. /**
  638. * @description
  639. * Defines how the columns react, when the declared table width is different than the calculated sum of all column widths.
  640. * [See more](http://docs.handsontable.com/demo-stretching.html) mode. Possible values:
  641. * * `'none'` Disable stretching
  642. * * `'last'` Stretch only the last column
  643. * * `'all'` Stretch all the columns evenly
  644. *
  645. * @type {String}
  646. * @default 'none'
  647. */
  648. stretchH: 'none',
  649. /**
  650. * Lets you overwrite the default `isEmptyRow` method, which checks if row at the provided index is empty.
  651. *
  652. * @type {Function}
  653. * @param {Number} row
  654. * @returns {Boolean}
  655. */
  656. isEmptyRow(row) {
  657. var col,
  658. colLen,
  659. value,
  660. meta;
  661. for (col = 0, colLen = this.countCols(); col < colLen; col++) {
  662. value = this.getDataAtCell(row, col);
  663. if (value !== '' && value !== null && isDefined(value)) {
  664. if (typeof value === 'object') {
  665. meta = this.getCellMeta(row, col);
  666. return isObjectEquals(this.getSchema()[meta.prop], value);
  667. }
  668. return false;
  669. }
  670. }
  671. return true;
  672. },
  673. /**
  674. * Lets you overwrite the default `isEmptyCol` method, which checks if column at the provided index is empty.
  675. *
  676. * @type {Function}
  677. * @param {Number} col
  678. * @returns {Boolean}
  679. */
  680. isEmptyCol(col) {
  681. var row,
  682. rowLen,
  683. value;
  684. for (row = 0, rowLen = this.countRows(); row < rowLen; row++) {
  685. value = this.getDataAtCell(row, col);
  686. if (value !== '' && value !== null && isDefined(value)) {
  687. return false;
  688. }
  689. }
  690. return true;
  691. },
  692. /**
  693. * When set to `true`, the table is re-rendered when it is detected that it was made visible in DOM.
  694. *
  695. * @type {Boolean}
  696. * @default true
  697. */
  698. observeDOMVisibility: true,
  699. /**
  700. * If set to `true`, Handsontable will accept values that were marked as invalid by the cell `validator`.
  701. * It will result with *invalid* cells being treated as *valid* (will save the *invalid* value into the Handsontable data source).
  702. * If set to `false`, Handsontable will *not* accept the invalid values and won't allow the user to close the editor.
  703. * This option will be particularly useful when used with the Autocomplete's `strict` mode.
  704. *
  705. * @type {Boolean}
  706. * @default true
  707. * @since 0.9.5
  708. */
  709. allowInvalid: true,
  710. /**
  711. * If set to `true`, Handsontable will accept values that are empty (`null`, `undefined` or `''`).
  712. * If set to `false`, Handsontable will *not* accept the empty values and mark cell as invalid.
  713. *
  714. * @example
  715. * ```js
  716. * ...
  717. * allowEmpty: true // allow empty values for all cells (whole table)
  718. * ...
  719. * // or
  720. * ...
  721. * columns: [
  722. * // allow empty values only for 'date' column
  723. * {data: 'date', dateFormat: 'DD/MM/YYYY', allowEmpty: true}
  724. * ]
  725. * ...
  726. * ```
  727. *
  728. * @type {Boolean}
  729. * @default true
  730. * @since 0.23.0
  731. */
  732. allowEmpty: true,
  733. /**
  734. * CSS class name for cells that did not pass validation.
  735. *
  736. * @type {String}
  737. * @default 'htInvalid'
  738. */
  739. invalidCellClassName: 'htInvalid',
  740. /**
  741. * When set to an non-empty string, displayed as the cell content for empty cells. If a value of a different type is provided,
  742. * it will be stringified and applied as a string.
  743. *
  744. * @type {Mixed}
  745. * @default false
  746. */
  747. placeholder: false,
  748. /**
  749. * CSS class name for cells that have a placeholder in use.
  750. *
  751. * @type {String}
  752. * @default 'htPlaceholder'
  753. */
  754. placeholderCellClassName: 'htPlaceholder',
  755. /**
  756. * CSS class name for read-only cells.
  757. *
  758. * @type {String}
  759. * @default 'htDimmed'
  760. */
  761. readOnlyCellClassName: 'htDimmed',
  762. /**
  763. * @description
  764. * If a string is provided, it may be one of the following predefined values:
  765. * * `autocomplete`,
  766. * * `checkbox`,
  767. * * `html`,
  768. * * `numeric`,
  769. * * `password`.
  770. * * `text`.
  771. *
  772. * Or you can [register](http://docs.handsontable.com/demo-custom-renderers.html) the custom renderer under specified name and use
  773. * its name as an alias in your configuration.
  774. *
  775. * If a function is provided, it will receive the following arguments:
  776. * ```js
  777. * function(instance, TD, row, col, prop, value, cellProperties) {}
  778. * ```
  779. *
  780. * You can read more about custom renderes [in the documentation](http://docs.handsontable.com/demo-custom-renderers.html).
  781. *
  782. * @example
  783. * ```js
  784. * ...
  785. * Handsontable.renderers.registerRenderer('my.renderer', function(instance, TD, row, col, prop, value, cellProperties) {
  786. * TD.innerHTML = value;
  787. * });
  788. * ...
  789. * columns: [
  790. * {
  791. * editor: 'select',
  792. * renderer: 'autocomplete' // as string
  793. * },
  794. * {
  795. * renderer: 'my.renderer' // custom renderer as an alias
  796. * },
  797. * {
  798. * // renderer as custom function
  799. * renderer: function(hotInstance, TD, row, col, prop, value, cellProperties) {
  800. * TD.style.color = 'blue';
  801. * TD.innerHTML = value;
  802. * }
  803. * }
  804. * ]
  805. * ...
  806. * ```
  807. *
  808. * @type {String|Function}
  809. * @default undefined
  810. */
  811. renderer: void 0,
  812. /**
  813. * CSS class name added to the commented cells.
  814. *
  815. * @type {String}
  816. * @default 'htCommentCell'
  817. */
  818. commentedCellClassName: 'htCommentCell',
  819. /**
  820. * If set to `true`, it enables the browser's native selection of a fragment of the text within a single cell, between adjacent cells or in a whole table.
  821. * If set to `'cell'`, it enables the possibility of selecting a fragment of the text within a single cell's body.
  822. *
  823. * @type {Boolean|String}
  824. * @default false
  825. */
  826. fragmentSelection: false,
  827. /**
  828. * @description
  829. * Make cell [read only](http://docs.handsontable.com/demo-read-only.html).
  830. *
  831. * @type {Boolean}
  832. * @default false
  833. */
  834. readOnly: false,
  835. /**
  836. * @description
  837. * When added to a `column` property, it skips the column on paste and pastes the data on the next column to the right.
  838. *
  839. * @type {Boolean}
  840. * @default false
  841. */
  842. skipColumnOnPaste: false,
  843. /**
  844. * @description
  845. * Setting to true enables the search plugin (see [demo](http://docs.handsontable.com/demo-search-for-values.html)).
  846. *
  847. * @type {Boolean}
  848. * @default false
  849. */
  850. search: false,
  851. /**
  852. * @description
  853. * Shortcut to define the combination of the cell renderer, editor and validator for the column, cell or whole table.
  854. *
  855. * Possible values:
  856. * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html)
  857. * * [checkbox](http://docs.handsontable.com/demo-checkbox.html)
  858. * * [date](http://docs.handsontable.com/demo-date.html)
  859. * * [dropdown](http://docs.handsontable.com/demo-dropdown.html)
  860. * * [handsontable](http://docs.handsontable.com/demo-handsontable.html)
  861. * * [numeric](http://docs.handsontable.com/demo-numeric.html)
  862. * * [password](http://docs.handsontable.com/demo-password.html)
  863. * * text
  864. * * [time](http://docs.handsontable.com/demo-time.html)
  865. *
  866. * Or you can register the custom cell type under specified name and use
  867. * its name as an alias in your configuration.
  868. *
  869. * @example
  870. * ```js
  871. * ...
  872. * Handsontable.cellTypes.registerCellType('my.type', {
  873. * editor: MyEditorClass,
  874. * renderer: function(hot, td, row, col, prop, value, cellProperties) {
  875. * td.innerHTML = value;
  876. * },
  877. * validator: function(value, callback) {
  878. * callback(value === 'foo' ? true : false);
  879. * }
  880. * });
  881. * ...
  882. * columns: [
  883. * {
  884. * type: 'text'
  885. * },
  886. * {
  887. * type: 'my.type' // an alias to custom type
  888. * },
  889. * {
  890. * type: 'checkbox'
  891. * }
  892. * ]
  893. * ...
  894. * ```
  895. *
  896. * @type {String}
  897. * @default 'text'
  898. */
  899. type: 'text',
  900. /**
  901. * @description
  902. * Make cell copyable (pressing <kbd>CTRL</kbd> + <kbd>C</kbd> on your keyboard moves its value to system clipboard).
  903. *
  904. * __Note:__ this setting is `false` by default for cells with type `password`.
  905. *
  906. * @type {Boolean}
  907. * @default true
  908. * @since 0.10.2
  909. */
  910. copyable: true,
  911. /**
  912. * Defines the editor for the table/column/cell.
  913. *
  914. * If a string is provided, it may be one of the following predefined values:
  915. * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html)
  916. * * [checkbox](http://docs.handsontable.com/demo-checkbox.html)
  917. * * [date](http://docs.handsontable.com/demo-date.html)
  918. * * [dropdown](http://docs.handsontable.com/demo-dropdown.html)
  919. * * [handsontable](http://docs.handsontable.com/demo-handsontable.html)
  920. * * [mobile](http://docs.handsontable.com/demo-mobiles-and-tablets.html)
  921. * * [password](http://docs.handsontable.com/demo-password.html)
  922. * * [select](http://docs.handsontable.com/demo-select.html)
  923. * * text
  924. *
  925. * Or you can [register](http://docs.handsontable.com/tutorial-cell-editor.html#registering-an-editor) the custom editor under specified name and use
  926. * its name as an alias in your configuration.
  927. *
  928. * To disable cell editing completely set `editor` property to `false`.
  929. *
  930. * @example
  931. * ```js
  932. * ...
  933. * columns: [
  934. * {
  935. * editor: 'select'
  936. * },
  937. * {
  938. * editor: false
  939. * }
  940. * ]
  941. * ...
  942. * ```
  943. *
  944. * @type {String|Function|Boolean}
  945. * @default 'text'
  946. */
  947. editor: void 0,
  948. /**
  949. * @description
  950. * Autocomplete definitions. See [autocomplete demo](http://docs.handsontable.com/demo-autocomplete.html) for examples and definitions.
  951. *
  952. * @type {Array}
  953. * @default undefined
  954. */
  955. autoComplete: void 0,
  956. /**
  957. * Control number of choices for the autocomplete (or dropdown) typed cells. After exceeding it, a scrollbar for the dropdown list of choices will appear.
  958. *
  959. * @since 0.18.0
  960. * @type {Number}
  961. * @default 10
  962. */
  963. visibleRows: 10,
  964. /**
  965. * Makes autocomplete or dropdown width the same as the edited cell width. If `false` then editor will be scaled
  966. * according to its content.
  967. *
  968. * @since 0.17.0
  969. * @type {Boolean}
  970. * @default true
  971. */
  972. trimDropdown: true,
  973. /**
  974. * Setting to true enables the debug mode, currently used to test the correctness of the row and column
  975. * header fixed positioning on a layer above the master table.
  976. *
  977. * @type {Boolean}
  978. * @default false
  979. */
  980. debug: false,
  981. /**
  982. * When set to `true`, the text of the cell content is wrapped if it does not fit in the fixed column width.
  983. *
  984. * @type {Boolean}
  985. * @default true
  986. * @since 0.11.0
  987. */
  988. wordWrap: true,
  989. /**
  990. * CSS class name added to cells with cell meta `wordWrap: false`.
  991. *
  992. * @type {String}
  993. * @default 'htNoWrap'
  994. * @since 0.11.0
  995. */
  996. noWordWrapClassName: 'htNoWrap',
  997. /**
  998. * @description
  999. * Defines if the right-click context menu should be enabled. Context menu allows to create new row or
  1000. * column at any place in the grid among [other features](http://docs.handsontable.com/demo-context-menu.html).
  1001. * Possible values:
  1002. * * `true` (to enable default options),
  1003. * * `false` (to disable completely)
  1004. *
  1005. * or array of any available strings:
  1006. * * `["row_above", "row_below", "col_left", "col_right",
  1007. * "remove_row", "remove_col", "---------", "undo", "redo"]`.
  1008. *
  1009. * See [the context menu demo](http://docs.handsontable.com/demo-context-menu.html) for examples.
  1010. *
  1011. * @example
  1012. * ```js
  1013. * ...
  1014. * // as a boolean
  1015. * contextMenu: true
  1016. * ...
  1017. * // as a array
  1018. * contextMenu: ['row_above', 'row_below', '--------', 'undo', 'redo']
  1019. * ...
  1020. * ```
  1021. *
  1022. * @type {Boolean|Array|Object}
  1023. * @default undefined
  1024. */
  1025. contextMenu: void 0,
  1026. /**
  1027. * @description
  1028. * Defines new actions copy/paste for context menu. This functionality is dependent on ZeroClipboard from which you
  1029. * should pass the swf file path under `swfPath` object key.
  1030. *
  1031. * @example
  1032. * ```js
  1033. * ...
  1034. * contextMenuCopyPaste: {swfPath: '[path to file]'}
  1035. * ...
  1036. * ```
  1037. *
  1038. * @type {Object}
  1039. */
  1040. contextMenuCopyPaste: void 0,
  1041. /**
  1042. * @description
  1043. * Disable or enable the copy/paste functionality.
  1044. *
  1045. * @example
  1046. * ```js
  1047. * ...
  1048. * copyPaste: false,
  1049. * ...
  1050. * ```
  1051. *
  1052. * @type {Boolean}
  1053. * @default undefined
  1054. */
  1055. copyPaste: void 0,
  1056. /**
  1057. * If `true`, undo/redo functionality is enabled.
  1058. *
  1059. * @type {Boolean}
  1060. * @default undefined
  1061. */
  1062. undo: void 0,
  1063. /**
  1064. * @description
  1065. * Turns on [Column sorting](http://docs.handsontable.com/demo-sorting-data.html).
  1066. * Can be either a boolean (true/false) or an object with a declared sorting options. See the below example:
  1067. *
  1068. * @example
  1069. * ```js
  1070. * ...
  1071. * // as boolean
  1072. * columnSorting: true
  1073. * ...
  1074. * // as a object with initial order (sort ascending column at index 2)
  1075. * columnSorting: {
  1076. * column: 2,
  1077. * sortOrder: true, // true = ascending, false = descending, undefined = original order
  1078. * sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table
  1079. * }
  1080. * ...
  1081. * ```
  1082. *
  1083. * @type {Boolean|Object}
  1084. * @default undefined
  1085. */
  1086. columnSorting: void 0,
  1087. /**
  1088. * @description
  1089. * Turns on [Manual column move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial
  1090. * column order, if set to an array of column indexes.
  1091. *
  1092. * @example
  1093. * ```js
  1094. * ...
  1095. * // as boolean
  1096. * manualColumnMove: true
  1097. * ...
  1098. * // as a array with initial order (move column index at 0 to 1 and move column index at 1 to 4)
  1099. * manualColumnMove: [1, 4]
  1100. * ...
  1101. * ```
  1102. *
  1103. * @type {Boolean|Array}
  1104. * @default undefined
  1105. */
  1106. manualColumnMove: void 0,
  1107. /**
  1108. * @description
  1109. * Turns on [Manual column resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial
  1110. * column resized widths, if set to an array of numbers.
  1111. *
  1112. * @example
  1113. * ```js
  1114. * ...
  1115. * // as boolean
  1116. * manualColumnResize: true
  1117. * ...
  1118. * // as a array with initial widths (column at 0 index has 40px and column at 1 index has 50px)
  1119. * manualColumnResize: [40, 50]
  1120. * ...
  1121. * ```
  1122. *
  1123. * @type {Boolean|Array}
  1124. * @default undefined
  1125. */
  1126. manualColumnResize: void 0,
  1127. /**
  1128. * @description
  1129. * Turns on [Manual row move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial
  1130. * row order, if set to an array of row indexes.
  1131. *
  1132. * @example
  1133. * ```js
  1134. * ...
  1135. * // as boolean
  1136. * manualRowMove: true
  1137. * ...
  1138. * // as a array with initial order (move row index at 0 to 1 and move row index at 1 to 4)
  1139. * manualRowMove: [1, 4]
  1140. * ...
  1141. * ```
  1142. *
  1143. * @type {Boolean|Array}
  1144. * @default undefined
  1145. * @since 0.11.0
  1146. */
  1147. manualRowMove: void 0,
  1148. /**
  1149. * @description
  1150. * Turns on [Manual row resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial
  1151. * row resized heights, if set to an array of numbers.
  1152. *
  1153. * @example
  1154. * ```js
  1155. * ...
  1156. * // as boolean
  1157. * manualRowResize: true
  1158. * ...
  1159. * // as a array with initial heights (row at 0 index has 40px and row at 1 index has 50px)
  1160. * manualRowResize: [40, 50]
  1161. * ...
  1162. * ```
  1163. *
  1164. * @type {Boolean|Array}
  1165. * @default undefined
  1166. * @since 0.11.0
  1167. */
  1168. manualRowResize: void 0,
  1169. /**
  1170. * @description
  1171. * If set to `true`, it enables a possibility to merge cells. If set to an array of objects, it merges the cells provided in the objects (see the example below).
  1172. * [More information on the demo page.](http://docs.handsontable.com/demo-merge-cells.html)
  1173. *
  1174. * @example
  1175. * ```js
  1176. * // enables the mergeCells plugin:
  1177. * margeCells: true
  1178. * ...
  1179. * // declares a list of merged sections:
  1180. * mergeCells: [
  1181. * {row: 1, col: 1, rowspan: 3, colspan: 3}, // rowspan and colspan properties declare the width and height of a merged section in cells
  1182. * {row: 3, col: 4, rowspan: 2, colspan: 2},
  1183. * {row: 5, col: 6, rowspan: 3, colspan: 3}
  1184. * ]
  1185. * ```
  1186. * @type {Boolean|Array}
  1187. * @default false
  1188. */
  1189. mergeCells: false,
  1190. /**
  1191. * Number of rows to be rendered outside of the visible part of the table.
  1192. * By default, it's set to `'auto'`, which makes Handsontable to attempt to calculate the best offset performance-wise.
  1193. *
  1194. * You may test out different values to find the best one that works for your specific implementation.
  1195. *
  1196. * @type {Number|String}
  1197. * @default 'auto'
  1198. */
  1199. viewportRowRenderingOffset: 'auto',
  1200. /**
  1201. * Number of columns to be rendered outside of the visible part of the table.
  1202. * By default, it's set to `'auto'`, which makes Handsontable try calculating the best offset performance-wise.
  1203. *
  1204. * You may experiment with the value to find the one that works best for your specific implementation.
  1205. *
  1206. * @type {Number|String}
  1207. * @default 'auto'
  1208. */
  1209. viewportColumnRenderingOffset: 'auto',
  1210. /**
  1211. * A function, regular expression or a string, which will be used in the process of cell validation.
  1212. * If a function is used, be sure to execute the callback argument with either `true` (`callback(true)`) if the validation passed
  1213. * or with `false` (`callback(false)`), if the validation failed.
  1214. * Note, that `this` in the function points to the `cellProperties` object.
  1215. *
  1216. * If a string is provided, it may be one of the following predefined values:
  1217. * * `autocomplete`,
  1218. * * `date`,
  1219. * * `numeric`,
  1220. * * `time`.
  1221. *
  1222. * Or you can [register](http://docs.handsontable.com/demo-data-validation.html) the validator function under specified name and use
  1223. * its name as an alias in your configuration.
  1224. *
  1225. * See more [in the demo](http://docs.handsontable.com/demo-data-validation.html).
  1226. *
  1227. * @example
  1228. * ```js
  1229. * // as a function
  1230. * columns: [
  1231. * {
  1232. * validator: function(value, callback) { // validation rules }
  1233. * }
  1234. * ]
  1235. * ...
  1236. * // as a regexp
  1237. * columns: [
  1238. * {
  1239. * validator: /^[0-9]$/ // regular expression
  1240. * }
  1241. * ]
  1242. * // as a string
  1243. * columns: [
  1244. * {
  1245. * validator: 'numeric'
  1246. * }
  1247. * ]
  1248. * ```
  1249. * @type {Function|RegExp|String}
  1250. * @default undefined
  1251. * @since 0.9.5
  1252. */
  1253. validator: void 0,
  1254. /**
  1255. * @description
  1256. * Disable visual cells selection.
  1257. *
  1258. * Possible values:
  1259. * * `true` - Disables any type of visual selection (current and area selection),
  1260. * * `false` - Enables any type of visual selection. This is default value.
  1261. * * `current` - Disables the selection of a currently selected cell, the area selection is still present.
  1262. * * `area` - Disables the area selection, the currently selected cell selection is still present.
  1263. *
  1264. * @type {Boolean|String|Array}
  1265. * @default false
  1266. * @since 0.13.2
  1267. * @example
  1268. * ```js
  1269. * ...
  1270. * // as boolean
  1271. * disableVisualSelection: true,
  1272. * ...
  1273. *
  1274. * ...
  1275. * // as string ('current' or 'area')
  1276. * disableVisualSelection: 'current',
  1277. * ...
  1278. *
  1279. * ...
  1280. * // as array
  1281. * disableVisualSelection: ['current', 'area'],
  1282. * ...
  1283. * ```
  1284. */
  1285. disableVisualSelection: false,
  1286. /**
  1287. * @description
  1288. * Set whether to display the current sorting order indicator (a triangle icon in the column header, specifying the sorting order).
  1289. *
  1290. * @type {Boolean}
  1291. * @default false
  1292. * @since 0.15.0-beta3
  1293. */
  1294. sortIndicator: void 0,
  1295. /**
  1296. * Disable or enable ManualColumnFreeze plugin.
  1297. *
  1298. * @type {Boolean}
  1299. * @default false
  1300. */
  1301. manualColumnFreeze: void 0,
  1302. /**
  1303. * @description
  1304. * Defines whether Handsontable should trim the whitespace at the beginning and the end of the cell contents.
  1305. *
  1306. * @type {Boolean}
  1307. * @default true
  1308. */
  1309. trimWhitespace: true,
  1310. settings: void 0,
  1311. /**
  1312. * @description
  1313. * Defines data source for Autocomplete or Dropdown cell types.
  1314. *
  1315. * @example
  1316. * ```js
  1317. * ...
  1318. * // source as a array
  1319. * columns: [{
  1320. * type: 'autocomplete',
  1321. * source: ['A', 'B', 'C', 'D']
  1322. * }]
  1323. * ...
  1324. * // source as a function
  1325. * columns: [{
  1326. * type: 'autocomplete',
  1327. * source: function(query, callback) {
  1328. * fetch('http://example.com/query?q=' + query, function(response) {
  1329. * callback(response.items);
  1330. * })
  1331. * }
  1332. * }]
  1333. * ...
  1334. * ```
  1335. *
  1336. * @type {Array|Function}
  1337. * @default undefined
  1338. */
  1339. source: void 0,
  1340. /**
  1341. * @description
  1342. * Defines the column header name.
  1343. *
  1344. * @example
  1345. * ```js
  1346. * ...
  1347. * columns: [{
  1348. * title: 'First name',
  1349. * type: 'text',
  1350. * },
  1351. * {
  1352. * title: 'Last name',
  1353. * type: 'text',
  1354. * }]
  1355. * ...
  1356. * ```
  1357. *
  1358. * @type {String}
  1359. * @default undefined
  1360. */
  1361. title: void 0,
  1362. /**
  1363. * Data template for `'checkbox'` type when checkbox is checked.
  1364. *
  1365. * @example
  1366. * ```js
  1367. * checkedTemplate: 'good'
  1368. *
  1369. * // if a checkbox-typed cell is checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell
  1370. * // will return 'good'.
  1371. * ```
  1372. * @type {Boolean|String}
  1373. * @default true
  1374. */
  1375. checkedTemplate: void 0,
  1376. /**
  1377. * Data template for `'checkbox'` type when checkbox is unchecked.
  1378. *
  1379. * @example
  1380. * ```js
  1381. * uncheckedTemplate: 'bad'
  1382. *
  1383. * // if a checkbox-typed cell is not checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell
  1384. * // will return 'bad'.
  1385. * ```
  1386. * @type {Boolean|String}
  1387. * @default false
  1388. */
  1389. uncheckedTemplate: void 0,
  1390. /**
  1391. * @description
  1392. * Object which describes if renderer should create checkbox element with label element as a parent. Option desired for
  1393. * [checkbox](http://docs.handsontable.com/demo-checkbox.html)-typed cells.
  1394. *
  1395. * By default the [checkbox](http://docs.handsontable.com/demo-checkbox.html) renderer renders the checkbox without a label.
  1396. *
  1397. * Possible object properties:
  1398. * * `property` - Defines the property name of the data object, which will to be used as a label.
  1399. * (eg. `label: {property: 'name.last'}`). This option works only if data was passed as an array of objects.
  1400. * * `position` - String which describes where to place the label text (before or after checkbox element).
  1401. * Valid values are `'before'` and '`after`' (defaults to `'after'`).
  1402. * * `value` - String or a Function which will be used as label text.
  1403. *
  1404. * @example
  1405. * ```js
  1406. * ...
  1407. * columns: [{
  1408. * type: 'checkbox',
  1409. * label: {position: 'after', value: 'My label: '}
  1410. * }]
  1411. * ...
  1412. * ```
  1413. *
  1414. * @since 0.19.0
  1415. * @type {Object}
  1416. * @default undefined
  1417. */
  1418. label: void 0,
  1419. /**
  1420. * Display format. See [numbrojs](http://numbrojs.com). This option is desired for
  1421. * [numeric](http://docs.handsontable.com/demo-numeric.html)-typed cells.
  1422. *
  1423. * Since 0.26.0 Handsontable uses [numbro](http://numbrojs.com/) as a main library for numbers formatting.
  1424. *
  1425. * @example
  1426. * ```js
  1427. * ...
  1428. * columns: [{
  1429. * type: 'numeric',
  1430. * format: '0,00'
  1431. * }]
  1432. * ...
  1433. * ```
  1434. *
  1435. * @type {String}
  1436. * @default '0'
  1437. */
  1438. format: void 0,
  1439. /**
  1440. * Language display format. See [numbrojs](http://numbrojs.com/languages.html#supported-languages). This option is desired for
  1441. * [numeric](http://docs.handsontable.com/demo-numeric.html)-typed cells.
  1442. *
  1443. * Since 0.26.0 Handsontable uses [numbro](http://numbrojs.com/) as a main library for numbers formatting.
  1444. *
  1445. * @example
  1446. * ```js
  1447. * ...
  1448. * columns: [{
  1449. * type: 'numeric',
  1450. * language: 'en-US'
  1451. * }]
  1452. * ...
  1453. * ```
  1454. *
  1455. * @type {String}
  1456. * @default 'en-US'
  1457. */
  1458. language: void 0,
  1459. /**
  1460. * @description
  1461. * Data source for [select](http://docs.handsontable.com/demo-select.html)-typed cells.
  1462. *
  1463. * @example
  1464. * ```js
  1465. * ...
  1466. * columns: [{
  1467. * editor: 'select',
  1468. * selectOptions: ['A', 'B', 'C'],
  1469. * }]
  1470. * ...
  1471. * ```
  1472. *
  1473. * @type {Array}
  1474. */
  1475. selectOptions: void 0,
  1476. /**
  1477. * Enables or disables the autoColumnSize plugin. Default value is `undefined`, which has the same effect as `true`.
  1478. * Disabling this plugin can increase performance, as no size-related calculations would be done.
  1479. *
  1480. * Column width calculations are divided into sync and async part. Each of this parts has their own advantages and
  1481. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  1482. * block the browser UI.
  1483. *
  1484. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value.
  1485. * `syncLimit` option is available since 0.16.0.
  1486. *
  1487. * You can also use the `useHeaders` option to take the column headers with into calculation.
  1488. *
  1489. * @example
  1490. * ```js
  1491. * ...
  1492. * // as a number (300 columns in sync, rest async)
  1493. * autoColumnSize: {syncLimit: 300},
  1494. * ...
  1495. *
  1496. * ...
  1497. * // as a string (percent)
  1498. * autoColumnSize: {syncLimit: '40%'},
  1499. * ...
  1500. *
  1501. * ...
  1502. * // use headers width while calculation the column width
  1503. * autoColumnSize: {useHeaders: true},
  1504. * ...
  1505. *
  1506. * ```
  1507. *
  1508. * @type {Object|Boolean}
  1509. * @default {syncLimit: 50}
  1510. */
  1511. autoColumnSize: void 0,
  1512. /**
  1513. * Enables or disables autoRowSize plugin. Default value is `undefined`, which has the same effect as `false` (disabled).
  1514. * Enabling this plugin can decrease performance, as size-related calculations would be performed.
  1515. *
  1516. * Row height calculations are divided into sync and async stages. Each of these stages has their own advantages and
  1517. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  1518. * block the browser UI.
  1519. *
  1520. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value.
  1521. * `syncLimit` options is available since 0.16.0.
  1522. *
  1523. * @example
  1524. * ```js
  1525. * ...
  1526. * // as number (300 columns in sync, rest async)
  1527. * autoRowSize: {syncLimit: 300},
  1528. * ...
  1529. *
  1530. * ...
  1531. * // as string (percent)
  1532. * autoRowSize: {syncLimit: '40%'},
  1533. * ...
  1534. * ```
  1535. * @type {Object|Boolean}
  1536. * @default {syncLimit: 1000}
  1537. */
  1538. autoRowSize: void 0,
  1539. /**
  1540. * Date validation format.
  1541. *
  1542. * Option desired for `'date'` - typed cells.
  1543. *
  1544. * @example
  1545. * ```js
  1546. * ...
  1547. * columns: [{
  1548. * type: 'date',
  1549. * dateFormat: 'MM/DD/YYYY'
  1550. * }]
  1551. * ...
  1552. * ```
  1553. *
  1554. * @type {String}
  1555. * @default 'DD/MM/YYYY'
  1556. */
  1557. dateFormat: void 0,
  1558. /**
  1559. * If `true` then dates will be automatically formatted to match the desired format.
  1560. *
  1561. * Option desired for `'date'`-typed typed cells.
  1562. *
  1563. * @example
  1564. * ```js
  1565. * ...
  1566. * columns: [{
  1567. * type: 'date',
  1568. * dateFormat: 'YYYY-MM-DD',
  1569. * correctFormat: true
  1570. * }]
  1571. * ...
  1572. * ```
  1573. *
  1574. * @type {Boolean}
  1575. * @default false
  1576. */
  1577. correctFormat: false,
  1578. /**
  1579. * Definition of default value which will fill the empty cells.
  1580. *
  1581. * Option desired for `'date'`-typed cells.
  1582. *
  1583. * @example
  1584. * ```js
  1585. * ...
  1586. * columns: [{
  1587. * type: 'date',
  1588. * defaultData: '2015-02-02'
  1589. * }]
  1590. * ...
  1591. * ```
  1592. *
  1593. * @type {String}
  1594. */
  1595. defaultDate: void 0,
  1596. /**
  1597. * If set to `true`, the value entered into the cell must match (case-sensitive) the autocomplete source. Otherwise, cell won't pass the validation.
  1598. * When filtering the autocomplete source list, the editor will be working in case-insensitive mode.
  1599. *
  1600. * Option desired for `autocomplete`-typed cells.
  1601. *
  1602. * @example
  1603. * ```js
  1604. * ...
  1605. * columns: [{
  1606. * type: 'autocomplete',
  1607. * source: ['A', 'B', 'C'],
  1608. * strict: true
  1609. * }]
  1610. * ...
  1611. * ```
  1612. *
  1613. * @type {Boolean}
  1614. */
  1615. strict: void 0,
  1616. /**
  1617. * @description
  1618. * If typed `true`, data defined in `source` of the autocomplete or dropdown cell will be treated as HTML.
  1619. *
  1620. * __Warning:__ Enabling this option can cause serious XSS vulnerabilities.
  1621. *
  1622. * Option desired for `'autocomplete'`-typed cells.
  1623. * @example
  1624. * ```js
  1625. * ...
  1626. * columns: [{
  1627. * type: 'autocomplete',
  1628. * allowHtml: true,
  1629. * source: ['<b>foo</b>', '<b>bar</b>']
  1630. * }]
  1631. * ...
  1632. * ```
  1633. * @type {Boolean}
  1634. * @default false
  1635. */
  1636. allowHtml: false,
  1637. /**
  1638. * If typed `true` then virtual rendering mechanism for handsontable will be disabled.
  1639. *
  1640. * @type {Boolean}
  1641. */
  1642. renderAllRows: void 0,
  1643. /**
  1644. * Prevents table to overlap outside the parent element. If `'horizontal'` option is chosen then table will appear horizontal
  1645. * scrollbar in case where parent's width is narrower then table's width.
  1646. *
  1647. * Possible values:
  1648. * * `false` - Disables functionality (Default option).
  1649. * * `horizontal` - Prevents horizontal overflow table.
  1650. * * `vertical` - Prevents vertical overflow table (Not implemented yet).
  1651. *
  1652. * @since 0.20.3
  1653. * @example
  1654. * ```js
  1655. * ...
  1656. * preventOverflow: 'horizontal'
  1657. * ...
  1658. * ```
  1659. *
  1660. * @type {String|Boolean}
  1661. */
  1662. preventOverflow: false,
  1663. /**
  1664. * @description
  1665. * Plugin allowing binding the table rows with their headers.
  1666. * If the plugin is enabled, the table row headers will "stick" to the rows, when they are hidden/moved. Basically, if at the initialization
  1667. * row 0 has a header titled "A", it will have it no matter what you do with the table.
  1668. *
  1669. * @pro
  1670. * @since 1.0.0-beta1
  1671. * @type {Boolean|String}
  1672. * @example
  1673. *
  1674. * ```js
  1675. * ...
  1676. * var hot = new Handsontable(document.getElementById('example'), {
  1677. * date: getData(),
  1678. * bindRowsWithHeaders: true
  1679. * });
  1680. * ...
  1681. * ```
  1682. *
  1683. */
  1684. bindRowsWithHeaders: void 0,
  1685. /**
  1686. * @description
  1687. * The CollapsibleColumns plugin allows collapsing of columns, covered by a header with the `colspan` property defined.
  1688. *
  1689. * Clicking the "collapse/expand" button collapses (or expands) all "child" headers except the first one.
  1690. *
  1691. * Setting the `collapsibleColumns` property to `true` will display a "collapse/expand" button in every header with a defined
  1692. * `colspan` property.
  1693. *
  1694. * To limit this functionality to a smaller group of headers, define the `collapsibleColumns` property as an array of objects, as in
  1695. * the example below.
  1696. *
  1697. * @pro
  1698. * @since 1.0.0-beta1
  1699. * @type {Boolean|Array}
  1700. * @example
  1701. * ```js
  1702. * ...
  1703. * collapsibleColumns: [
  1704. * {row: -4, col: 1, collapsible: true},
  1705. * {row: -3, col: 5, collapsible: true}
  1706. * ]
  1707. * ...
  1708. * // or
  1709. * ...
  1710. * collapsibleColumns: true
  1711. * ...
  1712. * ```
  1713. */
  1714. collapsibleColumns: void 0,
  1715. /**
  1716. * @description
  1717. * Allows making pre-defined calculations on the cell values and display the results within Handsontable.
  1718. * See the demo for more information.
  1719. *
  1720. * @pro
  1721. * @since 1.0.0-beta1
  1722. * @type {Object}
  1723. */
  1724. columnSummary: void 0,
  1725. /**
  1726. * This plugin allows adding a configurable dropdown menu to the table's column headers.
  1727. * The dropdown menu acts like the Context Menu, but is triggered by clicking the button in the header.
  1728. *
  1729. * @pro
  1730. * @since 1.0.0-beta1
  1731. * @type {Boolean|Object|Array}
  1732. */
  1733. dropdownMenu: void 0,
  1734. /**
  1735. * The filters plugin.
  1736. * It allows filtering the table data either by the built-in component or with the API.
  1737. *
  1738. * @pro
  1739. * @since 1.0.0-beta1
  1740. * @type {Boolean}
  1741. */
  1742. filters: void 0,
  1743. /**
  1744. * It allows Handsontable to process formula expressions defined in the provided data.
  1745. *
  1746. * @pro
  1747. * @since 1.7.0
  1748. * @type {Boolean}
  1749. */
  1750. formulas: void 0,
  1751. /**
  1752. * @description
  1753. * GanttChart plugin enables a possibility to create a Gantt chart using a Handsontable instance.
  1754. * In this case, the whole table becomes read-only.
  1755. *
  1756. * @pro
  1757. * @since 1.0.0-beta1
  1758. * @type {Object}
  1759. */
  1760. ganttChart: void 0,
  1761. /**
  1762. * @description
  1763. * Allows adding a tooltip to the table headers.
  1764. *
  1765. * Available options:
  1766. * * the `rows` property defines if tooltips should be added to row headers,
  1767. * * the `columns` property defines if tooltips should be added to column headers,
  1768. * * the `onlyTrimmed` property defines if tooltips should be added only to headers, which content is trimmed by the header itself (the content being wider then the header).
  1769. *
  1770. * @pro
  1771. * @since 1.0.0-beta1
  1772. * @type {Boolean|Object}
  1773. */
  1774. headerTooltips: void 0,
  1775. /**
  1776. * Plugin allowing hiding of certain columns.
  1777. *
  1778. * @pro
  1779. * @since 1.0.0-beta1
  1780. * @type {Boolean|Object}
  1781. */
  1782. hiddenColumns: void 0,
  1783. /**
  1784. * @description
  1785. * Plugin allowing hiding of certain rows.
  1786. *
  1787. * @pro
  1788. * @since 1.0.0-beta1
  1789. * @type {Boolean|Object}
  1790. */
  1791. hiddenRows: void 0,
  1792. /**
  1793. * @description
  1794. * Allows creating a nested header structure, using the HTML's colspan attribute.
  1795. *
  1796. * @pro
  1797. * @since 1.0.0-beta1
  1798. * @type {Array}
  1799. */
  1800. nestedHeaders: void 0,
  1801. /**
  1802. * @description
  1803. * Plugin allowing hiding of certain rows.
  1804. *
  1805. * @pro
  1806. * @since 1.0.0-beta1
  1807. * @type {Boolean|Array}
  1808. */
  1809. trimRows: void 0,
  1810. /**
  1811. * @description
  1812. * Allows setting a custom width of the row headers. You can provide a number or an array of widths, if many row header levels are defined.
  1813. *
  1814. * @since 0.22.0
  1815. * @type {Number|Array}
  1816. */
  1817. rowHeaderWidth: void 0,
  1818. /**
  1819. * @description
  1820. * Allows setting a custom height of the column headers. You can provide a number or an array of heights, if many column header levels are defined.
  1821. *
  1822. * @since 0.22.0
  1823. * @type {Number|Array}
  1824. */
  1825. columnHeaderHeight: void 0,
  1826. /**
  1827. * @description
  1828. * Enabling this plugin switches table into one-way data binding where changes are applied into data source (from outside table)
  1829. * will be automatically reflected in the table.
  1830. *
  1831. * For every data change [afterChangesObserved](Hooks.html#event:afterChangesObserved) hook will be fired.
  1832. *
  1833. * @type {Boolean}
  1834. * @default false
  1835. */
  1836. observeChanges: void 0,
  1837. /**
  1838. * @description
  1839. * When passed to the `column` property, allows specifying a custom sorting function for the desired column.
  1840. *
  1841. * @since 0.24.0
  1842. * @type {Function}
  1843. * @example
  1844. * ```js
  1845. * columns: [
  1846. * {
  1847. * sortFunction: function(sortOrder) {
  1848. * return function(a, b) {
  1849. * // sorting function body.
  1850. * //
  1851. * // Function parameters:
  1852. * // sortOrder: If true, the order is ascending, if false - descending. undefined = original order
  1853. * // a, b: Two compared elements. These are 2-element arrays, with the first element being the row index, the second - cell value.
  1854. * }
  1855. * }
  1856. * }
  1857. * ]
  1858. * ```
  1859. */
  1860. sortFunction: void 0,
  1861. /**
  1862. * If defined as 'true', the Autocomplete's suggestion list would be sorted by relevance (the closer to the left the match is, the higher the suggestion).
  1863. *
  1864. * Option desired for cells of the `'autocomplete'` type.
  1865. *
  1866. * @type {Boolean}
  1867. * @default true
  1868. */
  1869. sortByRelevance: true,
  1870. /**
  1871. * If defined as 'true', when the user types into the input area the Autocomplete's suggestion list is updated to only
  1872. * include those choices starting with what has been typed; if defined as 'false' all suggestions remain shown, with
  1873. * those matching what has been typed marked in bold.
  1874. *
  1875. * @type {Boolean}
  1876. * @default true
  1877. */
  1878. filter: true,
  1879. /**
  1880. * If defined as 'true', filtering in the Autocomplete Editor will be case-sensitive.
  1881. *
  1882. * @type {Boolean}
  1883. * @default: false
  1884. */
  1885. filteringCaseSensitive: false,
  1886. };
  1887. export default DefaultSettings;