@servicetitan/form 31.1.0 → 31.3.0

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 (81) hide show
  1. package/dist/color-picker/color-palette.js +8 -9
  2. package/dist/color-picker/color-palette.js.map +1 -1
  3. package/dist/color-picker/color-picker.js +46 -9
  4. package/dist/color-picker/color-picker.js.map +1 -1
  5. package/dist/color-picker/color-picker.module.css.d.ts +4 -0
  6. package/dist/color-picker/index.js +1 -0
  7. package/dist/color-picker/index.js.map +1 -1
  8. package/dist/date-range-picker/date-range-picker.js +205 -174
  9. package/dist/date-range-picker/date-range-picker.js.map +1 -1
  10. package/dist/date-range-picker/date-range-picker.module.css.d.ts +8 -0
  11. package/dist/date-range-picker/index.js +1 -0
  12. package/dist/date-range-picker/index.js.map +1 -1
  13. package/dist/demo/color-picker.js +39 -4
  14. package/dist/demo/color-picker.js.map +1 -1
  15. package/dist/demo/date-range-picker.js +18 -2
  16. package/dist/demo/date-range-picker.js.map +1 -1
  17. package/dist/demo/file-uploader.js +94 -12
  18. package/dist/demo/file-uploader.js.map +1 -1
  19. package/dist/demo/index.js +1 -0
  20. package/dist/demo/index.js.map +1 -1
  21. package/dist/demo/input-date-mask.js +18 -2
  22. package/dist/demo/input-date-mask.js.map +1 -1
  23. package/dist/demo/number-input.js +121 -3
  24. package/dist/demo/number-input.js.map +1 -1
  25. package/dist/demo/original-number-input.js +18 -2
  26. package/dist/demo/original-number-input.js.map +1 -1
  27. package/dist/demo/phone-number-input.js +5 -1
  28. package/dist/demo/phone-number-input.js.map +1 -1
  29. package/dist/file-uploader/config.js +10 -1
  30. package/dist/file-uploader/config.js.map +1 -1
  31. package/dist/file-uploader/file-uploader.js +189 -192
  32. package/dist/file-uploader/file-uploader.js.map +1 -1
  33. package/dist/file-uploader/index.js +3 -1
  34. package/dist/file-uploader/index.js.map +1 -1
  35. package/dist/file-uploader/uploader.js +57 -41
  36. package/dist/file-uploader/uploader.js.map +1 -1
  37. package/dist/form-state-error-banner/form-state-error-banner.js +15 -5
  38. package/dist/form-state-error-banner/form-state-error-banner.js.map +1 -1
  39. package/dist/form-state-error-banner/index.js +1 -0
  40. package/dist/form-state-error-banner/index.js.map +1 -1
  41. package/dist/index.js +1 -0
  42. package/dist/index.js.map +1 -1
  43. package/dist/input-date-mask/index.js +1 -0
  44. package/dist/input-date-mask/index.js.map +1 -1
  45. package/dist/input-date-mask/input-date-mask.js +47 -28
  46. package/dist/input-date-mask/input-date-mask.js.map +1 -1
  47. package/dist/input-date-mask/input-date-mask.module.css.d.ts +4 -0
  48. package/dist/label/index.js +1 -0
  49. package/dist/label/index.js.map +1 -1
  50. package/dist/label/label.js +29 -1
  51. package/dist/label/label.js.map +1 -1
  52. package/dist/label/label.module.css.d.ts +7 -0
  53. package/dist/masked-input.js +17 -4
  54. package/dist/masked-input.js.map +1 -1
  55. package/dist/number-input/common-interfaces.js +2 -1
  56. package/dist/number-input/common-interfaces.js.map +1 -1
  57. package/dist/number-input/get-formatted-string.js +2 -3
  58. package/dist/number-input/get-formatted-string.js.map +1 -1
  59. package/dist/number-input/index.js +1 -0
  60. package/dist/number-input/index.js.map +1 -1
  61. package/dist/number-input/number-input.js +53 -42
  62. package/dist/number-input/number-input.js.map +1 -1
  63. package/dist/number-input/process-value.js +10 -16
  64. package/dist/number-input/process-value.js.map +1 -1
  65. package/dist/original-number-input/index.js +1 -0
  66. package/dist/original-number-input/index.js.map +1 -1
  67. package/dist/original-number-input/ordinal-number-input.js +54 -59
  68. package/dist/original-number-input/ordinal-number-input.js.map +1 -1
  69. package/dist/phone-number-input/index.js +1 -0
  70. package/dist/phone-number-input/index.js.map +1 -1
  71. package/dist/phone-number-input/phone-number-input.js +13 -1
  72. package/dist/phone-number-input/phone-number-input.js.map +1 -1
  73. package/package.json +13 -13
  74. package/dist/form.stories.js +0 -20
  75. package/dist/form.stories.js.map +0 -1
  76. package/dist/number-input/__tests__/get-formatted-string.test.js +0 -41
  77. package/dist/number-input/__tests__/get-formatted-string.test.js.map +0 -1
  78. package/dist/number-input/__tests__/process-value.test.js +0 -283
  79. package/dist/number-input/__tests__/process-value.test.js.map +0 -1
  80. package/dist/original-number-input/__tests__/ordinal-number-input.test.js +0 -51
  81. package/dist/original-number-input/__tests__/ordinal-number-input.test.js.map +0 -1
@@ -1,31 +1,69 @@
1
- import { v4 as uuid } from 'uuid';
2
- const Resumable = require('resumablejs');
3
- export class Uploader {
4
- constructor(config = {}, handlers = {}, folderName = 'default') {
5
- Object.defineProperty(this, "resumable", {
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
6
5
  enumerable: true,
7
6
  configurable: true,
8
- writable: true,
9
- value: void 0
7
+ writable: true
10
8
  });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ import { v4 as uuid } from 'uuid';
15
+ const Resumable = require('resumablejs');
16
+ export class Uploader {
17
+ upload(source) {
18
+ if (source instanceof File) {
19
+ this.resumable.addFile(source);
20
+ } else {
21
+ for (const file of Array.from(source)){
22
+ this.resumable.addFile(file);
23
+ }
24
+ }
25
+ }
26
+ cancel(file) {
27
+ if (file) {
28
+ for (const resumableFile of this.resumable.files){
29
+ if (resumableFile.file === file) {
30
+ resumableFile.cancel();
31
+ break;
32
+ }
33
+ }
34
+ } else {
35
+ this.resumable.cancel();
36
+ }
37
+ }
38
+ constructor(config = {}, handlers = {}, folderName = 'default'){
39
+ _define_property(this, "resumable", void 0);
11
40
  const { errorParser, ...configuration } = config;
12
41
  const resumable = new Resumable({
13
42
  target: `/app/api/fileuploader/folders/${folderName}/files`,
14
43
  testChunks: false,
15
44
  simultaneousUploads: 1,
16
- headers: { 'X-Requested-With': 'XMLHttpRequest' },
17
- permanentErrors: [302, 400, 404, 415, 500, 501],
18
- generateUniqueIdentifier: () => uuid(),
19
- fileTypeErrorCallback: (file) => {
20
- var _a, _b, _c;
21
- (_a = handlers.error) === null || _a === void 0 ? void 0 : _a.call(handlers, file, `File type not allowed. Please provide file of type ${(_c = (_b = configuration.fileType) === null || _b === void 0 ? void 0 : _b.map(ext => `.${ext}`)) === null || _c === void 0 ? void 0 : _c.join(', ')}.`);
45
+ headers: {
46
+ 'X-Requested-With': 'XMLHttpRequest'
47
+ },
48
+ permanentErrors: [
49
+ 302,
50
+ 400,
51
+ 404,
52
+ 415,
53
+ 500,
54
+ 501
55
+ ],
56
+ generateUniqueIdentifier: ()=>uuid(),
57
+ fileTypeErrorCallback: (file)=>{
58
+ var _configuration_fileType_map, _configuration_fileType, _handlers_error;
59
+ (_handlers_error = handlers.error) === null || _handlers_error === void 0 ? void 0 : _handlers_error.call(handlers, file, `File type not allowed. Please provide file of type ${(_configuration_fileType = configuration.fileType) === null || _configuration_fileType === void 0 ? void 0 : (_configuration_fileType_map = _configuration_fileType.map((ext)=>`.${ext}`)) === null || _configuration_fileType_map === void 0 ? void 0 : _configuration_fileType_map.join(', ')}.`);
22
60
  },
23
- ...configuration,
61
+ ...configuration
24
62
  });
25
- resumable.on('fileAdded', () => {
63
+ resumable.on('fileAdded', ()=>{
26
64
  resumable.upload();
27
65
  });
28
- resumable.on('fileProgress', resumableFile => {
66
+ resumable.on('fileProgress', (resumableFile)=>{
29
67
  if (resumableFile.isComplete()) {
30
68
  return;
31
69
  }
@@ -37,13 +75,13 @@ export class Uploader {
37
75
  handlers.progress(resumableFile.file, progress);
38
76
  }
39
77
  });
40
- resumable.on('fileSuccess', (resumableFile, message) => {
78
+ resumable.on('fileSuccess', (resumableFile, message)=>{
41
79
  if (handlers.success) {
42
80
  handlers.success(resumableFile.file, message);
43
81
  }
44
82
  resumableFile.cancel();
45
83
  });
46
- resumable.on('fileError', (resumableFile, message) => {
84
+ resumable.on('fileError', (resumableFile, message)=>{
47
85
  if (handlers.error) {
48
86
  handlers.error(resumableFile.file, errorParser ? errorParser(message) : message);
49
87
  }
@@ -51,28 +89,6 @@ export class Uploader {
51
89
  });
52
90
  this.resumable = resumable;
53
91
  }
54
- upload(source) {
55
- if (source instanceof File) {
56
- this.resumable.addFile(source);
57
- }
58
- else {
59
- for (const file of Array.from(source)) {
60
- this.resumable.addFile(file);
61
- }
62
- }
63
- }
64
- cancel(file) {
65
- if (file) {
66
- for (const resumableFile of this.resumable.files) {
67
- if (resumableFile.file === file) {
68
- resumableFile.cancel();
69
- break;
70
- }
71
- }
72
- }
73
- else {
74
- this.resumable.cancel();
75
- }
76
- }
77
92
  }
93
+
78
94
  //# sourceMappingURL=uploader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploader.js","sourceRoot":"","sources":["../../src/file-uploader/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAIlC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAoBzC,MAAM,OAAO,QAAQ;IAGjB,YACI,SAA6B,EAAE,EAC/B,WAII,EAAE,EACN,UAAU,GAAG,SAAS;QATT;;;;;WAAqB;QAWlC,MAAM,EAAE,WAAW,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,CAAC;QAEjD,MAAM,SAAS,GAAc,IAAI,SAAS,CAAC;YACvC,MAAM,EAAE,iCAAiC,UAAU,QAAQ;YAC3D,UAAU,EAAE,KAAK;YACjB,mBAAmB,EAAE,CAAC;YACtB,OAAO,EAAE,EAAE,kBAAkB,EAAE,gBAAgB,EAAE;YACjD,eAAe,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;YAC/C,wBAAwB,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE;YACtC,qBAAqB,EAAE,CAAC,IAAU,EAAE,EAAE;;gBAClC,MAAA,QAAQ,CAAC,KAAK,yDACV,IAAI,EACJ,sDAAsD,MAAA,MAAA,aAAa,CAAC,QAAQ,0CACtE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,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C,CAAC;YACrF,CAAC;YAED,aAAa,CAAC,MAAM,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,MAAuB;QAC1B,IAAI,MAAM,YAAY,IAAI,EAAE,CAAC;YACzB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACJ,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBACpC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACjC,CAAC;QACL,CAAC;IACL,CAAC;IAED,MAAM,CAAC,IAAW;QACd,IAAI,IAAI,EAAE,CAAC;YACP,KAAK,MAAM,aAAa,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;gBAC/C,IAAI,aAAa,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;oBAC9B,aAAa,CAAC,MAAM,EAAE,CAAC;oBACvB,MAAM;gBACV,CAAC;YACL,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QAC5B,CAAC;IACL,CAAC;CACJ"}
1
+ {"version":3,"sources":["../../src/file-uploader/uploader.ts"],"sourcesContent":["import { v4 as uuid } from 'uuid';\n\nimport { FileUploaderConfig } from './config';\n\nconst Resumable = require('resumablejs');\n\ninterface Resumable {\n files: ResumableFile[];\n on(event: 'fileAdded', callback: (file: ResumableFile, event: Event) => void): void;\n on(event: 'fileProgress', callback: (file: ResumableFile, message?: string) => void): void;\n on(event: 'fileSuccess', callback: (file: ResumableFile, message?: string) => void): void;\n on(event: 'fileError', callback: (file: ResumableFile, message?: string) => void): void;\n addFile(file: File): void;\n upload(): void;\n cancel(): void;\n}\n\ninterface ResumableFile {\n file: File;\n progress(relative?: boolean): number;\n isComplete(): boolean;\n cancel(): void;\n}\n\nexport class Uploader {\n private readonly resumable: Resumable;\n\n constructor(\n config: FileUploaderConfig = {},\n handlers: {\n progress?(file: File, progress: number): void;\n success?(file: File, message?: string): void;\n error?(file: File, message?: string): void;\n } = {},\n folderName = 'default'\n ) {\n const { errorParser, ...configuration } = config;\n\n const resumable: Resumable = new Resumable({\n target: `/app/api/fileuploader/folders/${folderName}/files`,\n testChunks: false,\n simultaneousUploads: 1,\n headers: { 'X-Requested-With': 'XMLHttpRequest' },\n permanentErrors: [302, 400, 404, 415, 500, 501],\n generateUniqueIdentifier: () => uuid(),\n fileTypeErrorCallback: (file: File) => {\n handlers.error?.(\n file,\n `File type not allowed. Please provide file of type ${configuration.fileType\n ?.map(ext => `.${ext}`)\n ?.join(', ')}.`\n );\n },\n ...configuration,\n });\n\n resumable.on('fileAdded', () => {\n resumable.upload();\n });\n\n resumable.on('fileProgress', resumableFile => {\n if (resumableFile.isComplete()) {\n return;\n }\n\n let progress = Math.floor(resumableFile.progress(false) * 100);\n if (progress > 99) {\n progress = 99;\n }\n\n if (handlers.progress) {\n handlers.progress(resumableFile.file, progress);\n }\n });\n\n resumable.on('fileSuccess', (resumableFile, message) => {\n if (handlers.success) {\n handlers.success(resumableFile.file, message);\n }\n\n resumableFile.cancel();\n });\n\n resumable.on('fileError', (resumableFile, message) => {\n if (handlers.error) {\n handlers.error(resumableFile.file, errorParser ? errorParser(message) : message);\n }\n\n resumableFile.cancel();\n });\n\n this.resumable = resumable;\n }\n\n upload(source: File | FileList) {\n if (source instanceof File) {\n this.resumable.addFile(source);\n } else {\n for (const file of Array.from(source)) {\n this.resumable.addFile(file);\n }\n }\n }\n\n cancel(file?: File) {\n if (file) {\n for (const resumableFile of this.resumable.files) {\n if (resumableFile.file === file) {\n resumableFile.cancel();\n break;\n }\n }\n } else {\n this.resumable.cancel();\n }\n }\n}\n"],"names":["v4","uuid","Resumable","require","Uploader","upload","source","File","resumable","addFile","file","Array","from","cancel","resumableFile","files","constructor","config","handlers","folderName","errorParser","configuration","target","testChunks","simultaneousUploads","headers","permanentErrors","generateUniqueIdentifier","fileTypeErrorCallback","error","fileType","map","ext","join","on","isComplete","progress","Math","floor","message","success"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,MAAMC,IAAI,QAAQ,OAAO;AAIlC,MAAMC,YAAYC,QAAQ;AAoB1B,OAAO,MAAMC;IAsETC,OAAOC,MAAuB,EAAE;QAC5B,IAAIA,kBAAkBC,MAAM;YACxB,IAAI,CAACC,SAAS,CAACC,OAAO,CAACH;QAC3B,OAAO;YACH,KAAK,MAAMI,QAAQC,MAAMC,IAAI,CAACN,QAAS;gBACnC,IAAI,CAACE,SAAS,CAACC,OAAO,CAACC;YAC3B;QACJ;IACJ;IAEAG,OAAOH,IAAW,EAAE;QAChB,IAAIA,MAAM;YACN,KAAK,MAAMI,iBAAiB,IAAI,CAACN,SAAS,CAACO,KAAK,CAAE;gBAC9C,IAAID,cAAcJ,IAAI,KAAKA,MAAM;oBAC7BI,cAAcD,MAAM;oBACpB;gBACJ;YACJ;QACJ,OAAO;YACH,IAAI,CAACL,SAAS,CAACK,MAAM;QACzB;IACJ;IAxFAG,YACIC,SAA6B,CAAC,CAAC,EAC/BC,WAII,CAAC,CAAC,EACNC,aAAa,SAAS,CACxB;QAVF,uBAAiBX,aAAjB,KAAA;QAWI,MAAM,EAAEY,WAAW,EAAE,GAAGC,eAAe,GAAGJ;QAE1C,MAAMT,YAAuB,IAAIN,UAAU;YACvCoB,QAAQ,CAAC,8BAA8B,EAAEH,WAAW,MAAM,CAAC;YAC3DI,YAAY;YACZC,qBAAqB;YACrBC,SAAS;gBAAE,oBAAoB;YAAiB;YAChDC,iBAAiB;gBAAC;gBAAK;gBAAK;gBAAK;gBAAK;gBAAK;aAAI;YAC/CC,0BAA0B,IAAM1B;YAChC2B,uBAAuB,CAAClB;oBAGsCW,6BAAAA,yBAF1DH;iBAAAA,kBAAAA,SAASW,KAAK,cAAdX,sCAAAA,qBAAAA,UACIR,MACA,CAAC,mDAAmD,GAAEW,0BAAAA,cAAcS,QAAQ,cAAtBT,+CAAAA,8BAAAA,wBAChDU,GAAG,CAACC,CAAAA,MAAO,CAAC,CAAC,EAAEA,KAAK,eAD4BX,kDAAAA,4BAEhDY,IAAI,CAAC,MAAM,CAAC,CAAC;YAE3B;YACA,GAAGZ,aAAa;QACpB;QAEAb,UAAU0B,EAAE,CAAC,aAAa;YACtB1B,UAAUH,MAAM;QACpB;QAEAG,UAAU0B,EAAE,CAAC,gBAAgBpB,CAAAA;YACzB,IAAIA,cAAcqB,UAAU,IAAI;gBAC5B;YACJ;YAEA,IAAIC,WAAWC,KAAKC,KAAK,CAACxB,cAAcsB,QAAQ,CAAC,SAAS;YAC1D,IAAIA,WAAW,IAAI;gBACfA,WAAW;YACf;YAEA,IAAIlB,SAASkB,QAAQ,EAAE;gBACnBlB,SAASkB,QAAQ,CAACtB,cAAcJ,IAAI,EAAE0B;YAC1C;QACJ;QAEA5B,UAAU0B,EAAE,CAAC,eAAe,CAACpB,eAAeyB;YACxC,IAAIrB,SAASsB,OAAO,EAAE;gBAClBtB,SAASsB,OAAO,CAAC1B,cAAcJ,IAAI,EAAE6B;YACzC;YAEAzB,cAAcD,MAAM;QACxB;QAEAL,UAAU0B,EAAE,CAAC,aAAa,CAACpB,eAAeyB;YACtC,IAAIrB,SAASW,KAAK,EAAE;gBAChBX,SAASW,KAAK,CAACf,cAAcJ,IAAI,EAAEU,cAAcA,YAAYmB,WAAWA;YAC5E;YAEAzB,cAAcD,MAAM;QACxB;QAEA,IAAI,CAACL,SAAS,GAAGA;IACrB;AAwBJ"}
@@ -2,9 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Banner } from '@servicetitan/design-system';
3
3
  import { traverseFormState } from '@servicetitan/form-state';
4
4
  import { observer } from 'mobx-react';
5
- export const FormStateErrorBanner = observer(({ form, className, errorTitle = 'Form Incomplete', successTitle = 'Form Complete', }) => {
5
+ export const FormStateErrorBanner = observer(({ form, className, errorTitle = 'Form Incomplete', successTitle = 'Form Complete' })=>{
6
6
  const errors = [];
7
- traverseFormState(true, form, (_0, formState) => {
7
+ traverseFormState(true, form, (_0, formState)=>{
8
8
  if (formState.formError) {
9
9
  errors.push(formState.formError);
10
10
  }
@@ -14,8 +14,18 @@ export const FormStateErrorBanner = observer(({ form, className, errorTitle = 'F
14
14
  }
15
15
  const status = errors.length === 0 ? 'success' : 'critical';
16
16
  const title = errors.length === 0 ? successTitle : errorTitle;
17
- return (_jsx(Banner, { className: className, status: status, icon: true, title: title, children: _jsx("ul", { children: errors.map((e, index) => (
18
- // eslint-disable-next-line react/no-array-index-key
19
- _jsx("li", { children: e }, index))) }) }));
17
+ return /*#__PURE__*/ _jsx(Banner, {
18
+ className: className,
19
+ status: status,
20
+ icon: true,
21
+ title: title,
22
+ children: /*#__PURE__*/ _jsx("ul", {
23
+ children: errors.map((e, index)=>// eslint-disable-next-line react/no-array-index-key
24
+ /*#__PURE__*/ _jsx("li", {
25
+ children: e
26
+ }, index))
27
+ })
28
+ });
20
29
  });
30
+
21
31
  //# sourceMappingURL=form-state-error-banner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-state-error-banner.js","sourceRoot":"","sources":["../../src/form-state-error-banner/form-state-error-banner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAUtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CACxC,CAAkC,EAC9B,IAAI,EACJ,SAAS,EACT,UAAU,GAAG,iBAAiB,EAC9B,YAAY,GAAG,eAAe,GACH,EAAE,EAAE;IAC/B,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE;QAC5C,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACrC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;IAC5D,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC;IAC9D,OAAO,CACH,KAAC,MAAM,IAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,QAAC,KAAK,EAAE,KAAK,YAC3D,uBACK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YACtB,oDAAoD;YACpD,uBAAiB,CAAC,IAAT,KAAK,CAAU,CAC3B,CAAC,GACD,GACA,CACZ,CAAC;AACN,CAAC,CACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/form-state-error-banner/form-state-error-banner.tsx"],"sourcesContent":["import { Banner } from '@servicetitan/design-system';\nimport { traverseFormState } from '@servicetitan/form-state';\nimport { observer } from 'mobx-react';\nimport { FormState, ValidatableMapOrArray } from 'formstate';\n\nexport interface FormStateErrorBannerProps<T extends ValidatableMapOrArray> {\n form: FormState<T>;\n className?: string;\n errorTitle?: string;\n successTitle?: string;\n}\n\nexport const FormStateErrorBanner = observer(\n <T extends ValidatableMapOrArray>({\n form,\n className,\n errorTitle = 'Form Incomplete',\n successTitle = 'Form Complete',\n }: FormStateErrorBannerProps<T>) => {\n const errors: string[] = [];\n traverseFormState(true, form, (_0, formState) => {\n if (formState.formError) {\n errors.push(formState.formError);\n }\n });\n if (form.formError) {\n errors.push(form.formError);\n }\n const status = errors.length === 0 ? 'success' : 'critical';\n const title = errors.length === 0 ? successTitle : errorTitle;\n return (\n <Banner className={className} status={status} icon title={title}>\n <ul>\n {errors.map((e, index) => (\n // eslint-disable-next-line react/no-array-index-key\n <li key={index}>{e}</li>\n ))}\n </ul>\n </Banner>\n );\n }\n);\n"],"names":["Banner","traverseFormState","observer","FormStateErrorBanner","form","className","errorTitle","successTitle","errors","_0","formState","formError","push","status","length","title","icon","ul","map","e","index","li"],"mappings":";AAAA,SAASA,MAAM,QAAQ,8BAA8B;AACrD,SAASC,iBAAiB,QAAQ,2BAA2B;AAC7D,SAASC,QAAQ,QAAQ,aAAa;AAUtC,OAAO,MAAMC,uBAAuBD,SAChC,CAAkC,EAC9BE,IAAI,EACJC,SAAS,EACTC,aAAa,iBAAiB,EAC9BC,eAAe,eAAe,EACH;IAC3B,MAAMC,SAAmB,EAAE;IAC3BP,kBAAkB,MAAMG,MAAM,CAACK,IAAIC;QAC/B,IAAIA,UAAUC,SAAS,EAAE;YACrBH,OAAOI,IAAI,CAACF,UAAUC,SAAS;QACnC;IACJ;IACA,IAAIP,KAAKO,SAAS,EAAE;QAChBH,OAAOI,IAAI,CAACR,KAAKO,SAAS;IAC9B;IACA,MAAME,SAASL,OAAOM,MAAM,KAAK,IAAI,YAAY;IACjD,MAAMC,QAAQP,OAAOM,MAAM,KAAK,IAAIP,eAAeD;IACnD,qBACI,KAACN;QAAOK,WAAWA;QAAWQ,QAAQA;QAAQG,IAAI;QAACD,OAAOA;kBACtD,cAAA,KAACE;sBACIT,OAAOU,GAAG,CAAC,CAACC,GAAGC,QACZ,oDAAoD;8BACpD,KAACC;8BAAgBF;mBAARC;;;AAK7B,GACF"}
@@ -1,2 +1,3 @@
1
1
  export * from './form-state-error-banner';
2
+
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/form-state-error-banner/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"sources":["../../src/form-state-error-banner/index.ts"],"sourcesContent":["export * from './form-state-error-banner';\n"],"names":[],"mappings":"AAAA,cAAc,4BAA4B"}
package/dist/index.js CHANGED
@@ -9,4 +9,5 @@ export * from './phone-number-input';
9
9
  export * from './original-number-input';
10
10
  export * from './input-date-mask';
11
11
  export * from '@servicetitan/form-state';
12
+
12
13
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAElC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './color-picker';\nexport * from './file-uploader';\nexport * from './form-state-error-banner';\nexport * from './label';\nexport * from './number-input';\nexport * from './masked-input';\nexport * from './date-range-picker';\nexport * from './phone-number-input';\nexport * from './original-number-input';\nexport * from './input-date-mask';\n\nexport * from '@servicetitan/form-state';\n"],"names":[],"mappings":"AAAA,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB;AAChC,cAAc,4BAA4B;AAC1C,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;AAC/B,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,0BAA0B;AACxC,cAAc,oBAAoB;AAElC,cAAc,2BAA2B"}
@@ -1,2 +1,3 @@
1
1
  export * from './input-date-mask';
2
+
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/input-date-mask/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"sources":["../../src/input-date-mask/index.ts"],"sourcesContent":["export * from './input-date-mask';\n"],"names":[],"mappings":"AAAA,cAAc,oBAAoB"}
@@ -8,20 +8,20 @@ import InputMask from 'react-input-mask';
8
8
  import classnames from 'classnames';
9
9
  import * as Styles from './input-date-mask.module.css';
10
10
  const KEY_DEL = 46;
11
- export const InputDateMask = observer(({ className, maskChar = 'X', alwaysShowMask, shortLabel, value, onChange, 'qa-testing': qaTestingLocator, error, disabled, placeholder, dateFormat = 'MM/DD/YYYY', minDate, maxDate, }) => {
12
- const state = useLocalStore(() => ({
13
- maskValue: '',
14
- setMask: action(function (mask) {
15
- this.maskValue = mask;
16
- }),
17
- }));
18
- const handleKeyDown = (evt) => {
11
+ export const InputDateMask = observer(({ className, maskChar = 'X', alwaysShowMask, shortLabel, value, onChange, 'qa-testing': qaTestingLocator, error, disabled, placeholder, dateFormat = 'MM/DD/YYYY', minDate, maxDate })=>{
12
+ const state = useLocalStore(()=>({
13
+ maskValue: '',
14
+ setMask: action(function(mask) {
15
+ this.maskValue = mask;
16
+ })
17
+ }));
18
+ const handleKeyDown = (evt)=>{
19
19
  if (evt.keyCode === KEY_DEL) {
20
20
  onChange(undefined);
21
21
  state.setMask('');
22
22
  }
23
23
  };
24
- const handleChange = (event) => {
24
+ const handleChange = (event)=>{
25
25
  const value = event.target.value;
26
26
  state.setMask(value);
27
27
  if (event.type === 'focus' || event.type === 'blur') {
@@ -29,45 +29,44 @@ export const InputDateMask = observer(({ className, maskChar = 'X', alwaysShowMa
29
29
  }
30
30
  if (isMaskValid(value)) {
31
31
  onChange(parseDate(value));
32
- }
33
- else {
32
+ } else {
34
33
  onChange(undefined);
35
34
  }
36
35
  };
37
- useEffect(() => {
36
+ useEffect(()=>{
38
37
  if (value === undefined && isMaskValid(state.maskValue)) {
39
38
  state.setMask('');
40
39
  }
41
- }, [value]); // eslint-disable-line react-hooks/exhaustive-deps
42
- const getMaskError = () => {
40
+ }, [
41
+ value
42
+ ]); // eslint-disable-line react-hooks/exhaustive-deps
43
+ const getMaskError = ()=>{
43
44
  return value === undefined && state.maskValue !== '' && isMaskInvalid(state.maskValue);
44
45
  };
45
- const getValueError = () => {
46
+ const getValueError = ()=>{
46
47
  return value !== undefined && !isDateInRange(value);
47
48
  };
48
- const formatDate = (date) => {
49
+ const formatDate = (date)=>{
49
50
  return date ? moment(date).format(dateFormat) : '';
50
51
  };
51
- const parseDate = (date) => {
52
+ const parseDate = (date)=>{
52
53
  return moment(date, dateFormat).toDate();
53
54
  };
54
- const isMaskValid = (mask) => {
55
+ const isMaskValid = (mask)=>{
55
56
  return !mask.includes(maskChar) && isDateStringValid(mask);
56
57
  };
57
- const isMaskInvalid = (mask) => {
58
+ const isMaskInvalid = (mask)=>{
58
59
  return !mask.includes(maskChar) && !isDateStringValid(mask);
59
60
  };
60
- const isDateStringValid = (date) => {
61
+ const isDateStringValid = (date)=>{
61
62
  return moment(date, dateFormat).isValid() && isDateInRange(parseDate(date));
62
63
  };
63
- const isDateInRange = (date) => {
64
+ const isDateInRange = (date)=>{
64
65
  if (minDate && maxDate) {
65
66
  return date >= minDate && date <= maxDate;
66
- }
67
- else if (minDate) {
67
+ } else if (minDate) {
68
68
  return date >= minDate;
69
- }
70
- else if (maxDate) {
69
+ } else if (maxDate) {
71
70
  return date <= maxDate;
72
71
  }
73
72
  return true;
@@ -76,9 +75,29 @@ export const InputDateMask = observer(({ className, maskChar = 'X', alwaysShowMa
76
75
  const realError = error || getMaskError() || getValueError();
77
76
  const realPlaceholder = placeholder || mask.replace(/9/g, maskChar);
78
77
  const classes = classnames(className, qaTestingLocator, Styles.input, {
79
- [Styles.error]: realError,
78
+ [Styles.error]: realError
79
+ });
80
+ const renderFunction = ({ size, ...props })=>/*#__PURE__*/ _jsx("div", {
81
+ children: /*#__PURE__*/ _jsx(Input, {
82
+ ...props,
83
+ shortLabel: shortLabel,
84
+ className: classes,
85
+ small: true,
86
+ fluid: true,
87
+ error: realError,
88
+ disabled: disabled,
89
+ placeholder: realPlaceholder
90
+ })
91
+ });
92
+ return /*#__PURE__*/ _jsx(InputMask, {
93
+ mask: mask,
94
+ maskChar: maskChar,
95
+ onChange: handleChange,
96
+ onKeyDown: handleKeyDown,
97
+ alwaysShowMask: alwaysShowMask,
98
+ value: formatDate(value) || state.maskValue,
99
+ children: renderFunction
80
100
  });
81
- const renderFunction = ({ size, ...props }) => (_jsx("div", { children: _jsx(Input, { ...props, shortLabel: shortLabel, className: classes, small: true, fluid: true, error: realError, disabled: disabled, placeholder: realPlaceholder }) }));
82
- return (_jsx(InputMask, { mask: mask, maskChar: maskChar, onChange: handleChange, onKeyDown: handleKeyDown, alwaysShowMask: alwaysShowMask, value: formatDate(value) || state.maskValue, children: renderFunction }));
83
101
  });
102
+
84
103
  //# sourceMappingURL=input-date-mask.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"input-date-mask.js","sourceRoot":"","sources":["../../src/input-date-mask/input-date-mask.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAmB,SAAS,EAA0C,MAAM,OAAO,CAAC;AAC3F,OAAO,EAAE,KAAK,EAAc,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,8BAA8B,CAAC;AAEvD,MAAM,OAAO,GAAG,EAAE,CAAC;AAkBnB,MAAM,CAAC,MAAM,aAAa,GAA8C,QAAQ,CAC5E,CAAC,EACG,SAAS,EACT,QAAQ,GAAG,GAAG,EACd,cAAc,EACd,U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AAS,YAE1C,cAAqB,GACd,CACf,CAAC;AACN,CAAC,CACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/input-date-mask/input-date-mask.tsx"],"sourcesContent":["import { FC, ChangeEvent, useEffect, InputHTMLAttributes, PropsWithChildren } from 'react';\nimport { Input, InputProps } from '@servicetitan/design-system';\nimport { action } from 'mobx';\nimport { useLocalStore, observer } from 'mobx-react';\nimport moment from 'moment';\nimport InputMask from 'react-input-mask';\nimport classnames from 'classnames';\nimport * as Styles from './input-date-mask.module.css';\n\nconst KEY_DEL = 46;\n\ninterface InputDateMaskStore {\n maskValue: string;\n setMask(maskValue: string): void;\n}\n\nexport interface InputDateMaskProps extends Omit<InputProps, 'onChange' | 'value'> {\n value?: Date;\n ['qa-testing']?: string;\n maskChar?: string;\n alwaysShowMask?: boolean;\n dateFormat?: string;\n minDate?: Date;\n maxDate?: Date;\n onChange(value: Date | undefined): void;\n}\n\nexport const InputDateMask: FC<PropsWithChildren<InputDateMaskProps>> = observer(\n ({\n className,\n maskChar = 'X',\n alwaysShowMask,\n shortLabel,\n value,\n onChange,\n 'qa-testing': qaTestingLocator,\n error,\n disabled,\n placeholder,\n dateFormat = 'MM/DD/YYYY',\n minDate,\n maxDate,\n }: InputDateMaskProps) => {\n const state = useLocalStore(() => ({\n maskValue: '',\n setMask: action(function (this: InputDateMaskStore, mask: string) {\n this.maskValue = mask;\n }),\n }));\n\n const handleKeyDown = (evt: any) => {\n if (evt.keyCode === KEY_DEL) {\n onChange(undefined);\n\n state.setMask('');\n }\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const value = event.target.value;\n\n state.setMask(value);\n\n if (event.type === 'focus' || event.type === 'blur') {\n return;\n }\n\n if (isMaskValid(value)) {\n onChange(parseDate(value));\n } else {\n onChange(undefined);\n }\n };\n\n useEffect(() => {\n if (value === undefined && isMaskValid(state.maskValue)) {\n state.setMask('');\n }\n }, [value]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const getMaskError = () => {\n return value === undefined && state.maskValue !== '' && isMaskInvalid(state.maskValue);\n };\n\n const getValueError = () => {\n return value !== undefined && !isDateInRange(value);\n };\n\n const formatDate = (date?: Date) => {\n return date ? moment(date).format(dateFormat) : '';\n };\n\n const parseDate = (date: string) => {\n return moment(date, dateFormat).toDate();\n };\n\n const isMaskValid = (mask: string) => {\n return !mask.includes(maskChar) && isDateStringValid(mask);\n };\n\n const isMaskInvalid = (mask: string) => {\n return !mask.includes(maskChar) && !isDateStringValid(mask);\n };\n\n const isDateStringValid = (date: string) => {\n return moment(date, dateFormat).isValid() && isDateInRange(parseDate(date));\n };\n\n const isDateInRange = (date: Date) => {\n if (minDate && maxDate) {\n return date >= minDate && date <= maxDate;\n } else if (minDate) {\n return date >= minDate;\n } else if (maxDate) {\n return date <= maxDate;\n }\n\n return true;\n };\n\n const mask = dateFormat.replace(/[MDY]/g, '9');\n\n const realError = error || getMaskError() || getValueError();\n\n const realPlaceholder = placeholder || mask.replace(/9/g, maskChar);\n\n const classes = classnames(className, qaTestingLocator, Styles.input, {\n [Styles.error]: realError,\n });\n\n const renderFunction = ({ size, ...props }: InputHTMLAttributes<HTMLInputElement>) => (\n <div>\n <Input\n {...props}\n shortLabel={shortLabel}\n className={classes}\n small\n fluid\n error={realError}\n disabled={disabled}\n placeholder={realPlaceholder}\n />\n </div>\n );\n\n return (\n <InputMask\n mask={mask}\n maskChar={maskChar}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n alwaysShowMask={alwaysShowMask}\n value={formatDate(value) || state.maskValue}\n >\n {renderFunction as any}\n </InputMask>\n );\n }\n);\n"],"names":["useEffect","Input","action","useLocalStore","observer","moment","InputMask","classnames","Styles","KEY_DEL","InputDateMask","className","maskChar","alwaysShowMask","shortLabel","value","onChange","qaTestingLocator","error","disabled","placeholder","dateFormat","minDate","maxDate","state","maskValue","setMask","mask","handleKeyDown","evt","keyCode","undefined","handleChange","event","target","type","isMaskValid","parseDate","getMaskError","isMaskInvalid","getValueError","isDateInRange","formatDate","date","format","toDate","includes","isDateStringValid","isValid","replace","realError","realPlaceholder","classes","input","renderFunction","size","props","div","small","fluid","onKeyDown"],"mappings":";AAAA,SAA0BA,SAAS,QAAgD,QAAQ;AAC3F,SAASC,KAAK,QAAoB,8BAA8B;AAChE,SAASC,MAAM,QAAQ,OAAO;AAC9B,SAASC,aAAa,EAAEC,QAAQ,QAAQ,aAAa;AACrD,OAAOC,YAAY,SAAS;AAC5B,OAAOC,eAAe,mBAAmB;AACzC,OAAOC,gBAAgB,aAAa;AACpC,YAAYC,YAAY,+BAA+B;AAEvD,MAAMC,UAAU;AAkBhB,OAAO,MAAMC,gBAA2DN,SACpE,CAAC,EACGO,SAAS,EACTC,WAAW,GAAG,EACdC,cAAc,EACdC,UAAU,EACVC,KAAK,EACLC,QAAQ,EACR,cAAcC,gBAAgB,EAC9BC,KAAK,EACLC,QAAQ,EACRC,WAAW,EACXC,aAAa,YAAY,EACzBC,OAAO,EACPC,OAAO,EACU;IACjB,MAAMC,QAAQrB,cAAc,IAAO,CAAA;YAC/BsB,WAAW;YACXC,SAASxB,OAAO,SAAoCyB,IAAY;gBAC5D,IAAI,CAACF,SAAS,GAAGE;YACrB;QACJ,CAAA;IAEA,MAAMC,gBAAgB,CAACC;QACnB,IAAIA,IAAIC,OAAO,KAAKrB,SAAS;YACzBO,SAASe;YAETP,MAAME,OAAO,CAAC;QAClB;IACJ;IAEA,MAAMM,eAAe,CAACC;QAClB,MAAMlB,QAAQkB,MAAMC,MAAM,CAACnB,KAAK;QAEhCS,MAAME,OAAO,CAACX;QAEd,IAAIkB,MAAME,IAAI,KAAK,WAAWF,MAAME,IAAI,KAAK,QAAQ;YACjD;QACJ;QAEA,IAAIC,YAAYrB,QAAQ;YACpBC,SAASqB,UAAUtB;QACvB,OAAO;YACHC,SAASe;QACb;IACJ;IAEA/B,UAAU;QACN,IAAIe,UAAUgB,aAAaK,YAAYZ,MAAMC,SAAS,GAAG;YACrDD,MAAME,OAAO,CAAC;QAClB;I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G,cAAA,KAACxD;gBACI,GAAGuD,KAAK;gBACT1C,YAAYA;gBACZH,WAAWyC;gBACXM,KAAK;gBACLC,KAAK;gBACLzC,OAAOgC;gBACP/B,UAAUA;gBACVC,aAAa+B;;;IAKzB,qBACI,KAAC7C;QACGqB,MAAMA;QACNf,UAAUA;QACVI,UAAUgB;QACV4B,WAAWhC;QACXf,gBAAgBA;QAChBE,OAAO2B,WAAW3B,UAAUS,MAAMC,SAAS;kBAE1C6B;;AAGb,GACF"}
@@ -0,0 +1,4 @@
1
+ export const __esModule: true;
2
+ export const error: string;
3
+ export const input: string;
4
+
@@ -1,2 +1,3 @@
1
1
  export * from './label';
2
+
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/label/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
1
+ {"version":3,"sources":["../../src/label/index.ts"],"sourcesContent":["export * from './label';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU"}
@@ -2,5 +2,33 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import classNames from 'classnames';
3
3
  import { Stack, Icon, Text, Tooltip } from '@servicetitan/design-system';
4
4
  import * as Styles from './label.module.css';
5
- export const Label = ({ label, tooltip, tooltipDirection = 'r', hasError, error, }) => (_jsxs("div", { className: classNames(Styles.label, hasError && Styles.hasError), children: [_jsxs(Stack, { className: Styles.text, children: [_jsx(Stack.Item, { children: label }), tooltip && (_jsx(Stack.Item, { className: Styles.tooltip, children: _jsx(Tooltip, { direction: tooltipDirection, text: tooltip, children: _jsx(Icon, { name: "info" }) }) }))] }), hasError && (_jsx(Text, { className: Styles.error, size: 1, children: error }))] }));
5
+ export const Label = ({ label, tooltip, tooltipDirection = 'r', hasError, error })=>/*#__PURE__*/ _jsxs("div", {
6
+ className: classNames(Styles.label, hasError && Styles.hasError),
7
+ children: [
8
+ /*#__PURE__*/ _jsxs(Stack, {
9
+ className: Styles.text,
10
+ children: [
11
+ /*#__PURE__*/ _jsx(Stack.Item, {
12
+ children: label
13
+ }),
14
+ tooltip && /*#__PURE__*/ _jsx(Stack.Item, {
15
+ className: Styles.tooltip,
16
+ children: /*#__PURE__*/ _jsx(Tooltip, {
17
+ direction: tooltipDirection,
18
+ text: tooltip,
19
+ children: /*#__PURE__*/ _jsx(Icon, {
20
+ name: "info"
21
+ })
22
+ })
23
+ })
24
+ ]
25
+ }),
26
+ hasError && /*#__PURE__*/ _jsx(Text, {
27
+ className: Styles.error,
28
+ size: 1,
29
+ children: error
30
+ })
31
+ ]
32
+ });
33
+
6
34
  //# sourceMappingURL=label.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/label/label.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AA4B7C,MAAM,CAAC,MAAM,KAAK,GAAmB,CAAC,EAClC,KAAK,EACL,OAAO,EACP,gBAAgB,GAAG,GAAG,EACtB,QAAQ,EACR,KAAK,GACR,EAAE,EAAE,CAAC,CACF,eAAK,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,aACjE,MAAC,KAAK,IAAC,SAAS,EAAE,MAAM,CAAC,IAAI,aACzB,KAAC,KAAK,CAAC,IAAI,cAAE,KAAK,GAAc,EAC/B,OAAO,IAAI,CACR,KAAC,KAAK,CAAC,IAAI,IAAC,SAAS,EAAE,MAAM,CAAC,OAAO,YACjC,KAAC,OAAO,IAAC,SAAS,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,YAC/C,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,GACd,GACD,CAChB,IACG,EACP,QAAQ,IAAI,CACT,KAAC,IAAI,IAAC,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,YACjC,KAAK,GACH,CACV,IACC,CACT,CAAC"}
1
+ {"version":3,"sources":["../../src/label/label.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { FC } from 'react';\nimport { Stack, Icon, Text, Tooltip } from '@servicetitan/design-system';\n\nimport * as Styles from './label.module.css';\n\ntype Direction =\n | 'top'\n | 't'\n | 'right'\n | 'r'\n | 'bottom'\n | 'b'\n | 'left'\n | 'l'\n | 'topleft'\n | 'tl'\n | 'topright'\n | 'tr'\n | 'bottomleft'\n | 'bl'\n | 'bottomright'\n | 'br';\n\ninterface LabelProps {\n label: string;\n tooltip?: string;\n tooltipDirection?: Direction;\n hasError?: boolean;\n error?: string;\n}\n\nexport const Label: FC<LabelProps> = ({\n label,\n tooltip,\n tooltipDirection = 'r',\n hasError,\n error,\n}) => (\n <div className={classNames(Styles.label, hasError && Styles.hasError)}>\n <Stack className={Styles.text}>\n <Stack.Item>{label}</Stack.Item>\n {tooltip && (\n <Stack.Item className={Styles.tooltip}>\n <Tooltip direction={tooltipDirection} text={tooltip}>\n <Icon name=\"info\" />\n </Tooltip>\n </Stack.Item>\n )}\n </Stack>\n {hasError && (\n <Text className={Styles.error} size={1}>\n {error}\n </Text>\n )}\n </div>\n);\n"],"names":["classNames","Stack","Icon","Text","Tooltip","Styles","Label","label","tooltip","tooltipDirection","hasError","error","div","className","text","Item","direction","name","size"],"mappings":";AAAA,OAAOA,gBAAgB,aAAa;AAEpC,SAASC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,QAAQ,8BAA8B;AAEzE,YAAYC,YAAY,qBAAqB;AA4B7C,OAAO,MAAMC,QAAwB,CAAC,EAClCC,KAAK,EACLC,OAAO,EACPC,mBAAmB,GAAG,EACtBC,QAAQ,EACRC,KAAK,EACR,iBACG,MAACC;QAAIC,WAAWb,WAAWK,OAAOE,KAAK,EAAEG,YAAYL,OAAOK,QAAQ;;0BAChE,MAACT;gBAAMY,WAAWR,OAAOS,IAAI;;kCACzB,KAACb,MAAMc,IAAI;kCAAER;;oBACZC,yBACG,KAACP,MAAMc,IAAI;wBAACF,WAAWR,OAAOG,OAAO;kCACjC,cAAA,KAACJ;4BAAQY,WAAWP;4BAAkBK,MAAMN;sCACxC,cAAA,KAACN;gCAAKe,MAAK;;;;;;YAK1BP,0BACG,KAACP;gBAAKU,WAAWR,OAAOM,KAAK;gBAAEO,MAAM;0BAChCP;;;OAIf"}
@@ -0,0 +1,7 @@
1
+ export const __esModule: true;
2
+ export const error: string;
3
+ export const hasError: string;
4
+ export const label: string;
5
+ export const text: string;
6
+ export const tooltip: string;
7
+
@@ -1,11 +1,24 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import ReactInputMask from 'react-input-mask';
3
3
  import { Form } from '@servicetitan/design-system';
4
- export const MaskedInput = ({ mask, maskChar, value, onChange, placeholder, disabled, formatChars, ...props }) => {
5
- const handleInputChange = (e) => {
4
+ export const MaskedInput = ({ mask, maskChar, value, onChange, placeholder, disabled, formatChars, ...props })=>{
5
+ const handleInputChange = (e)=>{
6
6
  onChange(e.target.value);
7
7
  };
8
- const renderFunction = (innerProps) => (_jsx(Form.Input, { ...props, ...innerProps }));
9
- return (_jsx(ReactInputMask, { mask: mask, maskChar: maskChar, value: value, onChange: handleInputChange, placeholder: placeholder, disabled: disabled, formatChars: formatChars, children: renderFunction }));
8
+ const renderFunction = (innerProps)=>/*#__PURE__*/ _jsx(Form.Input, {
9
+ ...props,
10
+ ...innerProps
11
+ });
12
+ return /*#__PURE__*/ _jsx(ReactInputMask, {
13
+ mask: mask,
14
+ maskChar: maskChar,
15
+ value: value,
16
+ onChange: handleInputChange,
17
+ placeholder: placeholder,
18
+ disabled: disabled,
19
+ formatChars: formatChars,
20
+ children: renderFunction
21
+ });
10
22
  };
23
+
11
24
  //# sourceMappingURL=masked-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"masked-input.js","sourceRoot":"","sources":["../src/masked-input.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAkD,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,IAAI,EAAkB,MAAM,6BAA6B,CAAC;AAKnE,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,EAC9C,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,WAAW,EACX,GAAG,KAAK,EACX,EAAE,EAAE;IACD,MAAM,iBAAiB,GAAG,CAAC,CAAgC,EAAE,EAAE;QAC3D,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,CAAC,UAAiD,EAAE,EAAE,CAAC,CAC1E,KAAC,IAAI,CAAC,KAAK,OAAK,KAAK,KAAM,UAAU,GAAI,CAC5C,CAAC;IAEF,OAAO,CACH,KAAC,cAAc,IACX,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,YAEvB,cAAqB,GACT,CACpB,CAAC;AACN,CAAC,CAAC"}
1
+ {"version":3,"sources":["../src/masked-input.tsx"],"sourcesContent":["import { FC, InputHTMLAttributes, ChangeEvent } from 'react';\r\n\r\nimport ReactInputMask, { Props as ReactMaskedInputProps } from 'react-input-mask';\r\nimport { Form, FormInputProps } from '@servicetitan/design-system';\r\n\r\ntype MaskedInputProps = FormInputProps &\r\n Omit<ReactMaskedInputProps, keyof InputHTMLAttributes<HTMLInputElement>>;\r\n\r\nexport const MaskedInput: FC<MaskedInputProps> = ({\r\n mask,\r\n maskChar,\r\n value,\r\n onChange,\r\n placeholder,\r\n disabled,\r\n formatChars,\r\n ...props\r\n}) => {\r\n const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {\r\n onChange(e.target.value);\r\n };\r\n\r\n const renderFunction = (innerProps: InputHTMLAttributes<HTMLInputElement>) => (\r\n <Form.Input {...props} {...innerProps} />\r\n );\r\n\r\n return (\r\n <ReactInputMask\r\n mask={mask}\r\n maskChar={maskChar}\r\n value={value}\r\n onChange={handleInputChange}\r\n placeholder={placeholder}\r\n disabled={disabled}\r\n formatChars={formatChars}\r\n >\r\n {renderFunction as any}\r\n </ReactInputMask>\r\n );\r\n};\r\n"],"names":["ReactInputMask","Form","MaskedInput","mask","maskChar","value","onChange","placeholder","disabled","formatChars","props","handleInputChange","e","target","renderFunction","innerProps","Input"],"mappings":";AAEA,OAAOA,oBAAwD,mBAAmB;AAClF,SAASC,IAAI,QAAwB,8BAA8B;AAKnE,OAAO,MAAMC,cAAoC,CAAC,EAC9CC,IAAI,EACJC,QAAQ,EACRC,KAAK,EACLC,QAAQ,EACRC,WAAW,EACXC,QAAQ,EACRC,WAAW,EACX,GAAGC,OACN;IACG,MAAMC,oBAAoB,CAACC;QACvBN,SAASM,EAAEC,MAAM,CAACR,KAAK;IAC3B;IAEA,MAAMS,iBAAiB,CAACC,2BACpB,KAACd,KAAKe,KAAK;YAAE,GAAGN,KAAK;YAAG,GAAGK,UAAU;;IAGzC,qBACI,KAACf;QACGG,MAAMA;QACNC,UAAUA;QACVC,OAAOA;QACPC,UAAUK;QACVJ,aAAaA;QACbC,UAAUA;QACVC,aAAaA;kBAEZK;;AAGb,EAAE"}
@@ -1,2 +1,3 @@
1
- export {};
1
+ export { };
2
+
2
3
  //# sourceMappingURL=common-interfaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common-interfaces.js","sourceRoot":"","sources":["../../src/number-input/common-interfaces.ts"],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../../src/number-input/common-interfaces.ts"],"sourcesContent":["export type EmptyValue = 0 | undefined;\nexport type NumberValue<TEmpty extends EmptyValue> = TEmpty extends 0 ? number : number | undefined;\n\nexport interface Range {\n min?: number;\n max?: number;\n}\n\nexport interface Separators {\n thousand: string;\n decimal: string;\n}\n"],"names":[],"mappings":"AAQA,WAGC"}
@@ -1,7 +1,6 @@
1
1
  import { formatNumber as formatNumberDefault } from 'accounting';
2
2
  export function getFormattedString(value, { emptyValue, precision, separators }, formatNumber = formatNumberDefault) {
3
- return typeof value === 'number' || emptyValue === 0
4
- ? formatNumber((typeof value === 'number' ? value : emptyValue), precision !== null && precision !== void 0 ? precision : 0, separators.thousand, separators.decimal)
5
- : '';
3
+ return typeof value === 'number' || emptyValue === 0 ? formatNumber(typeof value === 'number' ? value : emptyValue, precision !== null && precision !== void 0 ? precision : 0, separators.thousand, separators.decimal) : '';
6
4
  }
5
+
7
6
  //# sourceMappingURL=get-formatted-string.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-formatted-string.js","sourceRoot":"","sources":["../../src/number-input/get-formatted-string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAiBjE,MAAM,UAAU,kBAAkB,CAC9B,KAA0B,EAC1B,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAqC,EACxE,eAA6B,mBAAmB;IAEhD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,UAAU,KAAK,CAAC;QAChD,CAAC,CAAC,YAAY,CACR,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAW,EAC1D,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,CAAC,EACd,UAAU,CAAC,QAAQ,EACnB,UAAU,CAAC,OAAO,CACrB;QACH,CAAC,CAAC,EAAE,CAAC;AACb,CAAC"}
1
+ {"version":3,"sources":["../../src/number-input/get-formatted-string.ts"],"sourcesContent":["import { formatNumber as formatNumberDefault } from 'accounting';\n\nimport { EmptyValue, NumberValue, Separators } from './common-interfaces';\n\nexport type FormatNumber = (\n value: number,\n precision?: number,\n thousand?: string,\n decimal?: string\n) => string;\n\ninterface GetFormattedStringOptions<TEmpty extends EmptyValue> {\n emptyValue: TEmpty;\n precision?: number;\n separators: Separators;\n}\n\nexport function getFormattedString<TEmpty extends EmptyValue>(\n value: NumberValue<TEmpty>,\n { emptyValue, precision, separators }: GetFormattedStringOptions<TEmpty>,\n formatNumber: FormatNumber = formatNumberDefault\n) {\n return typeof value === 'number' || emptyValue === 0\n ? formatNumber(\n (typeof value === 'number' ? value : emptyValue) as number,\n precision ?? 0,\n separators.thousand,\n separators.decimal\n )\n : '';\n}\n"],"names":["formatNumber","formatNumberDefault","getFormattedString","value","emptyValue","precision","separators","thousand","decimal"],"mappings":"AAAA,SAASA,gBAAgBC,mBAAmB,QAAQ,aAAa;AAiBjE,OAAO,SAASC,mBACZC,KAA0B,EAC1B,EAAEC,UAAU,EAAEC,SAAS,EAAEC,UAAU,EAAqC,EACxEN,eAA6BC,mBAAmB;IAEhD,OAAO,OAAOE,UAAU,YAAYC,eAAe,IAC7CJ,aACK,OAAOG,UAAU,WAAWA,QAAQC,YACrCC,sBAAAA,uBAAAA,YAAa,GACbC,WAAWC,QAAQ,EACnBD,WAAWE,OAAO,IAEtB;AACV"}
@@ -1,2 +1,3 @@
1
1
  export * from './number-input';
2
+
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/number-input/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"sources":["../../src/number-input/index.ts"],"sourcesContent":["export * from './number-input';\n"],"names":[],"mappings":"AAAA,cAAc,iBAAiB"}