mtrl 0.2.6 → 0.2.7
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.
- package/index.ts +18 -0
- package/package.json +1 -1
- package/src/components/badge/_styles.scss +117 -109
- package/src/components/badge/api.ts +57 -59
- package/src/components/badge/badge.ts +16 -2
- package/src/components/badge/config.ts +65 -11
- package/src/components/badge/constants.ts +22 -12
- package/src/components/badge/features.ts +44 -40
- package/src/components/badge/types.ts +42 -30
- package/src/components/bottom-app-bar/_styles.scss +103 -0
- package/src/components/bottom-app-bar/bottom-app-bar.ts +196 -0
- package/src/components/bottom-app-bar/config.ts +73 -0
- package/src/components/bottom-app-bar/index.ts +11 -0
- package/src/components/bottom-app-bar/types.ts +108 -0
- package/src/components/button/_styles.scss +0 -10
- package/src/components/button/api.ts +5 -0
- package/src/components/button/config.ts +5 -0
- package/src/components/button/types.ts +6 -0
- package/src/components/card/card.ts +13 -25
- package/src/components/card/config.ts +67 -22
- package/src/components/card/features.ts +3 -0
- package/src/components/card/types.ts +28 -0
- package/src/components/checkbox/_styles.scss +0 -2
- package/src/components/datepicker/_styles.scss +358 -0
- package/src/components/datepicker/api.ts +272 -0
- package/src/components/datepicker/config.ts +144 -0
- package/src/components/datepicker/constants.ts +98 -0
- package/src/components/datepicker/datepicker.ts +346 -0
- package/src/components/datepicker/index.ts +9 -0
- package/src/components/datepicker/render.ts +452 -0
- package/src/components/datepicker/types.ts +268 -0
- package/src/components/datepicker/utils.ts +290 -0
- package/src/components/dialog/_styles.scss +174 -128
- package/src/components/dialog/api.ts +48 -13
- package/src/components/dialog/config.ts +9 -5
- package/src/components/dialog/dialog.ts +6 -3
- package/src/components/dialog/features.ts +290 -130
- package/src/components/dialog/types.ts +7 -4
- package/src/components/divider/_styles.scss +57 -0
- package/src/components/divider/config.ts +81 -0
- package/src/components/divider/divider.ts +37 -0
- package/src/components/divider/features.ts +207 -0
- package/src/components/divider/index.ts +5 -0
- package/src/components/divider/types.ts +55 -0
- package/src/components/extended-fab/_styles.scss +267 -0
- package/src/components/extended-fab/api.ts +141 -0
- package/src/components/extended-fab/config.ts +108 -0
- package/src/components/extended-fab/constants.ts +36 -0
- package/src/components/extended-fab/extended-fab.ts +125 -0
- package/src/components/extended-fab/index.ts +4 -0
- package/src/components/extended-fab/types.ts +287 -0
- package/src/components/fab/_styles.scss +225 -0
- package/src/components/fab/api.ts +97 -0
- package/src/components/fab/config.ts +94 -0
- package/src/components/fab/constants.ts +41 -0
- package/src/components/fab/fab.ts +67 -0
- package/src/components/fab/index.ts +4 -0
- package/src/components/fab/types.ts +234 -0
- package/src/components/navigation/_styles.scss +1 -0
- package/src/components/navigation/api.ts +78 -50
- package/src/components/navigation/features/items.ts +280 -0
- package/src/components/navigation/nav-item.ts +72 -23
- package/src/components/navigation/navigation.ts +54 -2
- package/src/components/navigation/types.ts +210 -188
- package/src/components/search/_styles.scss +306 -0
- package/src/components/search/api.ts +203 -0
- package/src/components/search/config.ts +87 -0
- package/src/components/search/constants.ts +21 -0
- package/src/components/search/features/index.ts +4 -0
- package/src/components/search/features/search.ts +718 -0
- package/src/components/search/features/states.ts +165 -0
- package/src/components/search/features/structure.ts +198 -0
- package/src/components/search/index.ts +10 -0
- package/src/components/search/search.ts +52 -0
- package/src/components/search/types.ts +163 -0
- package/src/components/segmented-button/_styles.scss +117 -0
- package/src/components/segmented-button/config.ts +67 -0
- package/src/components/segmented-button/constants.ts +42 -0
- package/src/components/segmented-button/index.ts +4 -0
- package/src/components/segmented-button/segment.ts +155 -0
- package/src/components/segmented-button/segmented-button.ts +250 -0
- package/src/components/segmented-button/types.ts +219 -0
- package/src/components/slider/_styles.scss +83 -24
- package/src/components/slider/accessibility.md +5 -5
- package/src/components/slider/api.ts +41 -120
- package/src/components/slider/config.ts +51 -47
- package/src/components/slider/features/handlers.ts +495 -0
- package/src/components/slider/features/index.ts +1 -2
- package/src/components/slider/features/slider.ts +66 -84
- package/src/components/slider/features/states.ts +195 -0
- package/src/components/slider/features/structure.ts +136 -206
- package/src/components/slider/features/ui.ts +145 -206
- package/src/components/slider/index.ts +2 -11
- package/src/components/slider/slider.ts +9 -12
- package/src/components/slider/types.ts +39 -24
- package/src/components/switch/_styles.scss +0 -2
- package/src/components/tabs/_styles.scss +94 -32
- package/src/components/tabs/features.ts +4 -2
- package/src/components/tabs/indicator.ts +73 -13
- package/src/components/tabs/types.ts +10 -2
- package/src/components/timepicker/README.md +277 -0
- package/src/components/timepicker/_styles.scss +451 -0
- package/src/components/timepicker/api.ts +632 -0
- package/src/components/timepicker/clockdial.ts +482 -0
- package/src/components/timepicker/config.ts +130 -0
- package/src/components/timepicker/constants.ts +138 -0
- package/src/components/timepicker/index.ts +8 -0
- package/src/components/timepicker/render.ts +613 -0
- package/src/components/timepicker/timepicker.ts +117 -0
- package/src/components/timepicker/types.ts +336 -0
- package/src/components/timepicker/utils.ts +241 -0
- package/src/components/top-app-bar/_styles.scss +225 -0
- package/src/components/top-app-bar/config.ts +83 -0
- package/src/components/top-app-bar/index.ts +11 -0
- package/src/components/top-app-bar/top-app-bar.ts +316 -0
- package/src/components/top-app-bar/types.ts +140 -0
- package/src/core/build/_ripple.scss +6 -6
- package/src/core/build/ripple.ts +72 -95
- package/src/core/compose/features/icon.ts +3 -1
- package/src/core/compose/features/ripple.ts +4 -1
- package/src/core/compose/features/textlabel.ts +26 -2
- package/src/core/dom/create.ts +5 -0
- package/src/index.ts +9 -0
- package/src/styles/abstract/_theme.scss +9 -1
- package/src/styles/themes/_autumn.scss +21 -0
- package/src/styles/themes/_base-theme.scss +61 -0
- package/src/styles/themes/_baseline.scss +58 -0
- package/src/styles/themes/_bluekhaki.scss +125 -0
- package/src/styles/themes/_brownbeige.scss +125 -0
- package/src/styles/themes/_browngreen.scss +125 -0
- package/src/styles/themes/_forest.scss +6 -0
- package/src/styles/themes/_greenbeige.scss +125 -0
- package/src/styles/themes/_material.scss +125 -0
- package/src/styles/themes/_ocean.scss +6 -0
- package/src/styles/themes/_sageivory.scss +125 -0
- package/src/styles/themes/_spring.scss +6 -0
- package/src/styles/themes/_summer.scss +5 -0
- package/src/styles/themes/_sunset.scss +5 -0
- package/src/styles/themes/_tealcaramel.scss +125 -0
- package/src/styles/themes/_winter.scss +6 -0
- package/src/components/navigation/features/items.js +0 -192
- package/src/components/slider/features/appearance.ts +0 -94
- package/src/components/slider/features/disabled.ts +0 -68
- package/src/components/slider/features/events.ts +0 -164
- package/src/components/slider/features/interactions.ts +0 -396
- package/src/components/slider/features/keyboard.ts +0 -233
- package/src/core/collection/adapters/mongodb.js +0 -232
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
// src/core/collection/adapters/mongodb.js
|
|
2
|
-
|
|
3
|
-
import { MongoClient, ObjectId } from 'mongodb'
|
|
4
|
-
import { OPERATORS, createBaseAdapter } from './base'
|
|
5
|
-
|
|
6
|
-
const MONGODB_OPERATORS = {
|
|
7
|
-
[OPERATORS.EQ]: '$eq',
|
|
8
|
-
[OPERATORS.NE]: '$ne',
|
|
9
|
-
[OPERATORS.GT]: '$gt',
|
|
10
|
-
[OPERATORS.GTE]: '$gte',
|
|
11
|
-
[OPERATORS.LT]: '$lt',
|
|
12
|
-
[OPERATORS.LTE]: '$lte',
|
|
13
|
-
[OPERATORS.IN]: '$in',
|
|
14
|
-
[OPERATORS.NIN]: '$nin',
|
|
15
|
-
[OPERATORS.CONTAINS]: '$regex',
|
|
16
|
-
[OPERATORS.STARTS_WITH]: '$regex',
|
|
17
|
-
[OPERATORS.ENDS_WITH]: '$regex'
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const createMongoAdapter = (config = {}) => {
|
|
21
|
-
const base = createBaseAdapter(config)
|
|
22
|
-
let client = null
|
|
23
|
-
let db = null
|
|
24
|
-
let collection = null
|
|
25
|
-
|
|
26
|
-
const transformDocument = (doc) => {
|
|
27
|
-
if (!doc) return null
|
|
28
|
-
const { _id, ...rest } = doc
|
|
29
|
-
return { id: _id.toString(), ...rest }
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const transformForMongo = (doc) => {
|
|
33
|
-
if (!doc) return null
|
|
34
|
-
const { id, ...rest } = doc
|
|
35
|
-
return { _id: id ? new ObjectId(id) : new ObjectId(), ...rest }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const transformQuery = (query) => {
|
|
39
|
-
const transformed = {}
|
|
40
|
-
|
|
41
|
-
Object.entries(query).forEach(([field, conditions]) => {
|
|
42
|
-
if (typeof conditions === 'object') {
|
|
43
|
-
transformed[field] = Object.entries(conditions).reduce((acc, [op, value]) => {
|
|
44
|
-
const mongoOp = MONGODB_OPERATORS[op]
|
|
45
|
-
if (!mongoOp) return acc
|
|
46
|
-
|
|
47
|
-
if (op === OPERATORS.CONTAINS) {
|
|
48
|
-
acc[mongoOp] = new RegExp(value, 'i')
|
|
49
|
-
} else if (op === OPERATORS.STARTS_WITH) {
|
|
50
|
-
acc[mongoOp] = new RegExp(`^${value}`, 'i')
|
|
51
|
-
} else if (op === OPERATORS.ENDS_WITH) {
|
|
52
|
-
acc[mongoOp] = new RegExp(`${value}$`, 'i')
|
|
53
|
-
} else {
|
|
54
|
-
acc[mongoOp] = value
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return acc
|
|
58
|
-
}, {})
|
|
59
|
-
} else {
|
|
60
|
-
transformed[field] = conditions
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
return transformed
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
...base,
|
|
69
|
-
|
|
70
|
-
connect: async () => {
|
|
71
|
-
try {
|
|
72
|
-
client = new MongoClient(config.uri, {
|
|
73
|
-
useUnifiedTopology: true,
|
|
74
|
-
maxPoolSize: 10,
|
|
75
|
-
...config.options
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
await client.connect()
|
|
79
|
-
db = client.db(config.dbName)
|
|
80
|
-
collection = db.collection(config.collection)
|
|
81
|
-
|
|
82
|
-
// Optional: Create indexes
|
|
83
|
-
// await collection.createIndex({ field: 1 })
|
|
84
|
-
} catch (error) {
|
|
85
|
-
return base.handleError(new Error(`MongoDB connection failed: ${error.message}`))
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
disconnect: async () => {
|
|
90
|
-
if (client) {
|
|
91
|
-
await client.close()
|
|
92
|
-
client = null
|
|
93
|
-
db = null
|
|
94
|
-
collection = null
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
create: async (items) => {
|
|
99
|
-
if (!collection) {
|
|
100
|
-
return base.handleError(new Error('Not connected to MongoDB'))
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const docs = items.map(item => transformForMongo(item))
|
|
104
|
-
const result = await collection.insertMany(docs)
|
|
105
|
-
|
|
106
|
-
return items.map((item, index) => ({
|
|
107
|
-
...item,
|
|
108
|
-
id: result.insertedIds[index].toString()
|
|
109
|
-
}))
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
read: async (query = {}, options = {}) => {
|
|
113
|
-
if (!collection) {
|
|
114
|
-
return base.handleError(new Error('Not connected to MongoDB'))
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const {
|
|
118
|
-
skip = 0,
|
|
119
|
-
limit = 0,
|
|
120
|
-
sort = {},
|
|
121
|
-
projection = {}
|
|
122
|
-
} = options
|
|
123
|
-
|
|
124
|
-
const mongoQuery = transformQuery(query)
|
|
125
|
-
|
|
126
|
-
const cursor = collection
|
|
127
|
-
.find(mongoQuery)
|
|
128
|
-
.skip(skip)
|
|
129
|
-
.limit(limit)
|
|
130
|
-
.project(projection)
|
|
131
|
-
.sort(sort)
|
|
132
|
-
|
|
133
|
-
const docs = await cursor.toArray()
|
|
134
|
-
return docs.map(doc => transformDocument(doc))
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
update: async (items) => {
|
|
138
|
-
if (!collection) {
|
|
139
|
-
return base.handleError(new Error('Not connected to MongoDB'))
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const operations = items.map(item => ({
|
|
143
|
-
updateOne: {
|
|
144
|
-
filter: { _id: new ObjectId(item.id) },
|
|
145
|
-
update: { $set: transformForMongo(item) },
|
|
146
|
-
upsert: false
|
|
147
|
-
}
|
|
148
|
-
}))
|
|
149
|
-
|
|
150
|
-
await collection.bulkWrite(operations)
|
|
151
|
-
return items
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
delete: async (ids) => {
|
|
155
|
-
if (!collection) {
|
|
156
|
-
return base.handleError(new Error('Not connected to MongoDB'))
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const mongoIds = ids.map(id => new ObjectId(id))
|
|
160
|
-
await collection.deleteMany({ _id: { $in: mongoIds } })
|
|
161
|
-
return ids
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
query: async (query = {}, options = {}) => {
|
|
165
|
-
if (!collection) {
|
|
166
|
-
return base.handleError(new Error('Not connected to MongoDB'))
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const {
|
|
170
|
-
pipeline = [],
|
|
171
|
-
skip = 0,
|
|
172
|
-
limit = 0
|
|
173
|
-
} = options
|
|
174
|
-
|
|
175
|
-
const mongoQuery = transformQuery(query)
|
|
176
|
-
|
|
177
|
-
const aggregation = [
|
|
178
|
-
{ $match: mongoQuery },
|
|
179
|
-
...pipeline
|
|
180
|
-
]
|
|
181
|
-
|
|
182
|
-
if (skip > 0) {
|
|
183
|
-
aggregation.push({ $skip: skip })
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (limit > 0) {
|
|
187
|
-
aggregation.push({ $limit: limit })
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const docs = await collection.aggregate(aggregation).toArray()
|
|
191
|
-
|
|
192
|
-
return {
|
|
193
|
-
results: docs.map(doc => transformDocument(doc)),
|
|
194
|
-
total: await collection.countDocuments(mongoQuery)
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
watch: (callback, pipeline = []) => {
|
|
199
|
-
if (!collection) {
|
|
200
|
-
return base.handleError(new Error('Not connected to MongoDB'))
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const changeStream = collection.watch(pipeline, {
|
|
204
|
-
fullDocument: 'updateLookup'
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
changeStream.on('change', async (change) => {
|
|
208
|
-
const { operationType, documentKey, fullDocument } = change
|
|
209
|
-
|
|
210
|
-
switch (operationType) {
|
|
211
|
-
case 'insert':
|
|
212
|
-
case 'update':
|
|
213
|
-
case 'replace':
|
|
214
|
-
callback({
|
|
215
|
-
type: operationType,
|
|
216
|
-
document: transformDocument(fullDocument)
|
|
217
|
-
})
|
|
218
|
-
break
|
|
219
|
-
|
|
220
|
-
case 'delete':
|
|
221
|
-
callback({
|
|
222
|
-
type: operationType,
|
|
223
|
-
documentId: documentKey._id.toString()
|
|
224
|
-
})
|
|
225
|
-
break
|
|
226
|
-
}
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
return () => changeStream.close()
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|