superdesk-ui-framework 3.0.1-beta.3 → 3.0.1-beta.6

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 (100) hide show
  1. package/app/styles/_sd-tag-input.scss +201 -296
  2. package/app/styles/components/_list-item.scss +13 -1
  3. package/app/styles/components/_sd-photo-preview.scss +1 -1
  4. package/app/styles/design-tokens/_new-colors.scss +1 -1
  5. package/app/styles/form-elements/_forms-general.scss +22 -7
  6. package/app/styles/form-elements/_inputs.scss +133 -54
  7. package/app-typescript/components/Badge.tsx +3 -2
  8. package/app-typescript/components/DatePicker.tsx +40 -52
  9. package/app-typescript/components/DurationInput.tsx +342 -0
  10. package/app-typescript/components/Form/InputBase.tsx +85 -0
  11. package/app-typescript/components/Form/InputNew.tsx +107 -0
  12. package/app-typescript/components/Form/InputWrapper.tsx +79 -0
  13. package/app-typescript/components/Form/index.tsx +3 -0
  14. package/app-typescript/components/Input.tsx +28 -45
  15. package/app-typescript/components/Label.tsx +49 -10
  16. package/app-typescript/components/Layouts/Layout.tsx +1 -1
  17. package/app-typescript/components/Lists/ContentList.tsx +4 -4
  18. package/app-typescript/components/MultiSelect.tsx +37 -50
  19. package/app-typescript/components/Navigation/BottomNav.tsx +3 -2
  20. package/app-typescript/components/Select.tsx +23 -41
  21. package/app-typescript/components/SelectWithTemplate.tsx +32 -7
  22. package/app-typescript/components/TimePicker.tsx +48 -16
  23. package/app-typescript/components/TreeSelect.tsx +423 -195
  24. package/app-typescript/index.ts +4 -1
  25. package/dist/examples.bundle.js +16733 -15633
  26. package/dist/playgrounds/react-playgrounds/CoreLayout.tsx +64 -54
  27. package/dist/playgrounds/react-playgrounds/RundownEditor.tsx +24 -16
  28. package/dist/playgrounds/react-playgrounds/TestGround.tsx +76 -1
  29. package/dist/playgrounds/react-playgrounds/components/Layout.tsx +1 -1
  30. package/dist/react/Badges.tsx +18 -0
  31. package/dist/react/ContentList.tsx +15 -9
  32. package/dist/react/DatePicker.tsx +21 -1
  33. package/dist/react/DurationInput.tsx +104 -0
  34. package/dist/react/Index.tsx +5 -0
  35. package/dist/react/Inputs.tsx +153 -2
  36. package/dist/react/Labels.tsx +51 -1
  37. package/dist/react/MultiSelect.tsx +4 -1
  38. package/dist/react/SelectWithTemplate.tsx +6 -1
  39. package/dist/react/TableList.tsx +22 -44
  40. package/dist/react/TimePicker.tsx +16 -8
  41. package/dist/react/TreeSelect.tsx +301 -48
  42. package/dist/react/tree-select/TreeSelect.tsx +273 -0
  43. package/dist/react/tree-select/example-1.tsx +71 -0
  44. package/dist/react/tree-select/example-2.tsx +59 -0
  45. package/dist/superdesk-ui.bundle.css +413 -370
  46. package/dist/superdesk-ui.bundle.js +15879 -14782
  47. package/dist/vendor.bundle.js +27 -27
  48. package/examples/pages/playgrounds/react-playgrounds/CoreLayout.tsx +64 -54
  49. package/examples/pages/playgrounds/react-playgrounds/RundownEditor.tsx +24 -16
  50. package/examples/pages/playgrounds/react-playgrounds/TestGround.tsx +76 -1
  51. package/examples/pages/playgrounds/react-playgrounds/components/Layout.tsx +1 -1
  52. package/examples/pages/react/Badges.tsx +18 -0
  53. package/examples/pages/react/ContentList.tsx +15 -9
  54. package/examples/pages/react/DatePicker.tsx +21 -1
  55. package/examples/pages/react/DurationInput.tsx +104 -0
  56. package/examples/pages/react/Index.tsx +5 -0
  57. package/examples/pages/react/Inputs.tsx +153 -2
  58. package/examples/pages/react/Labels.tsx +51 -1
  59. package/examples/pages/react/MultiSelect.tsx +4 -1
  60. package/examples/pages/react/SelectWithTemplate.tsx +6 -1
  61. package/examples/pages/react/TableList.tsx +22 -44
  62. package/examples/pages/react/TimePicker.tsx +16 -8
  63. package/examples/pages/react/TreeSelect.tsx +301 -48
  64. package/examples/pages/react/tree-select/TreeSelect.tsx +273 -0
  65. package/examples/pages/react/tree-select/example-1.tsx +71 -0
  66. package/examples/pages/react/tree-select/example-2.tsx +59 -0
  67. package/package.json +2 -1
  68. package/patches/@superdesk+primereact+5.0.2-4.patch +10 -1
  69. package/react/components/Badge.d.ts +1 -0
  70. package/react/components/Badge.js +2 -2
  71. package/react/components/DatePicker.d.ts +1 -0
  72. package/react/components/DatePicker.js +6 -22
  73. package/react/components/DurationInput.d.ts +41 -0
  74. package/react/components/DurationInput.js +303 -0
  75. package/react/components/Form/InputBase.d.ts +42 -0
  76. package/react/components/Form/InputBase.js +72 -0
  77. package/react/components/Form/InputNew.d.ts +45 -0
  78. package/react/components/Form/InputNew.js +75 -0
  79. package/react/components/Form/InputWrapper.d.ts +28 -0
  80. package/react/components/Form/InputWrapper.js +91 -0
  81. package/react/components/Form/index.d.ts +3 -0
  82. package/react/components/Form/index.js +7 -1
  83. package/react/components/Input.js +5 -34
  84. package/react/components/Label.d.ts +1 -0
  85. package/react/components/Label.js +18 -2
  86. package/react/components/Layouts/Layout.js +1 -1
  87. package/react/components/Lists/ContentList.d.ts +45 -0
  88. package/react/components/Lists/ContentList.js +85 -0
  89. package/react/components/Navigation/BottomNav.d.ts +1 -0
  90. package/react/components/Navigation/BottomNav.js +2 -2
  91. package/react/components/Select.d.ts +1 -1
  92. package/react/components/Select.js +4 -26
  93. package/react/components/SelectWithTemplate.d.ts +11 -1
  94. package/react/components/SelectWithTemplate.js +19 -10
  95. package/react/components/TimePicker.d.ts +15 -2
  96. package/react/components/TimePicker.js +15 -4
  97. package/react/components/TreeSelect.d.ts +75 -0
  98. package/react/components/TreeSelect.js +448 -0
  99. package/react/index.d.ts +4 -0
  100. package/react/index.js +10 -3
@@ -81,13 +81,6 @@
81
81
  margin-bottom: 1rem;
82
82
  margin-right: 0;
83
83
  }
84
- & + div {
85
- margin-top: .4rem;
86
-
87
- .label {
88
- margin-bottom: .3rem;
89
- }
90
- }
91
84
  }
92
85
  }
93
86
  .label--active {
@@ -260,3 +253,25 @@
260
253
  background-color: var(--color-form-bg);
261
254
  color: var(--color-text);
262
255
  }
256
+
257
+
258
+ /// ---------------------------- NEW FORM LAYOUT TEST---------------------------- ///
259
+
260
+
261
+
262
+ .form__group-new {
263
+ display: flex;
264
+ flex-direction: row;
265
+ width:100%;
266
+ align-items: flex-start;
267
+ gap: $sd-base-increment * 2;
268
+ .sd-input {
269
+ flex: 1 1 0;
270
+ min-width: 12rem;
271
+ margin: 0;
272
+ }
273
+ .btn {
274
+ flex: 0 0 auto;
275
+ margin-top: $form-label-height;
276
+ }
277
+ }
@@ -471,12 +471,18 @@
471
471
  grid-template-rows: $form-label-height auto auto;
472
472
  grid-gap: 0;
473
473
  position: relative;
474
+ align-self: stretch;
475
+
474
476
 
475
477
  .sd-input__input {
476
478
  @include Line-input-base;
477
479
  grid-row: 2/3;
478
480
  grid-column: 2/4;
479
481
  }
482
+ .sd-input__input-container {
483
+ grid-row: 2/3;
484
+ grid-column: 2/4;
485
+ }
480
486
 
481
487
  textarea {
482
488
  &.sd-input__input {
@@ -687,6 +693,24 @@
687
693
  }
688
694
  }
689
695
  }
696
+ div {
697
+ &.sd-input__duration-input, &.sd-input__duration-input:hover, &.sd-input__duration-input:focus {
698
+ opacity: 0.5;
699
+ //background-color: var(--color-input-bg);
700
+ //border-bottom: 1px dotted var(--color-input-border);
701
+ cursor: not-allowed !important;
702
+ box-shadow: none;
703
+ }
704
+ input {
705
+ &.duration-input, &.duration-input:hover, &.duration-input:focus {
706
+ opacity: 0.5;
707
+ //background-color: var(--color-input-bg);
708
+ //border-bottom: 1px dotted var(--color-input-border);
709
+ cursor: not-allowed !important;
710
+ box-shadow: none;
711
+ }
712
+ }
713
+ }
690
714
  .sd-input__label, .sd-input__message-box, .sd-input__char-count {
691
715
  opacity: 0.5 !important;
692
716
  pointer-events: none !important;
@@ -704,6 +728,54 @@
704
728
  flex-grow: 1;
705
729
  width: 100%;
706
730
  }
731
+
732
+ &--medium {
733
+ &.sd-input--boxed-style {
734
+ .sd-input__input,
735
+ .sd-input__select {
736
+ border-radius: var(--b-radius--medium);
737
+ &:focus {
738
+ box-shadow: inset 0 0 0 3px var(--sd-colour-interactive--alpha-20);
739
+ }
740
+ }
741
+ }
742
+ }
743
+ &--large {
744
+ .sd-input__input,
745
+ .sd-input__select {
746
+ padding: 0 1.6rem;
747
+ min-height: 4.8rem;
748
+ font-size: 2.4rem;
749
+ font-weight: 500;
750
+ }
751
+ .sd-input__select {
752
+ line-height: 2.4rem;
753
+ option {
754
+ color: var(--color-text);
755
+ font-size: 1.4rem !important;
756
+ line-height: 2rem;
757
+ background-color: var(--color-dropdown-menu-Bg);
758
+ }
759
+ }
760
+ }
761
+ &--x-large {
762
+ .sd-input__input,
763
+ .sd-input__select {
764
+ padding: 0 1.6rem;
765
+ min-height: 5.6rem;
766
+ font-size: 3.2rem;
767
+ font-weight: 500;
768
+ }
769
+ .sd-input__select {
770
+ line-height: 3.2rem;
771
+ option {
772
+ color: var(--color-text);
773
+ font-size: 1.4rem !important;
774
+ line-height: 2rem;
775
+ background-color: var(--color-dropdown-menu-Bg);
776
+ }
777
+ }
778
+ }
707
779
  &--boxed-style {
708
780
  .sd-input__input,
709
781
  .sd-input__select {
@@ -724,18 +796,23 @@
724
796
  background-color: transparent;
725
797
  }
726
798
  }
799
+
727
800
  &.sd-input--disabled {
728
- input, textarea {
729
- &.sd-input__input, &.sd-input__input:hover, &.sd-input__input:focus {
801
+ input,
802
+ textarea {
803
+ &.sd-input__input,
804
+ &.sd-input__input:hover,
805
+ &.sd-input__input:focus {
730
806
  opacity: 0.5;
731
807
  background-color: transparent;
732
808
  border: 2px solid var(--color-input-border) !important;
733
- //cursor: not-allowed !important;
734
809
  box-shadow: none;
735
810
  }
736
811
  }
737
812
  select {
738
- &.sd-input__select, &.sd-input__select:hover, &.sd-input__select:focus {
813
+ &.sd-input__select,
814
+ &.sd-input__select:hover,
815
+ &.sd-input__select:focus {
739
816
  opacity: 0.5;
740
817
  background-color: transparent;
741
818
  border: 2px solid var(--color-input-border) !important;
@@ -743,8 +820,17 @@
743
820
  box-shadow: none;
744
821
  }
745
822
  }
746
- .sd-input__label, .sd-input__message-box, .sd-input__char-count {
747
- opacity: 0.5;
823
+ .tags-input__add-button {
824
+ pointer-events: none;
825
+ }
826
+ .sd-input__label,
827
+ .sd-input__message-box,
828
+ .sd-input__char-count {
829
+ .sd-input__label,
830
+ .sd-input__message-box,
831
+ .sd-input__char-count {
832
+ opacity: 0.5;
833
+ }
748
834
  }
749
835
  .sd-input__hint,
750
836
  .sd-input__message,
@@ -752,6 +838,7 @@
752
838
  pointer-events: none;
753
839
  }
754
840
  }
841
+
755
842
  &.sd-input--invalid {
756
843
  input, textarea {
757
844
  &.sd-input__input {
@@ -774,53 +861,6 @@
774
861
  }
775
862
  }
776
863
  }
777
- &--medium {
778
- &.sd-input--boxed-style {
779
- .sd-input__input,
780
- .sd-input__select {
781
- border-radius: var(--b-radius--medium);
782
- &:focus {
783
- box-shadow: inset 0 0 0 3px var(--sd-colour-interactive--alpha-20);
784
- }
785
- }
786
- }
787
- }
788
- &--large {
789
- .sd-input__input,
790
- .sd-input__select {
791
- padding: 0 1.6rem;
792
- min-height: 4.8rem;
793
- font-size: 2.4rem;
794
- font-weight: 500;
795
- }
796
- .sd-input__select {
797
- line-height: 2.4rem;
798
- option {
799
- color: var(--color-text);
800
- font-size: 1.4rem !important;
801
- line-height: 2rem;
802
- background-color: var(--color-dropdown-menu-Bg);
803
- }
804
- }
805
- }
806
- &--x-large {
807
- .sd-input__input,
808
- .sd-input__select {
809
- padding: 0 1.6rem;
810
- min-height: 5.6rem;
811
- font-size: 3.2rem;
812
- font-weight: 500;
813
- }
814
- .sd-input__select {
815
- line-height: 3.2rem;
816
- option {
817
- color: var(--color-text);
818
- font-size: 1.4rem !important;
819
- line-height: 2rem;
820
- background-color: var(--color-dropdown-menu-Bg);
821
- }
822
- }
823
- }
824
864
  &--boxed-label {
825
865
  grid-template-columns: auto 1fr auto;
826
866
  grid-template-rows: auto auto auto;
@@ -850,10 +890,17 @@
850
890
  }
851
891
  }
852
892
  }
893
+
853
894
  }
854
895
 
855
896
  ///////////////// -------------------- Duration & Time-Date input --------------------- /////////////////
856
897
 
898
+
899
+
900
+
901
+
902
+
903
+
857
904
  .sd-input__duration-input,
858
905
  .sd-input__time-date-input {
859
906
  @include Line-input-base;
@@ -867,6 +914,7 @@
867
914
  background-color: var(--sd-colour-interactive--alpha-20);
868
915
  }
869
916
  }
917
+
870
918
  .sd-input__duration-input {
871
919
  input {
872
920
  -webkit-appearance: none;
@@ -879,6 +927,9 @@
879
927
  color: var(--color-text);
880
928
  text-align: end;
881
929
  width: 2.5ch;
930
+ font-size: 1.4rem;
931
+ padding: 0 !important;
932
+ line-height: 3.2rem;
882
933
  &::-webkit-outer-spin-button,
883
934
  &::-webkit-inner-spin-button {
884
935
  -webkit-appearance: none;
@@ -888,6 +939,10 @@
888
939
  -moz-appearance: textfield;
889
940
  }
890
941
  }
942
+ span {
943
+ display: flex;
944
+ align-items: center;
945
+ }
891
946
  .sd-input__suffix {
892
947
  height: 3.2rem;
893
948
  line-height: 3.2rem;
@@ -908,5 +963,29 @@
908
963
  .tags-input {
909
964
  grid-row: 2/3;
910
965
  grid-column: 2/4;
966
+ width: 100%;
911
967
  }
912
- }
968
+ &.sd-input--disabled,
969
+ &.sd-input--disabled:hover {
970
+ .p-multiselect,
971
+ .p-calendar,
972
+ .p-multiselect,
973
+ .p-dropdown,
974
+ .tags-input {
975
+ opacity: 0.5;
976
+ cursor: not-allowed;
977
+ }
978
+ .p-calendar {
979
+ .p-calendar-icon {
980
+ pointer-events: none;
981
+ }
982
+ border-bottom: 1px dotted var(--color-input-border);
983
+ background-color: var(--color-input-bg);
984
+ }
985
+ }
986
+ }
987
+
988
+ //&--boxed-style
989
+
990
+
991
+
@@ -6,6 +6,7 @@ interface IProps {
6
6
  color?: string; // https://ui-framework.superdesk.org/#/components/colors
7
7
  shape?: 'round' | 'square'; // defaults to 'round'
8
8
  children?: React.ReactNode;
9
+ hexColor?: string;
9
10
  'data-test-id'?: string;
10
11
  }
11
12
 
@@ -21,11 +22,11 @@ export class Badge extends React.PureComponent<IProps> {
21
22
  return (
22
23
  <div className='element-with-badge' data-test-id={this.props['data-test-id']}>
23
24
  {this.props.children}
24
- <span className={classes} data-test-id="badge-content">{this.props.text}</span>
25
+ <span className={classes} style={{backgroundColor: this.props.hexColor}} data-test-id="badge-content">{this.props.text}</span>
25
26
  </div>
26
27
  );
27
28
  } else {
28
- return <span className={classes} data-test-id={this.props['data-test-id']}>{this.props.text}</span>;
29
+ return <span className={classes} style={{backgroundColor: this.props.hexColor}} data-test-id={this.props['data-test-id']}>{this.props.text}</span>;
29
30
  }
30
31
  }
31
32
  }
@@ -3,8 +3,9 @@ import addDays from 'date-fns/addDays';
3
3
  import format from 'date-fns/format';
4
4
  import {Calendar, LocaleSettings, CalendarProps} from '@superdesk/primereact/calendar';
5
5
  import {throttle} from 'lodash';
6
- import classNames from 'classnames';
6
+ // import classNames from 'classnames';
7
7
  import nextId from "react-id-generator";
8
+ import { InputWrapper } from './Form';
8
9
 
9
10
  export type DatePickerLocaleSettings = Omit<LocaleSettings, 'today' | 'clear'>;
10
11
 
@@ -79,7 +80,6 @@ function parseFromPrimeReactCalendarFormat(value: CalendarProps['value']): IDate
79
80
  return null;
80
81
  } else {
81
82
  // at this point value is a free input string that can't be parsed to a Date inside primereact/calendar
82
-
83
83
  return 'failed-to-parse';
84
84
  }
85
85
  }
@@ -91,10 +91,10 @@ function parseToPrimeReactCalendarFormat(value: IDatePicker['value']): CalendarP
91
91
  export class DatePicker extends React.PureComponent<IDatePicker, IState> {
92
92
  private instance: IPrivatePrimeReactCalendarApi | undefined;
93
93
  hidePopupOnScroll: () => void;
94
+ private htmlId = nextId();
94
95
 
95
96
  constructor(props: IDatePicker) {
96
97
  super(props);
97
-
98
98
  this.state = {
99
99
  value: parseToPrimeReactCalendarFormat(this.props.value),
100
100
  valid: true,
@@ -137,7 +137,6 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {
137
137
 
138
138
  render() {
139
139
  let locale: LocaleSettings | undefined;
140
-
141
140
  if (this.props.locale != null) {
142
141
  locale = {
143
142
  ...this.props.locale,
@@ -145,26 +144,23 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {
145
144
  clear: 'clear',
146
145
  };
147
146
  }
148
- const classes = classNames('sd-input', {
149
- 'sd-input--inline-label': this.props.inlineLabel,
150
- 'sd-input--required': this.props.required,
151
- 'sd-input--disabled': this.props.disabled,
152
- 'sd-input--full-width': this.props.fullWidth,
153
- 'sd-input--invalid': this.props.invalid || this.state.invalid,
154
- });
155
- const labelClasses = classNames('sd-input__label', {
156
- 'a11y-only': this.props.labelHidden,
157
- });
158
-
159
- let htmlId = nextId();
160
147
 
161
148
  return (
162
- <div className={classes}>
163
- <label className={labelClasses} htmlFor={htmlId} id={htmlId + 'label'}
164
- tabIndex={this.props.tabindex === undefined ? undefined : -1}>
165
- {this.props.label}
166
- </label>
149
+ <InputWrapper
150
+ label={this.props.label}
151
+ error={this.props.error}
152
+ required={this.props.required}
153
+ disabled={this.props.disabled}
154
+ invalid={this.state.invalid}
155
+ info={this.props.info}
156
+ inlineLabel={this.props.inlineLabel}
157
+ labelHidden={this.props.labelHidden}
158
+ fullWidth={this.props.fullWidth}
159
+ htmlId={this.htmlId}
160
+ tabindex={this.props.tabindex}>
167
161
  <Calendar
162
+ inputId={this.htmlId}
163
+ ariaLabelledBy={this.htmlId + 'label'}
168
164
  ref={(ref) => {
169
165
  this.instance = ref as unknown as IPrivatePrimeReactCalendarApi;
170
166
  }}
@@ -214,16 +210,8 @@ export class DatePicker extends React.PureComponent<IDatePicker, IState> {
214
210
  // restoring internal state to current props value
215
211
  this.setState({valid: true, value: parseToPrimeReactCalendarFormat(this.props.value)});
216
212
  }
217
- }}
218
- />
219
- <div className='sd-input__message-box'>
220
- {this.props.info && !this.props.invalid && !this.state.invalid ?
221
- <div className='sd-input__hint'>{this.props.info}</div> : null}
222
- {this.props.invalid || this.state.invalid ?
223
- <div className='sd-input__message'>{this.props.error}</div>
224
- : null}
225
- </div>
226
- </div>
213
+ }} />
214
+ </InputWrapper>
227
215
  );
228
216
  }
229
217
  }
@@ -237,27 +225,27 @@ export class DatePickerISO extends React.PureComponent<IDatePickerISO> {
237
225
  render() {
238
226
  return (
239
227
  <DatePicker
240
- value={new Date(this.props.value)}
241
- onChange={(value) => {
242
- if (value === null) {
243
- this.props.onChange('');
244
- } else {
245
- this.props.onChange(format(value, 'yyyy-MM-dd'));
246
- }
247
- }}
248
- disabled={this.props.disabled}
249
- shortcuts={this.props.shortcuts}
250
- dateFormat={this.props.dateFormat}
251
- locale={this.props.locale}
252
- inlineLabel={this.props.inlineLabel}
253
- required={this.props.required}
254
- fullWidth={this.props.fullWidth}
255
- invalid={this.props.invalid}
256
- labelHidden={this.props.labelHidden}
257
- tabindex={this.props.tabindex}
258
- label={this.props.label}
259
- info={this.props.info}
260
- error={this.props.error}
228
+ value={new Date(this.props.value)}
229
+ onChange={(value) => {
230
+ if (value === null) {
231
+ this.props.onChange('');
232
+ } else {
233
+ this.props.onChange(format(value, 'yyyy-MM-dd'));
234
+ }
235
+ }}
236
+ disabled={this.props.disabled}
237
+ shortcuts={this.props.shortcuts}
238
+ dateFormat={this.props.dateFormat}
239
+ locale={this.props.locale}
240
+ inlineLabel={this.props.inlineLabel}
241
+ required={this.props.required}
242
+ fullWidth={this.props.fullWidth}
243
+ invalid={this.props.invalid}
244
+ labelHidden={this.props.labelHidden}
245
+ tabindex={this.props.tabindex}
246
+ label={this.props.label}
247
+ info={this.props.info}
248
+ error={this.props.error}
261
249
  />
262
250
  );
263
251
  }