@likable-hair/svelte 3.1.26 → 3.1.28

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.
@@ -10,4 +10,5 @@
10
10
  --autocomplete-default-padding: 0.5rem .5rem .5rem .5rem;
11
11
  --autocomplete-default-border-radius: 1.5rem;
12
12
  --autocomplete-default-options-max-width: 100%;
13
+ --autocomplete-default-input-margin-left: 4px;
13
14
  }
@@ -205,12 +205,6 @@ import MenuOrDrawer from "../../composed/common/MenuOrDrawer.svelte";
205
205
  {/if}
206
206
 
207
207
  <input
208
- style:--simple-textfield-max-width="min(200px, 90%)"
209
- style:--simple-textfield-height="auto"
210
- style:--simple-textfield-padding="0px"
211
- style:--simple-textfield-default-background-color="rgb(1, 1, 1, 0)"
212
- style:--simple-textfield-default-margin-bottom="0px"
213
- style:--simple-textfield-default-margin-left="10px"
214
208
  class="autocomplete-input"
215
209
  bind:value={searchText}
216
210
  on:focus={handleTextFieldFocus}
@@ -426,7 +420,10 @@ import MenuOrDrawer from "../../composed/common/MenuOrDrawer.svelte";
426
420
 
427
421
  .autocomplete-input {
428
422
  background-color: rgb(1, 1, 1, 0);
429
- /* margin-left: 10px; */
423
+ margin-left: var(
424
+ --autocomplete-input-margin-left,
425
+ var(--autocomplete-default-input-margin-left)
426
+ );
430
427
  outline: none;
431
428
  border: none;
432
429
  color: inherit;
@@ -23,6 +23,7 @@ export let src = void 0, title = void 0, subtitle = void 0, avatarText = !title
23
23
  {#if !!title}
24
24
  <div
25
25
  class="font-bold title"
26
+ class:text-start={direction == 'row' && !reverse}
26
27
  class:text-center={direction == 'column'}
27
28
  class:text-end={direction == 'row' && reverse}
28
29
  >{title}</div>
@@ -30,6 +31,7 @@ export let src = void 0, title = void 0, subtitle = void 0, avatarText = !title
30
31
  {#if !!subtitle}
31
32
  <div
32
33
  class="subtitle"
34
+ class:text-start={direction == 'row' && !reverse}
33
35
  class:text-center={direction == 'column'}
34
36
  class:text-end={direction == 'row' && reverse}
35
37
  >{subtitle}</div>
@@ -160,6 +162,10 @@ export let src = void 0, title = void 0, subtitle = void 0, avatarText = !title
160
162
  text-align: end;
161
163
  }
162
164
 
165
+ .text-end {
166
+ text-align: start;
167
+ }
168
+
163
169
  .title {
164
170
  font-size: var(
165
171
  --descriptive-avatar-title-font-size,
@@ -8,8 +8,9 @@ export type JsonQuery = {
8
8
  modifiers: Modifier[];
9
9
  };
10
10
  export default class Builder {
11
- private modifiers;
11
+ private _modifiers;
12
12
  constructor();
13
+ get modifiers(): Modifier[];
13
14
  where(callback: (builder: Builder) => void): Builder;
14
15
  where(key: Record<string, WhereFilterValue>): Builder;
15
16
  where(key: string, value: WhereFilterValue): Builder;
@@ -52,6 +53,8 @@ export default class Builder {
52
53
  join(table: string, onCallback: (onBuilder: OnClauseBuilder) => void): this;
53
54
  leftJoin(table: string, onCallback: (onBuilder: OnClauseBuilder) => void): this;
54
55
  rightJoin(table: string, onCallback: (onBuilder: OnClauseBuilder) => void): this;
56
+ hasModifier(builderCallback: (builder: Builder) => Builder): boolean;
57
+ hasWhereOnColumn(column: string, modifiers?: Modifier[] | undefined): boolean;
55
58
  private applyJoinClause;
56
59
  toJson(): JsonQuery;
57
60
  select(fields: string | string[]): this;
@@ -1,7 +1,11 @@
1
+ import lodash from "lodash";
1
2
  export default class Builder {
2
- modifiers = [];
3
+ _modifiers = [];
3
4
  constructor() {
4
- this.modifiers = [];
5
+ this._modifiers = [];
6
+ }
7
+ get modifiers() {
8
+ return lodash.cloneDeep(this._modifiers);
5
9
  }
6
10
  where(first, second, third) {
7
11
  return this.applyWhereClause('and', first, second, third);
@@ -43,16 +47,16 @@ export default class Builder {
43
47
  if (typeof second == 'function') {
44
48
  let inBuilder = new Builder();
45
49
  second(inBuilder);
46
- this.modifiers.push({
50
+ this._modifiers.push({
47
51
  method: 'where',
48
52
  kind: 'inBuilder',
49
53
  logicalOperator: logicalOperator,
50
54
  key: key,
51
- children: inBuilder.modifiers.filter((el) => el.method == 'where' || el.method == 'select')
55
+ children: inBuilder._modifiers.filter((el) => el.method == 'where' || el.method == 'select')
52
56
  });
53
57
  }
54
58
  else {
55
- this.modifiers.push({
59
+ this._modifiers.push({
56
60
  method: 'where',
57
61
  kind: 'in',
58
62
  logicalOperator: logicalOperator,
@@ -75,7 +79,7 @@ export default class Builder {
75
79
  return this.applyWhereNullClause('orNot', key);
76
80
  }
77
81
  applyWhereNullClause(logicalOperator, key) {
78
- this.modifiers.push({
82
+ this._modifiers.push({
79
83
  method: 'where',
80
84
  kind: 'null',
81
85
  logicalOperator: logicalOperator,
@@ -86,7 +90,7 @@ export default class Builder {
86
90
  applyWhereClause(logicalOperator, first, second, third) {
87
91
  if (third !== undefined) {
88
92
  if (!!second && typeof first == 'string' && typeof second == 'string') {
89
- this.modifiers.push({
93
+ this._modifiers.push({
90
94
  method: 'where',
91
95
  kind: 'simple',
92
96
  key: first,
@@ -96,7 +100,7 @@ export default class Builder {
96
100
  });
97
101
  }
98
102
  else if (typeof first == 'object') {
99
- this.modifiers.push({
103
+ this._modifiers.push({
100
104
  method: 'where',
101
105
  kind: 'object',
102
106
  values: first,
@@ -105,7 +109,7 @@ export default class Builder {
105
109
  }
106
110
  }
107
111
  else if (typeof first == 'string' && second !== undefined) {
108
- this.modifiers.push({
112
+ this._modifiers.push({
109
113
  method: 'where',
110
114
  kind: 'simple',
111
115
  key: first,
@@ -116,20 +120,20 @@ export default class Builder {
116
120
  else if (typeof first == 'function') {
117
121
  let builder = new Builder();
118
122
  first(builder);
119
- if (!builder.modifiers.every(el => el.method == 'where'))
123
+ if (!builder._modifiers.every(el => el.method == 'where'))
120
124
  throw new Error('inconsistent json query from where callback');
121
- this.modifiers.push({
125
+ this._modifiers.push({
122
126
  method: 'where',
123
127
  kind: 'grouped',
124
128
  logicalOperator,
125
- children: builder.modifiers.filter((el) => el.method == 'where')
129
+ children: builder._modifiers.filter((el) => el.method == 'where')
126
130
  });
127
131
  }
128
132
  return this;
129
133
  }
130
134
  applyWhereColumnClause(logicalOperator, first, second, third) {
131
135
  if (third !== undefined) {
132
- this.modifiers.push({
136
+ this._modifiers.push({
133
137
  method: 'where',
134
138
  kind: 'column',
135
139
  key: first,
@@ -139,7 +143,7 @@ export default class Builder {
139
143
  });
140
144
  }
141
145
  else {
142
- this.modifiers.push({
146
+ this._modifiers.push({
143
147
  method: 'where',
144
148
  kind: 'column',
145
149
  key: first,
@@ -150,7 +154,7 @@ export default class Builder {
150
154
  return this;
151
155
  }
152
156
  applyWhereJsonSupersetClause(logicalOperator, first, second) {
153
- this.modifiers.push({
157
+ this._modifiers.push({
154
158
  method: 'where',
155
159
  kind: 'jsonSuperset',
156
160
  key: first,
@@ -177,8 +181,31 @@ export default class Builder {
177
181
  this.applyJoinClause('right', table, onBuilder.json);
178
182
  return this;
179
183
  }
184
+ hasModifier(builderCallback) {
185
+ let parameterBuilder = new Builder();
186
+ parameterBuilder = builderCallback(parameterBuilder);
187
+ for (let i = 0; i < parameterBuilder._modifiers.length; i += 1) {
188
+ let modifierToSearch = parameterBuilder._modifiers[i];
189
+ let found = false;
190
+ for (let k = 0; k < this._modifiers.length; k += 1) {
191
+ let currentModifier = this._modifiers[k];
192
+ found = lodash.isEqual(modifierToSearch, currentModifier);
193
+ if (found)
194
+ break;
195
+ }
196
+ if (!found)
197
+ return false;
198
+ }
199
+ return true;
200
+ }
201
+ hasWhereOnColumn(column, modifiers = undefined) {
202
+ return (modifiers || this._modifiers).some((m) => {
203
+ return m.method == 'where' &&
204
+ ((m.kind == 'column' && m.key == column) || (m.kind == 'grouped' && this.hasWhereOnColumn(column, m.children)) || (m.kind == 'in' && m.key == column) || (m.kind == 'inBuilder' && this.hasWhereOnColumn(column, m.children)) || (m.kind == 'jsonSuperset' && m.key == column) || (m.kind == 'null' && m.key == column) || (m.kind == 'object' && Object.keys(m.values).includes(column)) || (m.kind == 'simple' && m.key == column));
205
+ });
206
+ }
180
207
  applyJoinClause(kind, table, on) {
181
- this.modifiers.push({
208
+ this._modifiers.push({
182
209
  method: 'join',
183
210
  kind: kind,
184
211
  on: on,
@@ -188,25 +215,25 @@ export default class Builder {
188
215
  }
189
216
  toJson() {
190
217
  return {
191
- modifiers: this.modifiers
218
+ modifiers: this._modifiers
192
219
  };
193
220
  }
194
221
  select(fields) {
195
- this.modifiers.push({
222
+ this._modifiers.push({
196
223
  method: 'select',
197
224
  fields: fields
198
225
  });
199
226
  return this;
200
227
  }
201
228
  from(from) {
202
- this.modifiers.push({
229
+ this._modifiers.push({
203
230
  method: 'from',
204
231
  from: from
205
232
  });
206
233
  return this;
207
234
  }
208
235
  orderBy(sortBy, sortDirection) {
209
- this.modifiers.push({
236
+ this._modifiers.push({
210
237
  method: 'orderBy',
211
238
  sortBy: sortBy,
212
239
  sortDirection: sortDirection
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likable-hair/svelte",
3
3
  "description": "A Svelte component for likablehair and others",
4
- "version": "3.1.26",
4
+ "version": "3.1.28",
5
5
  "scripts": {
6
6
  "host": "vite --host",
7
7
  "dev": "vite dev",