answerui-py 0.0.2__py3-none-any.whl
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.
- answerui/__init__.py +20 -0
- answerui/_modidx.py +143 -0
- answerui/all.py +14 -0
- answerui/base.py +89 -0
- answerui/behaviors.py +83 -0
- answerui/controls.py +436 -0
- answerui/css/palette.css +12 -0
- answerui/css/typrose.LICENSE +21 -0
- answerui/css/typrose.css +358 -0
- answerui/data.py +43 -0
- answerui/demo.py +98 -0
- answerui/fonts/IBM-Plex.LICENSE +93 -0
- answerui/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- answerui/fonts/ibm-plex-sans-latin-400-italic.woff2 +0 -0
- answerui/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- answerui/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
- answerui/fonts/ibm-plex-serif-latin-600-normal.woff2 +0 -0
- answerui/hdrs.py +80 -0
- answerui/layout.py +113 -0
- answerui/navigation.py +113 -0
- answerui/overlays.py +243 -0
- answerui/registry.py +238 -0
- answerui/skill.py +92 -0
- answerui/status.py +187 -0
- answerui/surfaces.py +100 -0
- answerui/tokens.py +157 -0
- answerui_py-0.0.2.dist-info/METADATA +136 -0
- answerui_py-0.0.2.dist-info/RECORD +32 -0
- answerui_py-0.0.2.dist-info/WHEEL +5 -0
- answerui_py-0.0.2.dist-info/entry_points.txt +5 -0
- answerui_py-0.0.2.dist-info/licenses/LICENSE +201 -0
- answerui_py-0.0.2.dist-info/top_level.txt +1 -0
answerui/controls.py
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
"""Native form controls styled through their own states, raised to press and sunken to type into
|
|
2
|
+
|
|
3
|
+
Every form control we need is already a native HTML tag, and the browser already keeps track of its state. We style those tags directly, and we style their states through the pseudo-classes (`:disabled`, `:user-invalid`, …) and ARIA attributes (`aria-busy`, `aria-pressed`, …) that the browser provides, rather than tracking anything ourselves. Variants are bare attributes.
|
|
4
|
+
|
|
5
|
+
Docs: https://AnswerDotAI.github.io/answerui/controls.html.md"""
|
|
6
|
+
|
|
7
|
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/08_controls.ipynb.
|
|
8
|
+
|
|
9
|
+
# %% auto #0
|
|
10
|
+
__all__ = ['Button', 'Input', 'Textarea', 'Select', 'Fieldset', 'Group', 'Toolbar', 'Copy', 'Switch', 'Checkbox', 'Radio',
|
|
11
|
+
'Range', 'Field']
|
|
12
|
+
|
|
13
|
+
# %% ../nbs/08_controls.ipynb #16a360f9
|
|
14
|
+
from fastcore.utils import *
|
|
15
|
+
from fasthtml.common import Div, A, Label, Input, Small, Form, Textarea, Select, Option, Legend, Menu, Li, Code, unqid
|
|
16
|
+
from fastlucide.icons import Check, Copy as CopyIcon
|
|
17
|
+
from .registry import reg, hypelt
|
|
18
|
+
from .tokens import relief
|
|
19
|
+
from .demo import example
|
|
20
|
+
from .layout import Stack, Cluster
|
|
21
|
+
import answerui.base # the reset this styling is written on
|
|
22
|
+
|
|
23
|
+
# %% ../nbs/08_controls.ipynb #e7db663f
|
|
24
|
+
_button_css = r"""
|
|
25
|
+
:is(button, a[button]) {
|
|
26
|
+
--face: var(--v); --face-held: var(--v2); --shadow-held: var(--bevel-in), var(--sunken); --_shift: 0px; --busy-delay: 200ms;
|
|
27
|
+
--pad-block: var(--space-2); --pad-inline: var(--space);
|
|
28
|
+
display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
|
|
29
|
+
padding: calc(var(--pad-block) + var(--_shift)) calc(var(--pad-inline) - var(--_shift))
|
|
30
|
+
calc(var(--pad-block) - var(--_shift)) calc(var(--pad-inline) + var(--_shift));
|
|
31
|
+
font-weight: var(--weight1); line-height: var(--leading-1);
|
|
32
|
+
background: var(--face); color: var(--n-3); text-decoration: none;
|
|
33
|
+
border: 1px solid transparent; border-radius: var(--radius);
|
|
34
|
+
box-shadow: var(--bevel), var(--raised);
|
|
35
|
+
transition: box-shadow calc(var(--motion) / 2) var(--ease), padding calc(var(--motion) / 2) var(--ease), background var(--motion) var(--ease), opacity var(--motion) var(--ease), -webkit-text-fill-color var(--motion) var(--ease);
|
|
36
|
+
}
|
|
37
|
+
:is(button, a[button]):hover { --face: var(--v1); }
|
|
38
|
+
:is(button, a[button]):is(:active, [aria-busy=true], [aria-pressed=true], [aria-expanded=true]) { --face: var(--face-held); box-shadow: var(--shadow-held); }
|
|
39
|
+
:is(button, a[button]):active { --_shift: calc(1px * var(--relief)); transition-duration: calc(var(--motion) / 4); }
|
|
40
|
+
:is(button, a[button]):disabled { opacity: .5; --_shift: 0px; box-shadow: none; }
|
|
41
|
+
button:is([aria-busy=true], .htmx-request) { position: relative; }
|
|
42
|
+
button[aria-busy=true] { -webkit-text-fill-color: transparent; }
|
|
43
|
+
button > svg { transition: opacity var(--motion) var(--ease); }
|
|
44
|
+
button:is([aria-busy=true], .htmx-request) > svg { opacity: 0; }
|
|
45
|
+
button:is([aria-busy=true], .htmx-request)::before {
|
|
46
|
+
content: ''; position: absolute; inset: 0; margin: auto; inline-size: 1.25em; block-size: 1.25em;
|
|
47
|
+
border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: var(--radius-full);
|
|
48
|
+
animation: aui-spin calc(var(--motion) * 5) linear infinite;
|
|
49
|
+
}
|
|
50
|
+
:is(button, a[button]).htmx-request:not([aria-busy=true]) { animation: aui-sink 0s linear var(--busy-delay) both; }
|
|
51
|
+
button.htmx-request:not([aria-busy=true]) > svg { transition-delay: var(--busy-delay); }
|
|
52
|
+
button.htmx-request:not([aria-busy=true])::before { animation: aui-spin calc(var(--motion) * 5) linear infinite, aui-busy-in var(--motion) var(--ease) var(--busy-delay) both; }
|
|
53
|
+
@keyframes aui-sink { to { --face: var(--face-held); box-shadow: var(--shadow-held); -webkit-text-fill-color: transparent; } }
|
|
54
|
+
@keyframes aui-busy-in { from { opacity: 0; } }
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
Button = hypelt('Button', sel='button, a[button]', layer='components', doc='Raised at rest, down while active, busy, or expanded, latched by `aria-pressed`; `secondary` for the lesser action; a link carrying `button` is styled the same way.', css=_button_css)
|
|
58
|
+
|
|
59
|
+
# %% ../nbs/08_controls.ipynb #1802b6a8
|
|
60
|
+
Button.variant('secondary', r"""
|
|
61
|
+
--face: var(--n-2); color: var(--n2); border-color: var(--n-1);
|
|
62
|
+
--face-held: var(--n-2);
|
|
63
|
+
&:hover { --face: var(--v-3); }
|
|
64
|
+
&:is([aria-pressed=true], [aria-expanded=true]) { --face: var(--v-3); color: var(--v2); }
|
|
65
|
+
""", layer='components', doc='The lesser action: the neutral surface with a hairline border, and the accent wash when latched.')
|
|
66
|
+
|
|
67
|
+
# %% ../nbs/08_controls.ipynb #be7ed1c8
|
|
68
|
+
Button.variant('quiet', r'''
|
|
69
|
+
--face: transparent; color: inherit; border-color: transparent; box-shadow: none;
|
|
70
|
+
--face-held: oklch(from var(--tint) l c h / calc(alpha * 2)); --shadow-held: none;
|
|
71
|
+
&:hover { --face: var(--tint); }
|
|
72
|
+
&:is(:active, [aria-busy=true], [aria-pressed=true], [aria-expanded=true]) { --face: var(--face-held); }
|
|
73
|
+
&:active { --_shift: 0px; }
|
|
74
|
+
''', layer='components', doc='No face, border, or shadow at rest, for an action that should not compete: dismiss, close, and toolbar buttons.')
|
|
75
|
+
|
|
76
|
+
# %% ../nbs/08_controls.ipynb #85a54b51
|
|
77
|
+
@example(Button)
|
|
78
|
+
def _button_example():
|
|
79
|
+
return Cluster(Button('Save'), Button('Cancel', secondary=True), Button('Dismiss', quiet=True), A('Sign up', href='#', button=True), Button('Delete', danger=True), Button('Publish', success=True),
|
|
80
|
+
Button('Locked', disabled=True), Button('Save', aria_busy='true'), Button('Pinned', aria_pressed='true'), Button('Pinned', secondary=True, aria_pressed='true'), Button('Pinned', quiet=True, aria_pressed='true'),
|
|
81
|
+
gap='var(--space-2)')
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# %% ../nbs/08_controls.ipynb #752e6b29
|
|
85
|
+
Button.rule('icon-only', '&:has(> svg:only-child) { --pad-inline: var(--pad-block); }', layer='components', doc='A button whose only child is an svg is square; give it an aria-label.')
|
|
86
|
+
|
|
87
|
+
# %% ../nbs/08_controls.ipynb #bea255a7
|
|
88
|
+
reg.context(':user-invalid, [aria-invalid=true]', 'var(--hue-danger)')
|
|
89
|
+
|
|
90
|
+
_text_sel = 'input:is(:not([type]), [type=text], [type=email], [type=password], [type=search], [type=url], [type=tel], [type=number], [type=date], [type=time], [type=datetime-local], [type=month], [type=week])'
|
|
91
|
+
reg.rule('text-controls', rf"""
|
|
92
|
+
:is({_text_sel}, textarea, select, [well]) {{
|
|
93
|
+
inline-size: 100%; padding: var(--space-2) var(--space-1);
|
|
94
|
+
--face: var(--n-3); background: var(--face); color: var(--n2);
|
|
95
|
+
border: 1px solid var(--n-1); border-radius: var(--radius); box-shadow: var(--bevel-in), var(--sunken);
|
|
96
|
+
transition: border-color var(--motion) var(--ease), box-shadow var(--motion) var(--ease);
|
|
97
|
+
}}
|
|
98
|
+
:is(input, textarea, select):is(:user-invalid, [aria-invalid=true]) {{ border-color: var(--v); }}
|
|
99
|
+
:is({_text_sel}, textarea, select):disabled {{ --face: var(--n-2); color: var(--n); box-shadow: var(--bevel-in); }}
|
|
100
|
+
::placeholder {{ color: var(--n1); }}
|
|
101
|
+
input[type=number] {{ appearance: textfield; }}
|
|
102
|
+
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button {{ appearance: none; margin: 0; }}
|
|
103
|
+
""", layer='components', doc='The well shared by text inputs, textareas, selects, and any element marked `well`, taking the danger hue when invalid.')
|
|
104
|
+
|
|
105
|
+
Input = hypelt('Input', sel=_text_sel, layer='components', doc='A text-like input, styled as a well by the text-controls rule.')
|
|
106
|
+
Textarea = hypelt('Textarea', layer='components', css='textarea { min-block-size: 5rem; resize: vertical; field-sizing: content; }',
|
|
107
|
+
doc='A textarea, styled as a well by the text-controls rule; it grows with its content.')
|
|
108
|
+
Select = hypelt('Select', layer='components', doc='A select, styled as a well by the text-controls rule.')
|
|
109
|
+
|
|
110
|
+
# %% ../nbs/08_controls.ipynb #1a1e20e9
|
|
111
|
+
@example(Input)
|
|
112
|
+
def _input_example(): return Stack(Input(placeholder='Search', type='search', aria_label='Search'), Input(value='Locked', disabled=True, aria_label='Locked'), style='inline-size:16rem')
|
|
113
|
+
|
|
114
|
+
@example(Textarea)
|
|
115
|
+
def _textarea_example(): return Textarea('A note that grows with its content.', aria_label='Note', style='inline-size:16rem')
|
|
116
|
+
|
|
117
|
+
@example(Select)
|
|
118
|
+
def _select_example(): return Select(Option('Free'), Option('Team'), aria_label='Plan', style='inline-size:16rem')
|
|
119
|
+
|
|
120
|
+
# %% ../nbs/08_controls.ipynb #589b6139
|
|
121
|
+
_enable_js = r"""
|
|
122
|
+
const f = el.form ?? el;
|
|
123
|
+
const run = () => {
|
|
124
|
+
const changed = [...f.elements].some(c => c.matches('input:not([type=hidden], [type=submit], [type=button], [type=reset]), select, textarea')
|
|
125
|
+
&& (c.type === 'checkbox' || c.type === 'radio' ? c.checked !== c.defaultChecked
|
|
126
|
+
: c.tagName === 'SELECT' ? [...c.options].some(o => o.selected !== o.defaultSelected) : c.value !== c.defaultValue));
|
|
127
|
+
const valid = [...f.elements].every(c => c.validity.valid); // not checkValidity(), which fires `invalid` on each control and the validity rule would show its message
|
|
128
|
+
for (const b of f.querySelectorAll('button[enable]')) {
|
|
129
|
+
const wants = b.getAttribute('enable').split(' ');
|
|
130
|
+
b.disabled = !wants.every(w => w === 'changed' ? changed : w === 'valid' ? valid : true);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
e.type === 'reset' ? setTimeout(run) : run();"""
|
|
134
|
+
|
|
135
|
+
reg.rule('enable', on={('form:has(button[enable])', 'input'): _enable_js, ('form:has(button[enable])', 'change'): _enable_js, ('form:has(button[enable])', 'reset'): _enable_js, ('button[enable]', 'init'): _enable_js},
|
|
136
|
+
layer='components', doc="A submit button rendered disabled with `enable='changed'`, `enable='valid'`, or both comes alive when its form has changed, or is valid, and goes back when it is not.")
|
|
137
|
+
|
|
138
|
+
# %% ../nbs/08_controls.ipynb #018a9574
|
|
139
|
+
_group_css = r"""
|
|
140
|
+
[group] { display: inline-flex; align-items: stretch; margin: 0; padding: 0; list-style: none; border-radius: var(--radius); --_radius: var(--radius); --_small: var(--radius-1); }
|
|
141
|
+
[group] > li { display: flex; }
|
|
142
|
+
[group] > *, [group] > li > * { --radius: 0; }
|
|
143
|
+
[group] > :first-child, [group] > li:first-child > * { border-start-start-radius: var(--_radius); border-end-start-radius: var(--_radius); }
|
|
144
|
+
[group] > :last-child, [group] > li:last-child > * { border-start-end-radius: var(--_radius); border-end-end-radius: var(--_radius); }
|
|
145
|
+
[group] > * + * { margin-inline-start: -1px; }
|
|
146
|
+
[group]:has(> :is(input, select)) { inline-size: 100%; }
|
|
147
|
+
[group] > :is(input, select) { flex: 1; min-inline-size: 0; }
|
|
148
|
+
[group] > :is(button, a[button]) { flex: none; }
|
|
149
|
+
[group]:has(> :is(input, select):focus-visible) { outline: var(--ring); outline-offset: 2px; }
|
|
150
|
+
[group] > :is(input, select):focus-visible { outline: none; }
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
@hypelt(sel='[group]', layer='components', css=_group_css)
|
|
154
|
+
def Group(*c, **attrs):
|
|
155
|
+
"A text input and its action sharing an edge; `inset` puts the action inside the well"
|
|
156
|
+
return Div(*c, group=True, **attrs)
|
|
157
|
+
|
|
158
|
+
@hypelt(sel='menu[group]', layer='components')
|
|
159
|
+
def Toolbar(*controls, **attrs):
|
|
160
|
+
"A row of commands sharing their edges: a `menu` with each control as an item"
|
|
161
|
+
return Menu(*[Li(c) for c in controls], group=True, **attrs)
|
|
162
|
+
|
|
163
|
+
Group.variant('inset', r"""
|
|
164
|
+
--face: var(--n-3); background: var(--face); border: 1px solid var(--n-1); box-shadow: var(--bevel-in), var(--sunken);
|
|
165
|
+
align-items: center; padding-inline-end: var(--space-3);
|
|
166
|
+
& > * { margin: 0; --radius: var(--_small); }
|
|
167
|
+
& > :first-child, & > :last-child { border-radius: var(--_small); }
|
|
168
|
+
& > :is(input, select) { border: 0; background: transparent; box-shadow: none; }
|
|
169
|
+
& > :is(button, a[button]), & > [tooltip] > :is(button, a[button]) { --pad-block: var(--space-3); --pad-inline: var(--space-2); }
|
|
170
|
+
""", layer='components', doc='The action inside the well; the action starts disabled and `enable` wakes it.')
|
|
171
|
+
|
|
172
|
+
# %% ../nbs/08_controls.ipynb #deeba9c4
|
|
173
|
+
@example(Group)
|
|
174
|
+
def _group_example():
|
|
175
|
+
return Stack(Form(Group(Input(name='name', placeholder='Instance name', required=True, aria_label='Instance name'), Button('Create', type='submit', disabled=True, enable='valid'))),
|
|
176
|
+
Form(Group(Input(name='name', value='personal', aria_label='Name'), Button('Save', type='submit', disabled=True, enable='changed valid'), inset=True)),
|
|
177
|
+
style='inline-size: 24rem')
|
|
178
|
+
|
|
179
|
+
# %% ../nbs/08_controls.ipynb #926e45af
|
|
180
|
+
@example(Toolbar)
|
|
181
|
+
def _toolbar_example():
|
|
182
|
+
return Cluster(Toolbar(Button('Previous', secondary=True, type='button'), Button('Next', secondary=True, type='button'), aria_label='Pages'),
|
|
183
|
+
Toolbar(Button('Bold', secondary=True, aria_pressed='true'), Button('Italic', secondary=True, aria_pressed='false'),
|
|
184
|
+
Button('Underline', secondary=True, aria_pressed='false', disabled=True), aria_label='Text style'))
|
|
185
|
+
|
|
186
|
+
# %% ../nbs/08_controls.ipynb #252086a2
|
|
187
|
+
_copy_js = r"""
|
|
188
|
+
const t = document.getElementById(el.getAttribute('copyfor'));
|
|
189
|
+
const text = el.hasAttribute('copy') ? el.getAttribute('copy') : t?.matches('input, textarea, select') ? t.value : t?.textContent;
|
|
190
|
+
if (text == null) return;
|
|
191
|
+
await navigator.clipboard.writeText(text);
|
|
192
|
+
el._label ??= el.getAttribute('aria-label') ?? '';
|
|
193
|
+
el.toggleAttribute('copied', true); el.setAttribute('aria-label', 'Copied');
|
|
194
|
+
clearTimeout(el._copied);
|
|
195
|
+
el._copied = setTimeout(() => { el.removeAttribute('copied'); el._label ? el.setAttribute('aria-label', el._label) : el.removeAttribute('aria-label') }, 1500);"""
|
|
196
|
+
|
|
197
|
+
_copy_css = r"""
|
|
198
|
+
button:is([copyfor], [copy]) > svg > use:last-child { display: none; }
|
|
199
|
+
button:is([copyfor], [copy])[copied] > svg > use:first-child { display: none; }
|
|
200
|
+
button:is([copyfor], [copy])[copied] > svg > use:last-child { display: inline; }
|
|
201
|
+
"""
|
|
202
|
+
|
|
203
|
+
@hypelt(sel='button:is([copyfor], [copy])', layer='components', css=_copy_css, on={('&', 'click'): _copy_js})
|
|
204
|
+
def Copy(
|
|
205
|
+
*c, # Label text; with none, the button is square and named Copy
|
|
206
|
+
copyfor=None, # id of the element whose value, or text, is copied
|
|
207
|
+
copy=None, # Fixed text to copy instead of an element's
|
|
208
|
+
**attrs, # Attributes for the button; `secondary` replaces the default `quiet`
|
|
209
|
+
):
|
|
210
|
+
"A quiet button that copies an element's value or text to the clipboard"
|
|
211
|
+
if 'secondary' not in attrs: attrs.setdefault('quiet', True)
|
|
212
|
+
if not c: attrs.setdefault('aria_label', 'Copy')
|
|
213
|
+
return Button(CopyIcon(aria_hidden='true') + Check(), *c, type='button', copyfor=copyfor, copy=copy, **attrs)
|
|
214
|
+
|
|
215
|
+
# %% ../nbs/08_controls.ipynb #acef1e53
|
|
216
|
+
@example(Copy)
|
|
217
|
+
def _copy_example():
|
|
218
|
+
key, cmd = unqid(), unqid()
|
|
219
|
+
return Stack(Group(Input(value='sk-live-4f9c2e7b1a0d', readonly=True, id=key, aria_label='API key'), Copy(copyfor=key), inset=True),
|
|
220
|
+
Cluster(Code('pip install answerui', id=cmd), Copy('', copyfor=cmd, secondary=True), gap='var(--space-2)'),
|
|
221
|
+
style='inline-size: 24rem')
|
|
222
|
+
|
|
223
|
+
# %% ../nbs/08_controls.ipynb #9840b679
|
|
224
|
+
Button.variant('editable', r'''
|
|
225
|
+
--face: transparent; --pad-block: var(--space-2); --pad-inline: var(--space-1);
|
|
226
|
+
--face-held: oklch(from var(--tint) l c h / calc(alpha * 2)); --shadow-held: none;
|
|
227
|
+
inline-size: 100%; justify-content: start; text-align: start;
|
|
228
|
+
color: inherit; font: inherit; cursor: text;
|
|
229
|
+
border: 1px dashed var(--n); box-shadow: none;
|
|
230
|
+
&:hover { --face: var(--tint); }
|
|
231
|
+
&:is(:active, [aria-busy=true], [aria-pressed=true], [aria-expanded=true]) { --face: var(--face-held); }
|
|
232
|
+
&:active { --_shift: 0px; }
|
|
233
|
+
''', layer='components', doc='A value drawn as the dashed ghost of the well it becomes; click to edit, and the app swaps the form in.')
|
|
234
|
+
|
|
235
|
+
# %% ../nbs/08_controls.ipynb #5758d4d7
|
|
236
|
+
_switch_css = r"""
|
|
237
|
+
input[role=switch] { appearance: none; --face: var(--n-3); inline-size: 2.75em; block-size: 1.5em; margin: 0; padding: 2px;
|
|
238
|
+
background: var(--face); border: 1px solid var(--n-1); border-radius: var(--radius-full); box-shadow: var(--bevel-in), var(--sunken);
|
|
239
|
+
display: inline-grid; align-items: center;
|
|
240
|
+
transition: background var(--motion) var(--ease), box-shadow var(--motion) var(--ease); }
|
|
241
|
+
input[role=switch]::before { content: ''; --face: var(--n-2); inline-size: calc(1.5em - 6px); block-size: calc(1.5em - 6px); border-radius: var(--radius-full);
|
|
242
|
+
background: var(--face); box-shadow: var(--bevel), var(--raised);
|
|
243
|
+
transition: translate var(--motion) var(--ease), background var(--motion) var(--ease); }
|
|
244
|
+
input[role=switch]:checked { --face: var(--v); }
|
|
245
|
+
input[role=switch]:checked::before { translate: 1.25em 0; --face: var(--n-3); }
|
|
246
|
+
input[role=switch]:disabled { --face: var(--n-2); box-shadow: var(--bevel-in); }
|
|
247
|
+
input[role=switch]:disabled::before { --face: var(--n-1); box-shadow: var(--bevel); }
|
|
248
|
+
"""
|
|
249
|
+
|
|
250
|
+
@hypelt(sel='input[role=switch]', layer='components', css=_switch_css)
|
|
251
|
+
def Switch(**attrs):
|
|
252
|
+
"A checkbox with the switch role"
|
|
253
|
+
return Input(type='checkbox', role='switch', **attrs)
|
|
254
|
+
|
|
255
|
+
# %% ../nbs/08_controls.ipynb #664f6ea9
|
|
256
|
+
@example(Switch)
|
|
257
|
+
def _switch_example():
|
|
258
|
+
return Cluster(Switch(aria_label='Off'), Switch(checked=True, aria_label='On'), Switch(disabled=True, aria_label='Disabled'))
|
|
259
|
+
|
|
260
|
+
# %% ../nbs/08_controls.ipynb #19d571f7
|
|
261
|
+
_choice_css = r"""
|
|
262
|
+
input[type=checkbox]:not([role=switch]), input[type=radio] { appearance: none; --face: var(--n-3); inline-size: 1.15em; block-size: 1.15em; margin: 0;
|
|
263
|
+
background: var(--face); border: 1px solid var(--n-1); border-radius: var(--radius-1); box-shadow: var(--sunken);
|
|
264
|
+
display: inline-grid; place-content: center;
|
|
265
|
+
transition: background var(--motion) var(--ease), border-color var(--motion) var(--ease); }
|
|
266
|
+
input[type=checkbox]:not([role=switch])::before, input[type=radio]::before { content: ''; inline-size: .6em; block-size: .6em; background: var(--n-3); scale: 0; transition: scale var(--motion) var(--ease); }
|
|
267
|
+
:is(input[type=checkbox]:not([role=switch]), input[type=radio]):disabled { --face: var(--n-2); border-color: var(--n-1); }
|
|
268
|
+
"""
|
|
269
|
+
reg.rule('choice-controls', _choice_css, layer='components', doc='The small well and the mark shared by checkboxes and radios.')
|
|
270
|
+
|
|
271
|
+
_checkbox_css = r"""
|
|
272
|
+
input[type=checkbox]:not([role=switch])::before { clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
|
|
273
|
+
input[type=checkbox]:not([role=switch]):is(:checked, :indeterminate) { --face: var(--v); border-color: var(--v); }
|
|
274
|
+
input[type=checkbox]:not([role=switch]):is(:checked, :indeterminate)::before { scale: 1; }
|
|
275
|
+
input[type=checkbox]:not([role=switch]):indeterminate::before { clip-path: none; block-size: .15em; }
|
|
276
|
+
input[type=checkbox]:not([role=switch]):is(:checked, :indeterminate):disabled { --face: var(--n-1); border-color: var(--n-1); }
|
|
277
|
+
"""
|
|
278
|
+
|
|
279
|
+
@hypelt(sel='input[type=checkbox]:not([role=switch])', layer='components', css=_checkbox_css)
|
|
280
|
+
def Checkbox(**attrs):
|
|
281
|
+
"A checkbox; the choice-controls rule draws its well"
|
|
282
|
+
return Input(type='checkbox', **attrs)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
# %% ../nbs/08_controls.ipynb #6d62523e
|
|
286
|
+
_radio_css = r"""
|
|
287
|
+
input[type=radio] { border-radius: var(--radius-full); }
|
|
288
|
+
input[type=radio]::before { border-radius: var(--radius-full); background: var(--v); }
|
|
289
|
+
input[type=radio]:checked { border-color: var(--v); }
|
|
290
|
+
input[type=radio]:checked::before { scale: 1; }
|
|
291
|
+
input[type=radio]:checked:disabled::before { background: var(--n); }
|
|
292
|
+
"""
|
|
293
|
+
|
|
294
|
+
@hypelt(sel='input[type=radio]', layer='components', css=_radio_css)
|
|
295
|
+
def Radio(**attrs):
|
|
296
|
+
"A radio button; the choice-controls rule draws its well"
|
|
297
|
+
return Input(type='radio', **attrs)
|
|
298
|
+
|
|
299
|
+
# %% ../nbs/08_controls.ipynb #89e76df1
|
|
300
|
+
@example(Checkbox)
|
|
301
|
+
def _checkbox_example():
|
|
302
|
+
return Cluster(Checkbox(aria_label='Unchecked'), Checkbox(checked=True, aria_label='Checked'),
|
|
303
|
+
Checkbox(disabled=True, aria_label='Disabled'), Checkbox(checked=True, disabled=True, aria_label='Checked and disabled'))
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
# %% ../nbs/08_controls.ipynb #bcd64d9e
|
|
307
|
+
@example(Radio)
|
|
308
|
+
def _radio_example():
|
|
309
|
+
return Cluster(Radio(name='r', aria_label='Unchecked'), Radio(name='r', checked=True, aria_label='Checked'), Radio(name='rd', checked=True, disabled=True, aria_label='Checked and disabled'))
|
|
310
|
+
|
|
311
|
+
# %% ../nbs/08_controls.ipynb #8c8415b9
|
|
312
|
+
_fill = r"const lo = el.min === '' ? 0 : +el.min, hi = el.max === '' ? 100 : +el.max; el.style.setProperty('--p', (hi > lo ? (el.value - lo) / (hi - lo) * 100 : 0) + '%')"
|
|
313
|
+
_range_on = {
|
|
314
|
+
('&', 'init'): _fill,
|
|
315
|
+
('&', 'input'): _fill,
|
|
316
|
+
('form:has(input[type=range])', 'reset'): r"""
|
|
317
|
+
await new Promise(r => setTimeout(r, 0));
|
|
318
|
+
for (const range of [...el.elements].filter(i => i.matches('input[type=range]'))) { const el = range; """ + _fill + " }"}
|
|
319
|
+
|
|
320
|
+
def _range_parts(track, thumb):
|
|
321
|
+
"The track and thumb rules for one engine's pseudo-elements"
|
|
322
|
+
return relief(f'input[type=range]::{track}, input[type=range]::{thumb}') + rf"""
|
|
323
|
+
input[type=range]::{track} {{ --face: var(--n-3); block-size: var(--track); border-radius: var(--radius-full); border: 1px solid var(--n-1);
|
|
324
|
+
background: linear-gradient(to right, var(--v) var(--p), var(--face) 0); box-shadow: var(--bevel-in), var(--sunken); }}
|
|
325
|
+
input[type=range]::{thumb} {{ appearance: none; --face: var(--v); inline-size: var(--thumb); block-size: var(--thumb); border-radius: var(--radius-full);
|
|
326
|
+
background: var(--face); box-shadow: var(--bevel), var(--raised); transition: box-shadow calc(var(--motion) / 2) var(--ease); }}
|
|
327
|
+
input[type=range]:active::{thumb} {{ box-shadow: var(--bevel-in), var(--sunken); }}
|
|
328
|
+
input[type=range]:disabled::{track} {{ background: linear-gradient(to right, var(--n) var(--p), var(--n-2) 0); }}
|
|
329
|
+
input[type=range]:disabled::{thumb} {{ --face: var(--n-1); box-shadow: var(--bevel); }}
|
|
330
|
+
"""
|
|
331
|
+
|
|
332
|
+
_range_css = r"""
|
|
333
|
+
input[type=range] { appearance: none; inline-size: 100%; block-size: 1.5em; margin: 0; background: none;
|
|
334
|
+
--track: .6em; --thumb: 1.25em; --p: 0%; }
|
|
335
|
+
input[type=range]::-webkit-slider-thumb { margin-block-start: calc((var(--track) - var(--thumb)) / 2 - 1px); }
|
|
336
|
+
input[type=range]::-moz-range-thumb { border: 0; }
|
|
337
|
+
""" + _range_parts('-webkit-slider-runnable-track', '-webkit-slider-thumb') + _range_parts('-moz-range-track', '-moz-range-thumb')
|
|
338
|
+
|
|
339
|
+
@hypelt(sel='input[type=range]', layer='components', on=_range_on, css=_range_css)
|
|
340
|
+
def Range(**attrs):
|
|
341
|
+
"A slider"
|
|
342
|
+
return Input(type='range', **attrs)
|
|
343
|
+
|
|
344
|
+
# %% ../nbs/08_controls.ipynb #03205def
|
|
345
|
+
@example(Range)
|
|
346
|
+
def _range_example():
|
|
347
|
+
return Stack(Range(value=35, aria_label='Brightness'), Range(value=65, disabled=True, aria_label='Locked'), Range(min=0, max=10, value=8, aria_label='Rating'),
|
|
348
|
+
Range(min=-10, max=0, value=-5, aria_label='Offset'),
|
|
349
|
+
style='inline-size:16rem')
|
|
350
|
+
|
|
351
|
+
# %% ../nbs/08_controls.ipynb #6396d190
|
|
352
|
+
_field_css = r"""
|
|
353
|
+
[field], [field] > label { display: grid; gap: var(--space-3); font-size: var(--text-1); }
|
|
354
|
+
[field] > label { font-weight: var(--weight1); }
|
|
355
|
+
[field] > small { font-weight: var(--weight); color: var(--n1); }
|
|
356
|
+
small[danger] { color: var(--v2); }
|
|
357
|
+
[field] > label:has(> :is([type=checkbox], [type=radio])) { grid-template-columns: auto 1fr; justify-self: start; align-items: center; gap: var(--space-2); font-weight: var(--weight); }
|
|
358
|
+
[field]:has(:disabled) > label { color: var(--n); }
|
|
359
|
+
"""
|
|
360
|
+
|
|
361
|
+
@hypelt(sel='[field]', layer='components', css=_field_css)
|
|
362
|
+
def Field(
|
|
363
|
+
label, # Label text
|
|
364
|
+
control, # The control
|
|
365
|
+
hint=None, # Help text shown under the control
|
|
366
|
+
error=None, # Error message; marks the control invalid
|
|
367
|
+
**attrs, # Attributes for the field
|
|
368
|
+
):
|
|
369
|
+
"A labelled control with optional help and error text"
|
|
370
|
+
boxed = control.attrs.get('type') in ('checkbox', 'radio')
|
|
371
|
+
descriptions = []
|
|
372
|
+
if hint: descriptions.append(Small(hint, id=True))
|
|
373
|
+
if error:
|
|
374
|
+
descriptions.append(Small(error, id=True, danger=True))
|
|
375
|
+
control(aria_invalid='true')
|
|
376
|
+
if descriptions:
|
|
377
|
+
ids = [control.attrs.get('aria-describedby', ''), *(o.id for o in descriptions)]
|
|
378
|
+
control(aria_describedby=' '.join(filter(None, ids)))
|
|
379
|
+
return Div(Label(*([control, label] if boxed else [label, control])), *descriptions, field=True, **attrs)
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
# %% ../nbs/08_controls.ipynb #48d898b5
|
|
383
|
+
_validity_js = r"""
|
|
384
|
+
const f = el.closest('[field]'); let m = f.querySelector(':scope > small[validation]');
|
|
385
|
+
const ids = (el.getAttribute('aria-describedby') || '').split(' ').filter(i => i && i !== m?.id);
|
|
386
|
+
const show = e.type === 'invalid' || (e.type === 'focusout' ? el.matches(':user-invalid') : m && !el.validity.valid);
|
|
387
|
+
if (!show) { m?.remove(); ids.length ? el.setAttribute('aria-describedby', ids.join(' ')) : el.removeAttribute('aria-describedby'); return }
|
|
388
|
+
if (!m) { m = document.createElement('small'); m.toggleAttribute('validation', true); m.toggleAttribute('danger', true); m.id = 'validation-' + Math.random().toString(36).slice(2, 8); f.append(m) }
|
|
389
|
+
m.textContent = el.validationMessage; el.setAttribute('aria-describedby', [...ids, m.id].join(' '));
|
|
390
|
+
if (e.type !== 'invalid') return;
|
|
391
|
+
e.preventDefault(); if ([...el.form?.elements ?? [el]].find(c => !c.validity.valid) === el) el.focus();"""
|
|
392
|
+
_ctl = '& :is(input, select, textarea)'
|
|
393
|
+
Field.rule('validity', on={(_ctl, 'focusout'): _validity_js, (_ctl, 'input'): _validity_js, (_ctl, 'invalid', True): _validity_js}, layer='components',
|
|
394
|
+
doc="When the user leaves a control invalid or tries to submit, the browser's own validation message appears under the field in place of its bubble, listed in the control's `aria-describedby`; both go when the value is valid again.")
|
|
395
|
+
|
|
396
|
+
# %% ../nbs/08_controls.ipynb #f12ffe76
|
|
397
|
+
reg.rule('form-validation', sel='form', on={('& :is(input, select, textarea)', 'input'): r"for (const m of el.form.querySelectorAll('small[validation]')) if (!m.closest('[field]')) m.remove()"},
|
|
398
|
+
layer='components', doc='A validation message a form came back with, a `small` marked `validation` outside any field, clears once the user edits a control, since it described the values that were sent.')
|
|
399
|
+
|
|
400
|
+
# %% ../nbs/08_controls.ipynb #98f28199
|
|
401
|
+
@example(Field)
|
|
402
|
+
def _field_example():
|
|
403
|
+
return Form(
|
|
404
|
+
Field('Name', Input(name='name', placeholder='Ada Lovelace')),
|
|
405
|
+
Field('Email', Input(name='email', type='email', required=True), hint='We never share it.'),
|
|
406
|
+
Field('Notes', Textarea(name='notes', placeholder='Anything else?')),
|
|
407
|
+
Field('Plan', Select(Option('Free'), Option('Team'), name='plan')),
|
|
408
|
+
Field('Send me updates', Checkbox(name='updates', checked=True)),
|
|
409
|
+
Field('Email me about mentions', Switch(name='mentions', checked=True)),
|
|
410
|
+
Field('Weekly digest', Radio(name='digest', checked=True)),
|
|
411
|
+
Field('Volume', Range(name='volume')),
|
|
412
|
+
Field('Region', Input(name='region', value='Locked', disabled=True)),
|
|
413
|
+
Field('Username', Input(name='username', value='taken'), hint='Shown on your profile.', error='That name is in use.'),
|
|
414
|
+
Cluster(Button('Save'), Button('Cancel', secondary=True, type='button'), gap='var(--space-2)'),
|
|
415
|
+
stack=True)
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
# %% ../nbs/08_controls.ipynb #f48443b5
|
|
419
|
+
_fieldset_css = r"""
|
|
420
|
+
fieldset { margin: 0; min-inline-size: 0; border: 1px solid var(--n-1); border-radius: var(--radius); padding: var(--space); }
|
|
421
|
+
legend { font-weight: var(--weight1); padding-inline: var(--space-2); }
|
|
422
|
+
"""
|
|
423
|
+
|
|
424
|
+
Fieldset = hypelt('Fieldset', layer='components', doc='A bordered group of fields under a legend.', css=_fieldset_css)
|
|
425
|
+
|
|
426
|
+
# %% ../nbs/08_controls.ipynb #883b478c
|
|
427
|
+
@example(Fieldset)
|
|
428
|
+
def _fieldset_example():
|
|
429
|
+
return Fieldset(Legend('Notifications'),
|
|
430
|
+
Field('Email me about mentions', Input(type='checkbox', checked=True)),
|
|
431
|
+
Field('Email me a weekly digest', Input(type='checkbox')),
|
|
432
|
+
stack=True, style='--gap: var(--space-2)')
|
|
433
|
+
|
|
434
|
+
# %% ../nbs/08_controls.ipynb #ed615aa5
|
|
435
|
+
reg.rule('reveals', on={('input[reveals]', 'change'): r"document.getElementById(el.getAttribute('reveals')).hidden = !el.checked"}, layer='components',
|
|
436
|
+
doc="A checkbox or switch with `reveals='<id>'` shows that element while checked and hides it while not; render the element `hidden` to match the initial state.")
|
answerui/css/palette.css
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
--n-3: light-dark(oklch(0.9914 clamp(0, 0.00801 + 0.00551*cos((1*var(--hue) - 136.63)*1deg) + 0.00329*cos((2*var(--hue) - 268.97)*1deg) + 0.00139*cos((3*var(--hue) - 327.76)*1deg) + 0.00123*cos((4*var(--hue) - 93.61)*1deg) + 0.00125*cos((5*var(--hue) - 211.17)*1deg) + 0.00034*cos((6*var(--hue) - 339.8)*1deg) + 0.00023*cos((7*var(--hue) - 56.25)*1deg) + 0.00038*cos((8*var(--hue) - 125.04)*1deg) + 0.00015*cos((9*var(--hue) - 283.35)*1deg) + 7e-05*cos((10*var(--hue) - 349.22)*1deg) + 0.00021*cos((11*var(--hue) - 12.11)*1deg) + 0.00015*cos((12*var(--hue) - 161.94)*1deg), 0.02) var(--hue)), oklch(0.1026 clamp(0, 0.01959 + 0.00041*cos((1*var(--hue) - 19.99)*1deg), 0.02) var(--hue))); /* base: the lightness extreme (the default page) */
|
|
2
|
+
--n-2: light-dark(oklch(0.9506 0.02 var(--hue)), oklch(0.1434 0.02 var(--hue))); /* raised surface: cards, inputs */
|
|
3
|
+
--n-1: light-dark(oklch(0.7903 0.02 var(--hue)), oklch(0.3385 0.02 var(--hue))); /* hairline borders, separators */
|
|
4
|
+
--n: light-dark(oklch(0.6503 0.02 var(--hue)), oklch(0.4611 0.02 var(--hue))); /* disabled text and controls */
|
|
5
|
+
--n1: light-dark(oklch(0.5247 0.02 var(--hue)), oklch(0.5812 0.02 var(--hue))); /* muted and placeholder text */
|
|
6
|
+
--n2: light-dark(oklch(0.4217 0.02 var(--hue)), oklch(0.693 0.02 var(--hue))); /* body text; body text on surface */
|
|
7
|
+
--v-3: light-dark(oklch(0.913 0.03581 var(--hue)), oklch(0.1825 clamp(0, 0.05701 + 0.02563*cos((1*var(--hue) - 325.45)*1deg) + 0.01252*cos((2*var(--hue) - 263.8)*1deg) + 0.00819*cos((3*var(--hue) - 96.1)*1deg) + 0.00256*cos((4*var(--hue) - 85.33)*1deg) + 0.0017*cos((5*var(--hue) - 319.1)*1deg) + 0.0034*cos((6*var(--hue) - 157.26)*1deg) + 0.00073*cos((7*var(--hue) - 138.05)*1deg) + 0.00112*cos((8*var(--hue) - 2.43)*1deg) + 0.00177*cos((9*var(--hue) - 237.19)*1deg) + 0.00037*cos((10*var(--hue) - 228.33)*1deg) + 0.00064*cos((11*var(--hue) - 69.15)*1deg), 0.09221) var(--hue))); /* subtle background wash; distinct from raised surface */
|
|
8
|
+
--v-2: light-dark(oklch(0.7453 clamp(0, 0.12952 + 0.00279*cos((1*var(--hue) - 18.52)*1deg), 0.13231) var(--hue)), oklch(0.3792 clamp(0, 0.11554 + 0.05156*cos((1*var(--hue) - 327.56)*1deg) + 0.02507*cos((2*var(--hue) - 264.93)*1deg) + 0.01578*cos((3*var(--hue) - 92.55)*1deg) + 0.00467*cos((4*var(--hue) - 86.48)*1deg) + 0.00337*cos((5*var(--hue) - 312.62)*1deg) + 0.00706*cos((6*var(--hue) - 156.72)*1deg) + 0.00165*cos((7*var(--hue) - 144.83)*1deg) + 0.00212*cos((8*var(--hue) - 5.61)*1deg) + 0.00327*cos((9*var(--hue) - 233.15)*1deg), 0.18274) var(--hue))); /* wash hover, selected */
|
|
9
|
+
--v-1: light-dark(oklch(0.6068 clamp(0, 0.15177 + 0.03348*cos((1*var(--hue) - 339.18)*1deg) + 0.01411*cos((2*var(--hue) - 265.25)*1deg) + 0.02027*cos((3*var(--hue) - 71.84)*1deg) + 0.00504*cos((4*var(--hue) - 202.5)*1deg) + 0.00284*cos((5*var(--hue) - 280.18)*1deg) + 0.00522*cos((6*var(--hue) - 138.11)*1deg), 0.18647) var(--hue)), oklch(0.5094 clamp(0, 0.14536 + 0.05279*cos((1*var(--hue) - 334.05)*1deg) + 0.02127*cos((2*var(--hue) - 276.04)*1deg) + 0.02169*cos((3*var(--hue) - 73.93)*1deg) + 0.00271*cos((4*var(--hue) - 80.86)*1deg) + 0.00309*cos((5*var(--hue) - 307.8)*1deg) + 0.00789*cos((6*var(--hue) - 145.12)*1deg) + 0.00091*cos((7*var(--hue) - 251.54)*1deg) + 0.00153*cos((8*var(--hue) - 336.58)*1deg) + 0.00362*cos((9*var(--hue) - 213.73)*1deg), 0.19989) var(--hue))); /* border, focus ring; large accent text */
|
|
10
|
+
--v: light-dark(oklch(0.5109 clamp(0, 0.14555 + 0.0526*cos((1*var(--hue) - 334.09)*1deg) + 0.02117*cos((2*var(--hue) - 275.99)*1deg) + 0.02172*cos((3*var(--hue) - 73.84)*1deg) + 0.00264*cos((4*var(--hue) - 81.88)*1deg) + 0.00308*cos((5*var(--hue) - 307.72)*1deg) + 0.00788*cos((6*var(--hue) - 144.99)*1deg) + 0.00097*cos((7*var(--hue) - 254.36)*1deg) + 0.00156*cos((8*var(--hue) - 336.36)*1deg) + 0.00359*cos((9*var(--hue) - 214.08)*1deg), 0.19985) var(--hue)), oklch(0.6034 clamp(0, 0.15172 + 0.03445*cos((1*var(--hue) - 338.76)*1deg) + 0.01436*cos((2*var(--hue) - 266.04)*1deg) + 0.02036*cos((3*var(--hue) - 72.01)*1deg) + 0.00473*cos((4*var(--hue) - 201.3)*1deg) + 0.00285*cos((5*var(--hue) - 280.97)*1deg) + 0.00525*cos((6*var(--hue) - 138.08)*1deg), 0.18731) var(--hue))); /* solid fill with base-coloured label; accent text on surface */
|
|
11
|
+
--v1: light-dark(oklch(0.4609 clamp(0, 0.13622 + 0.05574*cos((1*var(--hue) - 331.36)*1deg) + 0.02464*cos((2*var(--hue) - 272.89)*1deg) + 0.0188*cos((3*var(--hue) - 78.49)*1deg) + 0.00313*cos((4*var(--hue) - 73.47)*1deg) + 0.00393*cos((5*var(--hue) - 301.46)*1deg) + 0.00794*cos((6*var(--hue) - 154.72)*1deg) + 0.00129*cos((7*var(--hue) - 189.47)*1deg) + 0.00145*cos((8*var(--hue) - 338.99)*1deg) + 0.00411*cos((9*var(--hue) - 219.84)*1deg), 0.19816) var(--hue)), oklch(0.6558 clamp(0, 0.15083 + 0.02302*cos((1*var(--hue) - 351.49)*1deg) + 0.0125*cos((2*var(--hue) - 248.44)*1deg) + 0.01618*cos((3*var(--hue) - 71.32)*1deg) + 0.00601*cos((4*var(--hue) - 217.68)*1deg), 0.17158) var(--hue))); /* solid hover */
|
|
12
|
+
--v2: light-dark(oklch(0.4111 clamp(0, 0.12402 + 0.05381*cos((1*var(--hue) - 328.74)*1deg) + 0.02534*cos((2*var(--hue) - 267.43)*1deg) + 0.01666*cos((3*var(--hue) - 87.73)*1deg) + 0.00394*cos((4*var(--hue) - 85.73)*1deg) + 0.00349*cos((5*var(--hue) - 305.12)*1deg) + 0.00764*cos((6*var(--hue) - 156.18)*1deg) + 0.00167*cos((7*var(--hue) - 153.78)*1deg) + 0.00191*cos((8*var(--hue) - 7.44)*1deg) + 0.00338*cos((9*var(--hue) - 227.69)*1deg), 0.19058) var(--hue)), oklch(0.71 clamp(0, 0.13825 + 0.01049*cos((1*var(--hue) - 10.64)*1deg) + 0.00723*cos((2*var(--hue) - 226.95)*1deg), 0.14949) var(--hue))); /* strong accent text on surface; alert text on wash */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Answer.AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|